Skip to content

Commit

Permalink
docs: Document how to deal with eslintignore warnings (#759)
Browse files Browse the repository at this point in the history
This adds an example on dealing with eslint ignored files, to fix the issues with `warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override` errors blocking commits.
  • Loading branch information
shadyvb authored and okonet committed Dec 27, 2019
1 parent 33b9752 commit 056723b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,20 @@ In certain project setups, it might be desirable to bypass this restriction. See
Note that patterns like `*.js`, `**/*.js` will still only match the project files and not any of the files in parent or sibling directories.

Example repo: [sudo-suhas/lint-staged-django-react-demo](https://github.com/sudo-suhas/lint-staged-django-react-demo).

### How can i ignore files from `.eslintignore` ?

ESLint throws out `warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override` warnings that breaks the linting process ( if you used `--max-warnings=0` which is recommended ).

Based on the discussion from https://github.com/eslint/eslint/issues/9977 , it was decided that using [the outlined script ](https://github.com/eslint/eslint/issues/9977#issuecomment-406420893)is the best route to fix this.

So you can setup a `.lintstagedrc.js` config file to do this:

```
var CLIEngine = require("eslint").CLIEngine;
var cli = new CLIEngine({});
module.exports = {
"*.js": files => 'eslint --max-warnings=0 ' + files.filter( file => ! cli.isPathIgnored( file ) ).join( ' ' ),
}
```

0 comments on commit 056723b

Please sign in to comment.