Remove warnings when linting ignored files
See original GitHub issueThe version of ESLint you are using. v7.22.0
The problem you want to solve.
When running eslint with globs or explicit paths to files and that file is ignored in .eslintignore, a warning is shown. For example, if .eslintignore contains file.js
and you run eslint file.js
, it will show warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
.
This becomes a problem when using tools like lint-staged along with eslint --max-warnings 0
flag. For example, when you’re working on a large project and during a branch merge some .eslintignored files are staged, lint-staged passes the whole staged file list to eslint. Since --max-warnings 0
causes eslint to exit with status code 1, commits are being prevented by the aforementioned warning. This is frustrating because those files are explicitly ignored.
There have already been discussions about this: https://github.com/eslint/eslint/issues/12249 https://github.com/eslint/eslint/issues/12206 https://github.com/eslint/eslint/issues/9977
Your take on the correct solution to problem.
- Instead of a warning, maybe this should be logged as info? Though I’m not sure if it’s possible to set lower severity than a warning in eslint.
- This functionality is not configurable in any way. A CLI option
--no-warn-ignored
or similar would solve such cases.
Are you willing to submit a pull request to implement this change? Yes
Issue Analytics
- State:
- Created 2 years ago
- Reactions:32
- Comments:38 (12 by maintainers)
Top GitHub Comments
I was putting this off for a long time, sorry about that. Finished the RFC: https://github.com/eslint/rfcs/pull/90
We decided in the TSC meeting that we’d like to provide a solution to this. We can discuss possible options here on the issue. One option is replicating
eslint.lintText()
'swarnIgnored
option oneslint.lintFiles()
and exposing it via a CLI option.