-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
Loading too many package.json files #1243
Comments
even simper reproducer:
|
Workaround: add explicitly tell which config to use: |
Are your additional package.json files not valid JSON? It is intentional behavior for monorepo support. |
After reading your comment again, to prevent loading them from |
Hi, lilconfig maintainer here. Lilconfig can only search recursively towards file system root. This makes me think that it is not lilconfig that "discovers" newly added package json files in a new workspace node_modules. Looking at the lint staged source code it looks like it uses git to infer all not gitignored filepaths to look up configuration files. Which makes sense for a mono repo support. All node_modules in a repository should be added to a gitignore file. +1 to @iiroj comment above. |
Yes, exactly. We enumerate all possible files from |
Could there be a way to turn off config search? Or at least fail silently on I want to add lint-staged to Bun's codebase, but it errors trying to parse this empty |
Would it make sense to just silently ignore all invalid |
@privatenumber I opened a PR here which would hide the Note that this doesn't change any exit codes because currently even with the error lint-staged basically just ignores the config file. |
That works, thanks @iiroj 🙏 |
Hello @privatenumber and @glensc, would version 13.2.1 work any better? |
@iiroj here's my reproducer: if it passes, it's fixed! |
Worked great for me, thanks @iiroj |
Description
lint-staged attempts to load foreign
package.json
files, i.e other than/package.json
in project rootLonger explanation:
I made a test in my workspace which resulted in
demo-project/node_modules
directory, which was not under.gitignore
.Having this done, I started to notice json errors when committing:
which made me enable debug to see where it comes from:
which printed and that it loaded tons of
package.json
fromdemo-project/node_modules
.I think it's bug that lilconfig is called in a way that it goes searches the files recursively:
I do not read from the readme it should do that, it should find the files from project root only.
Steps to reproduce
mkdir test
cd test
yarn add typescript
# or whatevercd ..
node_modules/lilconfig/dist/index.js
as abovetouch test
git add test
yarn lint-staged
Debug Logs
expand to view
Environment
lint-staged
: 13.1.0The text was updated successfully, but these errors were encountered: