Closed abannachGrafana closed 3 months ago
@abannachGrafana I tried reproducing this but couldn't. Could you setup a codesandbox that reproduces it?
I'll see what I can do 👍
Whoop! Was able to recreate with a simple example and multiple file locations https://codesandbox.io/p/github/abannachGrafana/eslint-sort-repro/draft/agitated-rosalind
Also I just created a public repo in GitHub that recreates so you could just check it out if you want https://github.com/abannachGrafana/eslint-sort-repro
@abannachGrafana So, this happens in instances where you have an import with a relative path that is resolvable by the isomorphic-resolve
package in node_modules. In your reproduction repo, this happened with ../../jest...
which was resolvable since isomorphic-resolve
was 2 levels deep and thus could resolve the relative path, and incorrectly assumed it was a dependency. The solution here is to detect relative imports and always flag those as non-dependencies before attempting to call require.resolve
.
:tada: This issue has been resolved in version 3.0.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Description
Relative paths greater than one layer deep e.g.
../../some/path
imports are not sorted with other relative path imports.Example config
Example sorted imports
Example sorted imports with single layer relative
Expected behavior