special/eslint: bad calculation of preset dependencies
See original GitHub issueBug Description
In a monorepo project managed by yarn
, I have a package containing my eslint configuration. Every eslint needed dependency is set as a dependency (not dev!) of this package.
This is currently working because of 2 bugs, one masking the other:
- the method
requireConfig
ofeslint.js
only searches for configuration dependency in the current directory, therefore ignoring structures like yarn workspaces; it should use the newutils.loadMetadata
function to use the real node resolution mechanism; - when analyzing
eslint
configuration dependencies, it does not look at this dependencies’ dependencies.
In a normal environment (if I had a configuration package apart), the process would fail because it would be able to analyse the project configuration file, see that a lot of packages are needed, but not see that they already are integrated because dependencies of this configuration package, so displaying a lot of “missing dependencies”.
Code snippets
In the package @my-project/eslint-config
:
File .eslintrc.yaml
:
plugins:
- react-hooks
File package.json
:
"dependencies": {
"eslint-plugin-react-hooks": "2.2.0"
}
In the package @my-project/other-package
File .eslintrc.yaml
:
extends:
- '@my-project'
File package.json
:
"devDependencies": {
"@my-project/eslint-config": "0.0.1"
}
Execution
In the directory of other-package
:
depcheck --specials=eslint
Expected result
No error.
Actual result
- with a yarn workspace, no error because hoist
eslint-config
is not seen by the analyzer; - with npm and lerna,
missing dependencies: eslint-plugin-react-hooks
because the analyzer sees theeslint-config
but does not read its included dependencies.
Versions
node -v
: 12.13.0npm -v
: 6.12.0yarn -v
: 1.19.1depcheck --version
: 0.9.1
Extra info
Sorry for not publishing a PR, but I can’t really spend more time on depcheck
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
🎉
I’ll buy you a beer next time you come to Paris 😃
Finally, I’m working on it… 😄