iancmyers / eslint-grunt

Validate files with ESLint using the Grunt task runner.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to fail grunt on warnings

Bartvds opened this issue · comments

It would be useful if there was a way to be able to use a config with both level 1 and 2 rules but optionally fail grunt on level 1 warnings.

This so we can configure 2 grunt multi-targets with the same config but have passing warnings during development and a more harsh compliance for acceptance.

I agree. I think this is a good idea.

This is fixed in v0.0.5 via a7fa67e. Instead of failing on warnings, you can force a pass on errors via the force option. So, during development, you'll set the force option to true and everything will be treated as a warning instead of an error.

Nice, will check it out.

Maybe this feature needs a companion that makes grunt fail on both errors AND warnings? For maximum flexibility.

Failing on warnings isn't possible without some really hacky workarounds. ESLint is only setup to give two return values (exit codes) 0 for no errors and 1 for errors. I use this return value to determine whether or not I should fail the task. Detecting warnings would require hooking into the output from ESLint and determining whether there are warnings based on the console output. This becomes a bit sketchy when you have the ability to drop in custom formatters.

So, I think for now the best way to deal with this particular use case is to set your config to error, and set the force option to true in the task that's part of your development watch task and set it to false for your test/pre-deploy task.

Okay, we'll see how it goes.