-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Here's the relevant bit of our config:
"import/order": [ "error", {
"groups": [
[ "builtin", "external" ],
[ "internal" ],
[ "parent", "sibling", "index" ],
[ "object", "type" ]
],
"pathGroups": [
{
"pattern": "Forms/**",
"group": "internal",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": [],
"newlines-between": "always"
} ],
This works, I think. But I fail to understand why. The pathGroups
, I assume, tells import/order
the patterns that belong to internal
imports.
But then why would I ever need to specify the position
as well? Surely this is handled by groups
already? 🤨
Also why does this only work when pathGroupsExcludedImportTypes
is an empty array? I cannot understand for the life of me what that thing actually does. But it has to do with pathGroups
, in some way or another, so I just started guessing at its value. The documentation is incredibly vague on this. Something is excluded - what is exlcuded, and from what? And what effect does it have on import order, and why?
Lastly, I shouldn't have to use pathGroups
in the first place. This is a workaround for the fact that even with a parser that understands jsconfig.json
or tsconfigjson
, after 2 years it still doesn't see that these aliased paths actually belong to internal
. I haven't looked at the code, but it feels like import/order
way of deterining what sort of import is external vs internal, is hardcoded, instead of taken from any kind of configuration to speak of.
I'd like to keep my configs DRY, but that seems impossible with this plugin. Can we get this fixed please?
Recap:
position
shouldn't be neccesary - handled bygroups
order.pathGroupsExcludedImportTypes
is vague:- Needs better explanation
- Might need a more sane default value
- Should not be neccesary when just using
pathGroups
to "assign" certain paths to a group
- Please respect project config in
jsconfig.json
ortsconfig.json
. Using one of these is the defacto standard to configure path aliases. And ESLint is aware of these when using a parser that requires them.