lint-staged npm package does not read .solhintignore
I use lint-staged like so to run my husky pre-commit hook.

So it runs solhint against every .sol file.
However, I had a linter bug with solc 0.7.4 which I reported here #262 . So I put that file in .solhintignore. When I ran solhint manually it ignores that file. But when solhint is run by lint-staged somehow it does not seem to ignore that file and the linting throws an error and the lint-staged process exits with code 2.
So I guess, lint-staged somehow does not read .solhintignore ?
I'm guessing the problem is that doing:
solhint Foo.sol
doesn't ignore Foo.sol even if it's in .solhintignore. Is that correct?
I'm not sure what is the ideal behavior here. eslint does this, which seems good enough:
- If you run
eslint .and there's an ignored file in that directory, it is ignored. - If you run
eslint foo.jsandfoo.jsis ignored, you get a warning saying that that file is ignored, and to use the--no-ignoreflag to override that behavior. - If you run
eslint '*.js'(the quotes are important), then ignored files are ignored (that is, it has a different behavior when using a glob).
For me when I run yarn solhint path/to/ignored/contract it ignores it as expected.
Same if I use a glob.
However, when I run solhint against *.sol in lint-staged it somehow stops ignoring ignored files.
If you are looking for a fix read on.
Initial setup:
- My package.json command is
"solhint": "solhint './contracts/**/*.sol'" - Content of
.solhintignoreis./contracts/dependencies/**/*.sol
Run:
npm run solhint: End command looks like thissolhint './contracts/**/*.sol'and it will ignore files given in ignore pattern.Run with lintstaged: Command that run looks like thissolhint './contracts/**/*.sol' 'user/x/y/z/contracts/a/b.sol'....'user/x/y/z/contracts/dependencies/a/b.sol'. You can see that ignore will work for 1st argument but not for all as lintstaged is passing each file individually again and with full qualified path.
Workaround
- No change in package.json command
- Update ignore pattern like this
**/contracts/dependencies/**/*.sol. Noticewildcardbefore contracts.
Run
- It will work with both approach. as new ignore pattern can filter files with full qualified path