-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Bug: Multiple packageDirs in no-extraneous-dependencies #1175
Comments
You're right that this logic is incorrect. It'd be great to get a failing test :-) |
I'm not familiar enough with this repo to send a PR, but I can suggest a minimal test: Directory structure:
root/.eslintrc
root/package.json
root/bar/package.json
root/bar/index.js
Assertion
Other scenariosIn other tests test, packageDir can be:
(Only allowing relative paths is extremely limiting, and it is not clear why this limitation exists in the documentation while |
@aravindet @ljharb Already fixed this in a PR, with a test that fails for the current version. |
According to the docs, packageDirs accepts an array of paths, and (presumably) the package.json's found at all the paths have some effect.
In the current implementation, only the last element in the array is used.
This is because
Object.assign()
is used to merge the dependencies found in each file. AsObject.assign()
performs a shallow merge, and the extractDepFields function adds default empty objects for fields that are not defined inpackage.json
, every field ends up being overridden in each iteration.I suggest that a deep merge be performed here instead of
Object.assign
.The text was updated successfully, but these errors were encountered: