sasstools / gulp-sass-lint

Gulp plugin for Sass Lint
MIT License
115 stars 43 forks source link

'max-warnings' option not respected #64

Open bobbygryzynger opened 7 years ago

bobbygryzynger commented 7 years ago

Running the following code does not result in an error as expected:

  return gulp.src(CONFIG.styles.source)
    .pipe(sasslint({
        options: {'max-warnings': 1}
      }))
    .pipe(sasslint.format())
    .pipe(sasslint.failOnError());

In the console, the task finishes without errors, despite the following output: screen shot 2016-11-15 at 8 21 51 pm

I am using version: 1.3.2.

mloayzagahona commented 7 years ago

I have the same problem but inside of the sass-lint.yaml file

image

plateniteshow commented 7 years ago

I'm experiencing the same issue in both yaml-file and javascript-code. I already browsed the original code and played with thewarningCount-variable. It seems that it is possible to create a failOnError-like function which exits when reaching a certain amount of warnings. I don't want to customize the plugin, though... I'd really appreciate a solution for this problem!

I am using version 1.3.2 aswell

esteinborn commented 7 years ago

This may be due to the fact that sass-lint implementation may utilize the --verbose flag which will not fail on max-warnings but it's just a guess

plateniteshow commented 7 years ago

I unwillingly went for another workaround. I put a custom function in the gulp-pipe, in which I can access the original lint-file, which is generated via sass-lint, and exit the task if a certain warningCount is reached. My function also accessses the config-file, so it might be the best way until the plugin gets fixed.

...I'm at home right now and have no access to the code, but I'll post my (hacky?) solution on monday.

webdevian commented 7 years ago

@Kyriou Did you dig out your solution? I've been trying a few things like grep'ing the sassLint.format() but it feels incredibly hacky

plateniteshow commented 7 years ago

Totally forgot about that, sorry. This is my (hacky) solution. I referenced this function via .pipe(xyz) in the respective gulp task.

sasslinterrorhandling

Actually I can't recall how exactly this works. As far as I remember I copied this from the failOnError-function of the original sass-lint-plugin. Not sure, though.

It's not the cleanest solution, but it works. I'm open for better and cleaner solutions.

webdevian commented 7 years ago

I opted to just use exec in the end. Until something like #72 is merged it does the job

gulp.task('sass-lint', function(cb) {
  exec('sass-lint -v', function(err, stdout) {
    if (stdout) {
      gutil.log(stdout);
    }
    cb(shouldItExit ? err : 0);
  });
});