Lint-staged: Being able to bail on error.

Created on 19 Mar 2019  路  8Comments  路  Source: okonet/lint-staged

Description

Hi there, first of, awesome package!

This is a feature request.

I was wondering if there was a way to bail on error?
Currently, I have multiple linters set up, and one of them is quite long to run.
Sometimes, other short ones fail before this long one, but we have to wait after every linters to finish their job before exiting the process.

I'm using lint-staged in a pre-commit hook with husky.
It's very useful this way.

Maybe I'm missing a configuration that would let me bail on error, if so I'd love more info on it.

Thank you!

Environment

  • OS:macOS Mojave
  • Node.js:11.6.0
  • lint-staged:8.1.0

Most helpful comment

It does make sense to me. I'll re-open the issue if you're up for working on it.

All 8 comments

I've just found out that it does bail on error, but only if concurrent is set to false.
Since we have lots of linters to run, it's not practical to set concurrent to false.

Is there a way to kill other jobs when one fails? Even in concurrent mode.
That would be awesome.

Is there a way to kill other jobs when one fails?

concurrent is meant exactly for this.

See https://github.com/okonet/lint-staged/blob/63b085f7b8a6ae953c0070fcb4122499fdb73542/src/runAll.js#L97

That said, you can experiment with this setting and propose a change if you think it will improve the UX. As far as I can remember, it didn't make sense to me to run concurrently and bail on the first error. But maybe there is a use case for that.

I feel like concurrent and bail should not be mutually exclusive.
Semantically speaking, they are not, it's just the design that makes them that way.
Because it's still great to get the speed of concurrent jobs and still being able to bail on the first one that fails.

I'll have a look, see if I figure something out.

It does make sense to me. I'll re-open the issue if you're up for working on it.

Thanks @okonet, I'll have a look as soon as I can.

Hi. Where are concurrent or other similar settings documented? How are they set? (Asking due to #730.) Thanks

In the upcoming v10.0.0 it would be possible to set exitOnError: true safely on the main tasks, since there is always a backup stash that will get restored on errors. Thoughts, @okonet?

@iiroj The "exitOnError" would be great, but I don't find any information on it on the documentation.
Is it released ? The cli option is --exit-on-error ?
Thanks.

Was this page helpful?
0 / 5 - 0 ratings