-
-
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/order
ignores pathGroups
#2736
Comments
I had to go digging through old issues, but the reason is that You'll want to set Issue which helped: |
I found another weirdness. Using Before: import { X } from 'package/src/ui'
import { useCallback } from 'react'
import { Y } from 'package/src/utils'
import { something } from './something' Expected: import { useCallback } from 'react'
import { X } from 'package/src/ui'
import { Y } from 'package/src/utils'
import { something } from './something' This will not work. rules: {
"import/order": ["warn", {
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
"pathGroups": [
{
"pattern": "package/**",
"group": "internal",
},
],
}],
}, This will work. settings: {
"import/internal-regex": "^package/",
},
rules: {
"import/order": ["warn", {
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
}],
}, Why? /edit Using it like this will also work, but why? settings: {
// "import/internal-regex": "^package/",
},
rules: {
"import/order": ["warn", {
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
"pathGroups": [
{
"pattern": "package/**",
"group": "internal",
},
],
pathGroupsExcludedImportTypes: [],
}],
}, I don't understand the description for pathGroupsExcludedImportTypes at all either.
From the example and description, I get it that when a pattern is matched, the import will be regarded as belonging to the group. But what the heck does this do??
/edit 2 Okay, after further experimenting I think that I understand what it does, but damn, that is hell confusing. The point is
Therefore if you have an import, such as This means that in order to get a |
@ackvf Thank you, you saved me a lot of time. I will document this as a quirk for future reference. |
Hi there,
I'm trying to use
import/order
with this setting:When I run the code, the linter orders the imports like this:
When instead it should order it like this:
Can you tell me, why my
pathGroups
and mygroups
setting to not work?Thanks!
The text was updated successfully, but these errors were encountered: