lazd / gulp-csslint

CSSLint plugin for gulp
MIT License
74 stars 14 forks source link

failReporter throws unhandled error #50

Closed ovanderzee closed 8 years ago

ovanderzee commented 8 years ago

When failReporter() is not used and csslint encounters an error, we see:

csslint: There are 1 problems in /file.css.

file.css
1: warning at line 9, col 5
Unknown property 'displ-ay'.
    displ-ay: none

That's good. But when failReporter(), or reporter('fail') is used we see:

events.js:154
      throw er; // Unhandled 'error' event
      ^
Error: CSSLint failed for file.css

That is not graceful. Users don't understand it. It made me suspect problems in node, gulp, csslint. It should end quietly, or only the message "Error: CSSLint failed for file.css"

setup: gulp-csslint@0.3.0

gulp --version CLI version 3.9.0 Local version 3.9.1

node --version v5.11.1

npm --version 3.4.1

bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15) Copyright (C) 2007 Free Software Foundation, Inc.

lazd commented 8 years ago

Hmm, maybe you want to include the default reporter before the fail reporter?

var csslint = require('gulp-csslint');

gulp.task('lint', function() {
  return gulp.src('lib/*.css')
    .pipe(csslint())
    .pipe(csslint.reporter()) // Display errors
    .pipe(csslint.reporter('fail')); // Fail on error (or csslint.failReporter())
});

This way, you still see the friendly error that shows what's actually wrong, and also fail.

That said, it's possible we're not failing the way gulp expects. If you don't mind testing gulp-jshint to see if it does the same with its fail reporter and reporting back, then we can continue to investigate if changes are required.

Thanks!

ovanderzee commented 8 years ago

I did use the default reporter, i tested with gulp-jshint and it fails in the same way. I made a branch "unhandled-error-event" in my project: https://github.com/ovanderzee/nl.ovdz.resource-router. Run it with "gulp develop"

Maybe the oddity is I installed node with homebrew.

ovanderzee commented 8 years ago

I'm not seeing this anymore

lazd commented 8 years ago

Any insights on what you did to fix it? What does it do now?

On May 30, 2016, at 5:19 AM, Onno van der Zee notifications@github.com wrote:

Closed #50.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ovanderzee commented 8 years ago

Now it shows what caused the error (like csslint: There are 1 problems ..... Unknown property 'displ-ay'. displ-ay: none ) and then gulp exits and we are back at the command line As expected.

I turned my computer off and later on again instead of putting it to sleep. So, i think something in the background caused it.

mickaelperrin commented 8 years ago

This error is thrown mainly if you forgot the return statement before gulp , or if you try to use gulp with a callback function.