Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pkuczynski opened this issue Oct 5, 2020 · 3 comments
Open

Comments

@pkuczynski
Copy link

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
Copy link
Author

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
Copy link
Author

I created some tests illustrating the issue #1919. Maybe they would help to solve it...

ljharb pushed a commit to pkuczynski/eslint-plugin-import that referenced this issue Jan 31, 2021
@pierceray
Copy link

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

ljharb pushed a commit to pkuczynski/eslint-plugin-import that referenced this issue Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants