eslint-plugin-import
eslint-plugin-import copied to clipboard
no-extraneous-dependencies does not report when importing from subfolder
My eslint settings:
'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/*.test.js'] }],
and package.json:
"devDependencies": {
...
"uuid": "^8.3.0",
}
The following import does not error:
const v5 = require('uuid/v5')
However it does error, when using exact package name:
const { v5 } = require('uuid')
Its quite common practice, so I believe it should complain also when referencing individual files from a package...
It looks like the issue is caused by resolve(name, context) returning undefined (https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/no-extraneous-dependencies.js#L122).
I created some tests illustrating the issue https://github.com/benmosher/eslint-plugin-import/pull/1919. Maybe they would help to solve it...
There is a similar failure for namespaced packages. import { MockedProvider } from '@apollo/client/testing';