I am using jshint to validate my scripts with grunt. I configured it and it works correctly. The only problem is that it either pass (when there are no errors) or fails if there is at least 1 error.
I am aware that I can use --force
true in my options to suppress the fail
options: {
force : true
}
But this is not what I want. I want my validation to fail if there are more than N
(let's say 10) errors.
After reading documentation, I thought I can achieve it with "maxerr" : 10
in my .jshintrc
file. But this does not solve it. The only thing it does is showing additional warning like Too many errors. (58% scanned).
when you already exceed your limit.
So is there a way to fail my validation only if I have more than N errors? By this I mean that validation would pass if I have no errors (which I have right now) but also if I have N-1
errors.
No, grunt-contrib-jshint will always fail if there is at least one error. You would have to add the feature yourself, something like this might work (requires maxErr
to be set in the task configuration):
if(!options.maxErr || results.length > options.maxErr) failed = force;