Skip to content

pathGroupsExcludedImportTypes must be set to an empty array? #2291

@thany

Description

@thany

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 by groups 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 or tsconfig.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions