-
-
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
[Docs] order
: improve the documentation for the pathGroupsExcludedImportTypes
option
#2156
Conversation
Do you have any other questions? If you do not consider a merger, please let me know. Thank you. |
…ImportTypes` option
@ljharb PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@yola-0316 yes, do you have a question? |
this PR add below demo {
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"]
}
]
}
|
@Akiq2016 i'm not sure I understand, but I'd love to review a PR that either fixes the docs, or adds a failing test case :-) |
#1665 I read this issue and knowing why we had this PR, but I think they use I think the origin docs describe clearly enough
As pathGroupsExcludedImportTypes was set to ['builtin', 'external'] as default. While we have some customize pattern in This is also why #1665 's config doesn't work and after they add a conclusion: this PR saying 'You can also use |
Maybe we could improve the original description:
In many times, the pathGroup you configured will work as your expected. but if the pathGroups pattern is same as Incorrect: {
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"]
}
]
} Correct: {
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": [] // not include external, because the react is belong to external form
}
]
} If you want the pathGroups to work, it should not be listed in pathGroupsExcludedImportTypes. If you want to disable pathGroups, it should appear in pathGroupsExcludedImportTypes. This is the original meaning. But now, it has been applied exactly the opposite way FYI: the exclude feature has been added in this PR. Perhaps we can discuss whether this configuration is necessary. Many people are now perplexed by it, even in the test case. (e.g. https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/order.js#L2385, the |
I think you’re right. We were using
I don’t think so. As can be seen from #1665, there are still a lot of people who are confused about it (including me).
I think we should update the document so that no one else uses it incorrectly. @yola-0316 However, I have some questions about the corrected configuration.
|
Just to five my 2 cents. I introduced this option only because of backward compatibility reasons. I didn't want to change the default value of this exclusion list in a minor version. And for the explanation, in my original documentation I added an example to make the usage clear. Because I don't know how to describe it clearly without adding too much sentences. I can understand that this description could lead to confusions for people that are not into the internals. I think something like
would perhaps be better? |
Motivation: #1665
I think this paragraph makes a lot of sense, and for a while, I couldn't figure out how to configure this option.