13

I would like to trigger fail CI/CD gitlab job on eslint warnings.

Eslint will fail on error, but in CI/CD I would like to fail on warnings too.

How can I do it?

nirebam368
  • 245
  • 4
  • 11
  • 1
    Either change your rules to apply them as error instead of warning, or set `--max-warnings 0`. – jonrsharpe Sep 16 '20 at 12:09
  • 3
    Does this answer your question? [Running ESLint in precommit does not stop on warnings](https://stackoverflow.com/questions/51158815/husky-running-eslint-in-precommit-does-not-stop-on-warnings) – jonrsharpe Sep 16 '20 at 12:10

2 Answers2

21

You can fail eslint on any warnings by adding the --max-warnings=0 flag. For example:

eslint '**/*.js' --max-warnings=0
Brady Dowling
  • 4,920
  • 3
  • 32
  • 62
1

You could use eslint-plugin-only-error to convert all your warnings to errors

David Bradshaw
  • 11,859
  • 3
  • 41
  • 70