-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import/extensions should have a ignorePackages option #414
Comments
This makes sense to me. Feels like another mode between |
Great! I too want to force extensions only for everything that is not a main entry in package.json
Naming is hard :D |
maybe |
Do you have other example of eslint rules with two different string parameters? I am not comfortable with "!packages", again do you have example of an eslint rule having that sort of string based configuration with a negation? Why not provide an option object an drop the string based one? Major ftw :D |
I think a string and then a flag object is probably ideal. No one is surprised by booleans on an options object. Or maybe I suppose this new behavior would ignore index.js files too. Not sure how to denote that via the flag override name. |
I would not ignore index.js files, only packages. |
Sure, but if import { x } from './foo' // acceptable
// vs
import { x } from './foo/index' // definitely still reported I think of |
In my project I specifically want to always enforce file extensions on anything that is not the main export of an external package. Again that's also maybe just me, but this is what I am looking for. |
My goal being: when looking at local imports, I never want to ask myself: "Is this a folder? Is this the index.js file?" => always be specific on local |
Ah, got it. I'm not sure that the two are distinguishable, ATM (explicit package main vs. implicit folder index file). (edit: without some additional resolver enhancements) Would it be workable if it ignored both? or are you depending on this rule to suss out implicit |
Yep for a first start and if it requires a lot of changes it would work for me but ultimately I would love to have something like "disallowImplicit: true" "allowMainPackage: true" :) |
Yeah, seems like an anti-version of #394. I'd be up for that, but feels like a separate problem (and rule) than this one, just mandating extensions. |
This really is a must-have in order to use this rule. (edit: as others have noted, should read "in order to use this rule to require specifying |
(note: it's only a must-have if you want to require extensions for files that are the "main" export of packages - the airbnb config's settings forbid JS extensions, and require them for non-JS files, so it doesn't run into trouble here) |
@ljharb then I've misunderstood the issue. My understanding is that the OP doesn't want to use the extension on the main export of packages. Are you saying setting |
@SimenB no, i'm saying that if you don't choose "always" for JS files, then it works fine. This issue only exists when you require extensions on |
Ah, gotcha. I've heard |
@SimenB in node, |
Here's a PR: #827 I went with the |
I had the similiar problem and I fixed it with this line of code in my And in component I call resources like this: |
We have the same problem. We want to always require the "js" extension because we're also having "jsx" extensions and want to avoid confusion. Unfortunately there is still no option which fixes this for packages. The comment above is about never requiring extensions so it won't fix anything :/ |
[new] import/extensions should have a ignorePackages option. Fixes #414
Currently setting
import/extensions
toalways
reports the following as an error:However, packages default entry point (and extension) should be resolved by the loader, so it doesn't really make sense to do:
The text was updated successfully, but these errors were encountered: