-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Migrating from tslint ordered-imports to import/order #1311
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
Comments
Seems like you’d want the groups option to be available on https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md ? |
@ljharb thanks for the quick feedback! What I think we need, in order to have a compatible behaviour here, is to be able to apply the required group order defined above, but every time we found a new line between the imports, just considerer it as a new group and then restart the group rank and build starting on the next import (in case it exists). I think the better way is to add a new option for |
Since groups are configurable I’m not sure how that would work - what I’m envisioning is actually moving the entire groups option to plugin-wide settings, and modifying this rule to respect them. |
@ljharb Before I made the suggestion on the last comment, I had a quick look into the code. I think in case we wanna implement the option What do you think? |
I do not think that logic would be good. Groups should be explicit, not inferred by the presence or absence of newlines. |
@ljharb thanks for your thoughts! In my perspective, what is import here, is the ability to achieve multiple batches of groups (thats why I was suggesting to extend the logic for new lines). That would be important to assure compatibility for the users migrating from The current
I can think at least in one use case where this batch of groups logic would make sense: when someone just want to order their imports for example by matter however they still wanna assure that Do you think we can think about any way of supporting this using that plugin? 😃 |
I don’t think it’s useful to allow that kind of haphazard “however you want” grouping, no. I think this plugin’s existing grouping convention is what we need to follow. |
@ljharb thanks again for the feedback. I just think it is not possible for us to use that plugin at all then. |
@ljharb personally I think this is a reasonable feature to add to This could be done easily in tslint by using |
@mistic thanks for raising this issue. I'm also running into the same problem. It would be great if we have this feature. |
@slvganesh I just gave up on that issue and also that plugin since last @ljharb answer. It was clear that implementing this feature was not on the path they wanna follow on the library, so that is nothing else we can do here! |
@mistic did you postpone your tslint -> eslint migration due to this issue or did you find another way? (any chance you wrote your own plugin?) |
@mistic @falkenhawk This is holding up our tslint -> eslint migration too, so if either of you have found a solution I would love to know about it. I really don't want to have to reimplement the tslint |
@falkenhawk @abierbaum I did not find any bullet proof solution / workaround other than re-implement the plugin on my own. As we didn't want to dig and use our time for it I just did the most similar thing I could:
Then I just fixed the remaining conflicts and move on with the migration. We just didn't want to loose to much time with that problem, so we just found another different way of doing things. |
I'm hitting the same problem. I understand the purpose of the plugin, and that I should probably try to modify the way I work on my project, instead of trying to modify the way the plugin works. But I think my use case is worth mentioning: I am actually working on a scoped monorepo project, and I would like all import coming from other packages of the same project to be grouped together, which makes, for example: import http from 'http';
import { MyClass } from '@my-project/other-package';
import { LocalClass, localFunction } from '../utils'; |
@benmosher @ljharb we're facing the same issue with migration from |
Try the new |
When migrating from
tslint ordered-imports
ruleimport/order
is the one recommended here https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.mdI was trying to configure in the following way, which seems to be the most approachable one:
However there is one option from
tslint ordered-imports
not covered by that plugin: the ability to have multiple different groups separated by new lines (more info here: https://palantir.github.io/tslint/rules/ordered-imports/)Are there any plans to support this @benmosher @ljharb ?
The text was updated successfully, but these errors were encountered: