In a nodejs project I have a shortcut yarn lint
that runs couple of linters in such way:
lint_1 && lint_2 && lint_3
If any of these find an error it return an error code, as a result yarn lint
itself returns error code, as a result - build fails.
It works somewhat fine, catches all the errors though there is a small issue: If a linter fails with error code - rest of the linters wont be executed.
What I would like - execute all of them (so they all print all errors) and only then fail.
I know that I can create a bash script (that I will run in yarn lint
), run each of the linters one by one collecting return codes and then check if any of codes is non-zero - exit 1
and it will fail the yarn lint
. But I am wondering is there more elegant way to do it?
You could trap on ERR and set a flag. This would run each of the linters and exit with failure if any one of them fails: