eslint-plugin-import: `import/no-extraneous-dependencies` regression from 2.22.1 to 2.23.0 on Yarn 2 with npm dependency protocol
When I bump eslint-plugin-import
from 2.22.0 to 2.23.0, the linter bails under certain Yarn 2 npm:
protocol dependencies
package.json
:
{
"devDependencies": {
"@babel-baseline/parser": "npm:@babel/parser@^7.14.0" // "npm:" is a yarn 2 protocol
}
}
Input code:
import baseline from "@babel-baseline/parser";
// eslint complains
// '@babel/parser' should be listed in the project's dependencies. Run 'npm i -S @babel/parser' to add it (import/no-extraneous-dependencies)
ESLint config: https://github.com/JLHwung/babel/blob/c18d774916c7fdec04c5ef5b4cdc3be31cddc55f/.eslintrc.cjs
Although this issue might be specific to yarn 2, one can replace npm:@babel/parser
to any local path supported also by npm, as long as the name
in package.json
(@babel/parser
) does not equal to the value of import specifier (@babel-baseline/parser
).
The linter is happy on 2.22.0 and 2.22.1.
Reproduction: https://github.com/JLHwung/babel/commit/c18d774916c7fdec04c5ef5b4cdc3be31cddc55f, clone this repo and run yarn; make build; make lint
.
Might be related: https://github.com/benmosher/eslint-plugin-import/issues/1712
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
Can confirm it is fixed in 2.23.4. Thanks!
Good question! The import is renamed to make it clearly that we are benchmarking against the npm published version of
@babel/parser
, as a baseline, versus the current@babel/parser
(resolved to./packages/babel-parser/lib/index.js
in a yarn 2 workspace).I agree with @ljharb, it would be great if I don’t have to duplicate the alias info in both
package.json
and.eslintrc
.