Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running ESLint in precommit does not stop on warnings

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

like image 836
Pablo Avatar asked Jul 03 '18 15:07

Pablo


Video Answer


1 Answers

You need specify --max-warnings param.

Something like this:

"scripts": {
  ...
  "lint": "eslint \"**/*.js\" --max-warnings=0",
  ...
},
like image 100
Oleg Vikoultsev Avatar answered Sep 29 '22 02:09

Oleg Vikoultsev