Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make eslint exit on first error

I have to work on existing javascript code that has not been linted before. Running eslint is throwing 800+ problems with 700+ errors.

In order to clean up things, that can't be fixed using --fix, I would like to work on the errors step by step. It would therefore come in very handy to configure eslint to exit on the first error it can find.

Is that actually possible, e.g. with a workaround? I searched the cli doc and the rules doc but could not find anything similar.

Update: I am running on linux, so a shell-based solution would also be valid to me.


Edit:

Another use case would be saving computational time on a CI - Pipeline, where the code is supposed to be clean and ready for build and deploy unless there has been an error found, then it should immediately stop. On a large code base this can save a great amount of time over a longer period.

like image 669
Jankapunkt Avatar asked Jan 12 '18 10:01

Jankapunkt


2 Answers

Hope my answer is proven wrong, but unfortunately, according to this github issue there wasn't enough interest in 2018 for the eslint team to sponsor this request.

like image 84
jlee Avatar answered Nov 12 '22 12:11

jlee


Eslint does not support this.

But, eslint does take arguments that allow you to specify which file(s) you want to scan. You could write a script that tries each file one by one (stopping as soon as you get an error). That will result in all errors in that last file being printed - but even that should be a much easier list to satisfy than the one you're currently dealing with.

As for pipelines - I don't think it'd save that much time. Specifically, it'd only save time on a failed build, and ideally most of your builds should succeed. You could look into git commit hooks though - that way you could quickly scan the files you've changed before they go into the repo.

I suspect this is the closest you're going to get to your request, unless you sponsored or wrote this feature yourself.

like image 1
Shadow Avatar answered Nov 12 '22 12:11

Shadow