no-extraneous-dependencies doesn't support nested package.json
See original GitHub issueExample of my project structure:
├── package.json
├── src
│ ├── components
│ │ ├── Avatar
│ │ │ ├── Avatar.css
│ │ │ ├── Avatar.js
│ │ │ ├── README.md
│ │ │ └── package.json
│ │ ├── Button
│ │ │ ├── Button.css
│ │ │ ├── Button.js
│ │ │ ├── ButtonSpinner.css
│ │ │ ├── ButtonSpinner.js
│ │ │ ├── README.md
│ │ │ └── package.json
Root package.json contains all dependencies, nested package.json looks like this:
{
"name": "Avatar",
"main": "Avatar.js"
}
That’s why I got wrong warnings:
src/components/Avatar/Avatar.js
1:1 error 'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it import/no-extraneous-dependencies
2:1 error 'classnames' should be listed in the project's dependencies. Run 'npm i -S classnames' to add it import/no-extraneous-dependencies
Is this fixable?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:40
- Comments:51 (13 by maintainers)
Top Results From Across the Web
no-extraneous-dependencies doesn't support nested package ...
I use package.json instead of index.js . I'm not used to monorepos. I'm too. It's not monorepo.
Read more >Why (and How Can I FIx) ESLint import/no-extraneous ...
As far as I can tell, there is no issue with your package.json, ... -plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md.
Read more >npm-prune
Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed....
Read more >eslint/eslint - Gitter
I understand babel-eslint is by design more loose so as to support experimental ... Run 'npm i -S assert' to add it import/no-extraneous-dependencies....
Read more >@lingui/macro - Reference — LinguiJS documentation
It's recommended to install @lingui/macro package as a production dependency rather than development one to avoid import/no-extraneous-dependencies errors ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When trying to pass a function to the rule with both eslint 5.16.0 and 6.0.0-alpha I get
Expanding on my previous comment, here’s what my ESLint settings look like:
Inside
srcI have 3 main folders:services,components, andscenes(this is for a large React Native app, by the way). Each of those main folders contains apackage.jsonthat looks like this (each with their respective names):Elsewhere in my project I can now import a component (or a service or a scene) by simply typing:
This is much more manageable than typing something like:
Currently, I get
import/no-extraneous-dependencies: 'react' should be listed in the project's dependencies. Run 'npm i -S react' to add itbecause the minimalpackage.jsondoesn’t have dependencies and the rule doesn’t care to look up higher in the directory tree.If the rule allowed me to do the following, it would solve this issue: