question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[import/order] 2.20.1 Windows only: Resolver cannot distinguish external and internal imports

See original GitHub issue

Hi there,

When using import/order in conjunction with the import/no-unresolved rule, it doesn’t appear possible to configure a resolver to distinguish between external (i.e. node_modules) and internal/absolute imports (i.e. src). In every case, either the resolver groups the external and absolute imports together, or, the resolver is unable to resolve one of the groups.

The following configuration is able to automatically add a newline between the external and absolute imports, but is unable to resolve the external imports:

"eslintConfig": {
    "extends": [
      "eslint:recommended",
      "react-app",
      "plugin:import/recommended",
      "plugin:import/react"
    ],
    "rules": {
      "import/order": [
        "error",
        {
          "groups": [
            "builtin",
            "external",
            "internal",
            "parent",
            "sibling",
            "index"
          ],
          "newlines-between": "always"
        }
      ]
    },
    "settings": {
      "import/external-module-folders": [
        "node_modules"
      ],
      "import/resolver": {
        "node": {
          "moduleDirectory": [
            "src"
          ],
          "extensions": [
            ".jsx",
            ".js"
          ]
        }
      }
    }
  }

In order to get the external imports to resolve, adding node_modules to the module_directory works, but then external and absolute internal imports are grouped together.

I’ve tried additional configurations using the webpack resolver as well, but am running into the same problem. Any help would be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
bduff9commented, Mar 12, 2020

Running into this same issue on Windows, any timeline on when this fix will be released?

4reactions
warnellwcommented, Feb 17, 2020

@ljharb Yes, #1651 seems to have fixed it - thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[import/order] 2.20.1 Windows only: Resolver cannot ... - GitHub
In every case, either the resolver groups the external and absolute imports together, or, the resolver is unable to resolve one of the...
Read more >
eslint import/order breaks down when using typescript aliases
I choose to use the ~ symbol instead of @ to create a difference between importing from my src folder and importing from...
Read more >
eslint-plugin-import | Yarn - Package Manager
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
Read more >
Package List — Spack 0.20.0.dev0 documentation
graphite2, py-flake8-import-order, r-rgdal ... libFLAME is a C-only implementation and does not depend on any external FORTRAN libraries including LAPACK.
Read more >
eslint-plugin-import - Bountysource
I'd like to forbid deep internal imports from libraries, e.g. import internalFunction from 'some-lib/deep/down/in/the/dark/internalFunction'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found