eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

no-extraneous-dependencies does not report when importing from subfolder

Open pkuczynski opened this issue 5 years ago • 3 comments

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...

pkuczynski avatar Oct 05 '20 10:10 pkuczynski

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).

pkuczynski avatar Oct 05 '20 10:10 pkuczynski

I created some tests illustrating the issue https://github.com/benmosher/eslint-plugin-import/pull/1919. Maybe they would help to solve it...

pkuczynski avatar Oct 05 '20 10:10 pkuczynski

There is a similar failure for namespaced packages. import { MockedProvider } from '@apollo/client/testing';

pierceray avatar May 25 '21 19:05 pierceray