Eslint error: 'dependency' should be listed in the project's dependencies
See original GitHub issueBackground
When I generate a new roc project I see that eslint picks up a lot of errors similar to the one below:
My understanding of this problem is that this is a result of roc’s design choices: roc takes over the responsibility of handling such dependencies for me: my project no longer depends on react, it depends on roc and roc depends on react.
However, since eslint is a stage of my CI process, I cannot have any eslint errors in my code.
Questions
- How would you recommend solving this?
- Is adding the roc dependencies as
peerDependenciesin my project a good solution? - Can this be done automatically by
rocso I don’t have to do it manually each time?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
eslint should be listed in the project's dependencies, not ...
I give the specifics in this post: ESLint error: '@storybook/react' should be listed in the project's dependencies, not devDependencies.
Read more >import/no-extraneous-dependencies: Complains about node ...
It throws an error which says 'path' should be listed in the project's dependencies. Run 'npm i -S path' to add it.
Read more >ESLint - npm
Make sure your plugins (and ESLint) are both in your project's package.json as devDependencies (or dependencies, if your project uses ESLint at runtime)....
Read more >Vite and @vitejs/plugin-vue as devDependencies - Reddit
I got these ESlint errors in vite.config.js file: '@vitejs/plugin-vue' should be listed in the project's dependencies, not devDependencies.
Read more >A Guide to ESLint | Laurie on Tech
The above code will only show a linting error when core dependencies are imported but not included. Any other dependency type can be...
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
To support this in an optimal way we need to do as what @fix-fix suggests, creating a
eslint-import-resolver-rocand probably aeslint-config-rocas well. I have thought about doing this myself but never gotten around to it and if someone is up for it I think it would be a great addition to the ecosystem and something I think we could host under this organization.To manage this currently I often just either set this rule to a warning or turn it off completely.
With that said, I could not stop myself from giving this some more thought and I now have something you can test in your project @wadim.
Note that this is an experiment and should be optimized further in the future if it works.
.eslintrcExample that uses
eslint-config-airbnbeslint-config-roc.jseslint-import-resolver-roc.jsIt should be solved by writing custom resolver for
eslint-plugin-import(or maybe just usingeslint-import-resolver-webpack, if it’s possible to provide webpack config at runtime), see docs