Open Netail opened 3 months ago
That's a cool idea, but I'm not sure how we could reliably detect if another package is using a dependency that isn't specified in its own dependencies
/ devDependencies
. At a first glance, we would have to analyze the source code for all packages to detect any import statements, which might be expensive.
Do you have any other idea in mind?
That's a good question, to which I do not have the answer to :(
eslint-plugin-import has a similar rule.
Does it work with monorepo's?
Yes, it looks for dependencies in the nearest package.json file. I use it in my monorepo.
Summary
When working in a mono repo, you can import packages from the node_modules which are used by other packages within the mono repo, but not listed in the dependency list of the package you are working in. It might be nice to give the user a heads up to include the dependency in their dependency list too.
Example
As both package a & b use react, the react is installed in the root node_modules, thus allowing it to be imported by package c too. When react is also used in the source code of package c, it should be listed in the dependency or dev dependency list