You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Of particular note, package b depends on c, and pnpm structures things as above so that t/index.js won't see c as a phantom dependency. c exports a named export 'foo', and b rexports that with export * from 'c'.
When t/index.js imports b, standard Node module resoluton resolves that via the symlink t/node_modules/b, returning the absolute realpath /some/absolute/path/t/node_modules/.pnpm/b@1.0.0/node_modules/b/index.js. Resolving c relative to that path finds it via the symlink t/node_modules/.pnpm/b@1.0.0/node_modules/c.
eslint-import-resolver-node's resolution differs in one key respect: by default, instead of returning the absolute realpath /some/absolute/path/t/node_modules/.pnpm/b@1.0.0/node_modules/b/index.js, it returns /some/absolute/path/t/node_modules/b/index.js instead. It then (correctly) cannot resolve c relative to that path.
A relevant eslint.config.js to use with the above could look like this:
I note the README for the resolve package you use recommends setting preserveSymlinks: false to match Node's behavior; as far as I can tell, preserving symlinks was only the default in Node for a short time between 6.0.0 and 6.2.0, although the documentation as to the expected behavior was unclear before that.
The text was updated successfully, but these errors were encountered:
You are correct that this value should be set to false by default. The reason that we don't do that in the node resolver at the moment is because that would be a breaking change.
Consider this example project, structured similarly to what pnpm produces: t.tar.gz
The directory structure looks something like this:
Of particular note, package
b
depends onc
, and pnpm structures things as above so thatt/index.js
won't seec
as a phantom dependency.c
exports a named export 'foo', andb
rexports that withexport * from 'c'
.When
t/index.js
importsb
, standard Node module resoluton resolves that via the symlinkt/node_modules/b
, returning the absolute realpath/some/absolute/path/t/node_modules/.pnpm/b@1.0.0/node_modules/b/index.js
. Resolvingc
relative to that path finds it via the symlinkt/node_modules/.pnpm/b@1.0.0/node_modules/c
.eslint-import-resolver-node
's resolution differs in one key respect: by default, instead of returning the absolute realpath/some/absolute/path/t/node_modules/.pnpm/b@1.0.0/node_modules/b/index.js
, it returns/some/absolute/path/t/node_modules/b/index.js
instead. It then (correctly) cannot resolvec
relative to that path.A relevant
eslint.config.js
to use with the above could look like this:which will produce the following false positive due to this bug
If you want a "real" reproduction, starting in an empty project:
"type": "module"
(or use extension.mjs
instead of.js
in steps 3 and 4).pnpm add eslint eslint-plugin-import @playwright/test
.eslint.config.js
.import { expect } from '@playwright/test';
.As for a fix, it looks like setting
preserveSymlinks: false
ineslint-plugin-import/resolvers/node/index.js
Lines 11 to 20 in d5f2950
I note the README for the resolve package you use recommends setting
preserveSymlinks: false
to match Node's behavior; as far as I can tell, preserving symlinks was only the default in Node for a short time between 6.0.0 and 6.2.0, although the documentation as to the expected behavior was unclear before that.The text was updated successfully, but these errors were encountered: