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 sort-imports member sorting into a separate option #11019
Add sort-imports member sorting into a separate option #11019
Comments
Given the pluggable nature of ESLint and the size of the plugin community, we can't always ensure that all rules work with plugins. I'm not convinced we need an entirely new rule to solve this problem. I wonder if a better solve would be to deprecate the {
"sort-imports": ["error", {
"sortDeclarations": true,
"sortMembers": true,
}]
} If we decide to go down this route, we should do this in a backwards compatible way. |
That proposal seems just as good to me. 👍 For backwards compatibility, I suggest the following signature: {
"sort-imports": ["error", {
ignoreMemberSort: false, // Already exists
ignoreDeclarationSort: false, // Analogous to `ignoreMemberSort`. The default matches the current behavious.
...otherOptions
}]
} |
The proposal to add an option to turn off declaration sort seems reasonable to me. 👍 @remcohaszing are you will to submit a pull request for this proposal? |
I'll give it a try somewhere this week. |
This allows users to enforce sorting import members, without having to enforce sorting of import declarations.
Can someone look into the related PR ? There hasn't been any action taken in over a month, and I'm also very interested in having a rule to check ordered and sorted imports. |
Thanks for the ping, we'll take a look. |
TSC Summary: This proposal seeks to add another option, TSC Questions:
|
Rule changes do not require TSC consent, unless they are breaking. In that case, it looks like there's a champion and 1 up vote already on the proposal. It's now up to the champion to gather more support from the rest of the team, until this issue can be accepted. |
@ilyavolodin oh right, duh! Thanks. |
Is any action required from me? I thought not, but it’s taking much longer to get merged than I expected. |
@remcohaszing thanks for the ping. Sorry, a lot of team members are taking time off around this time of year, so things can take a bit longer than usual. It looks like enough team members support this change so I'm marking as accepted. The next step is to review the PR. |
* Update: Add sort-imports ignoreDeclarationSort (fixes #11019) This allows users to enforce sorting import members, without having to enforce sorting of import declarations. * Docs: fix typo in documentation for sort-imports
What rule do you want to change?
sort-imports
Does this change cause the rule to produce more or fewer warnings?
Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
Currently,
sort-imports
does two checks. One is always on, the other is optional. I would like to only use the optional part.One part is that it checks the order of import statements. This can’t be turned off. I would like to check this using import/order, which offers more advanced features.
The part of the rule I would like to use, is the sorting of the imported members.
My proposal is to split the distinct
memberSort
option into a separate rule:sort-import-members
.Please provide some example code that this change will affect:
What does the rule currently do for this code?
sort-imports
will cause conflicts withimport/order
, but also make sure import members are sorted nicely.What will the rule do after it's changed?
sort-imports
should be disabled to prevent conflicts withimport/order
.sort-import-members
will ensure the imported members are sorted, assort-imports
does now.The text was updated successfully, but these errors were encountered: