codepunkt/gulp-jscs-stylish

The presents of error doesn't fail the gulp task

Closed this issue · 4 comments

Is there a way to fail the gulp task when there are jscs errors other wise the next gulp task is executed regardless of jscs errors being present. The only way I see of now is removing the on error noop handler but there you get the ugly errors printed out by jscs itself.

gulp.task('default', function () {
    gulp.src([ 'file.js' ])
        .pipe(jscs())      // enforce style guide
        .pipe(stylish());  // log style errors
});

Any ideas?

Thanks,

Jon

I've found a way to fail the task but it is using jshint. This is working for me now but doesn't seem like the ideal solution. Note I'm not acutally using JSHint just using the jshint reporter.

gulp.src([ 'file.js' ])
    .pipe(jscs())
    .on('error', noop)                        // don't stop on error
    .pipe(stylish.combineWithHintResults())   // combine with jshint results
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'));

Seems fine to me. Whats the problem with it?

I guess the problem is the fact that this hack only works when you use jshint as well.

That's correct. PRs are welcome!