-
-
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
Add support for absolute imports to import/order #512
Comments
Adding a new import type I'm curious though as to why you import modules this way. Do you mind explaining it to me? :) |
Sure, I'm using meteor and it allows me to import files from the root dir with For Example: import a from '../../../client/components/button'; So i have this instead: import a from '/imports/client/components/button'; So it's clearer where the file is located and it easier to find them. |
Hmm, sounds like a resolver would be more appropriate in your case. @benmosher thoughts on that? |
The Resolver isn't the problem, I'm using this resolver: https://github.com/clayne11/eslint-import-resolver-meteor, which handles the absolute imports correctly. The problem is the order. |
@jfmengels yeah, it's a little weird because they aren't technically absolute on the filesystem, but they certainly look that way. I'm thinking about making it possible for the resolver to specify what Given that, I think these imports would be classified as So the question becomes: do you think it's worth adding the |
My thoughts exactly :)
Pretty sure you can do import foo from '/home/users/me/foo.js'; in "vanilla" Node, so it's probably worth it, yeah. Would make a rule to forbid absolute imports (which sounds to me like a great rule, hopefully never useful) pretty easy.
Sounds good to me. And when the resolver doesn't overcharge the importType detection, or returns null or something, it should fallback on the core importType algorithm. |
Removing myself from this issue, as it is now more of a resolver thing, which I'll gladly leave to someone else 😅 |
actually @jfmengels, I think this is fixed by the changes in #530? since you added |
Well, the original problem is solved, but you mentioned this which hasn't been done, and is probably nice to have. (maybe rename the issue or create a new one?) |
Ah, yeah, I'm tracking that via #479 at the moment. (but it looks like it's not necessary to close this issue, just me getting distracted and off track... 😅) |
Currently, when you have the order rule turned on and the option
newlines-between
set toalways
it will give errors when you have something like this:
This will report having an empty line between the imports which in my opinion isn't correct.
Proposal
Add a new string to the order rule called
absolute
.The text was updated successfully, but these errors were encountered: