27

I'm adding some precommit and prepush scripts to my project. I'm using Husky because it keeps tracked on git any change.

On my package.json I have:

"precommit": "npm run lint && npm run test",

Which initially seems to be working fine, when any test or lint error was found I was unable to make the commit.

Now I found that if I have a warning, the commit happens anyway.

How can I configure Husky, or maybe ESLint, to stop the commit when there are warnings?

I know I could override all eslint configs to be always error [2], but I'm expecting there is something better

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Pablo
  • 9,424
  • 17
  • 55
  • 78

2 Answers2

63

You need specify --max-warnings param.

Something like this:

"scripts": {
  ...
  "lint": "eslint \"**/*.js\" --max-warnings=0",
  ...
},
Oleg Vikoultsev
  • 646
  • 7
  • 6
0

"eslint --cache --max-warnings=-1" ignore all eslint warnings

spstar
  • 1