eslint-plugin-require-extensions
eslint-plugin-require-extensions copied to clipboard
TypeScript paths
When using custom TypeScript paths the import is completely ignored (and therefore ESM invalid):
import { hello } from "@/world"; // IGNORED!
import { test } from "@/world/wow" // IGNORED!
Correct behaviour:
import { hello } from "@/world/index.js";
import { test } from "@/world/wow.js"
There is the need to understand if the import path points to a folder or a file and then apply the corresponding logic.
I was so happy when I found this, for converting a large existing repo, but then I realized that most of my paths use aliases 😞
Happy to accept a PR to fix this!
I don't think it's an easy fix. I tried hacking my way around it, but it didn't work, and I ran out of time. I'm going to park this for now.
same issue, hope someone have a good idea.
@jordaaash Would you accept a PR which adds an ability to specify alias mapping for your two rules? Similar to these two: eslint-import-resolver-custom-alias and eslint-import-resolver-alias.
Ideally, it would take the list of aliases from any of these:
package.jsonbrowserfield- webpack conf
resolve.aliasfield tsconfig.jsonpathsbut that would be much more complicated to implement.
FYI just to report that I managed to do a rewrite in which the existing import resolution aliases (webpack, jsconfig, tsconfig...) are taken into account. I decided to publish a new package, given the unresponsiveness here, although I have to thank the original authors for the inspiration.
Introducing eslint-plugin-esm-import plugin: https://github.com/sematext/eslint-plugin-esm-import
@mbonaci Sorry about that! I had some of my Github emails going to an old work email address for quite a while, so I didn't see the notifications here until yours this week. I'd be happy to accept a PR to fix this behavior, and I'll check out your new package as well. If there's an opportunity for us to consolidate I'm very open to it, as we haven't been updating this in some time.
@jordaaash No worries.
If there's an opportunity for us to consolidate...
I'd be open to that. You can ping me here when you check it out.