gulp-stylelint
gulp-stylelint copied to clipboard
gulp-stylelint failing out of gulp process on error
When I have a stylelint error, it is failing out of gulp, which means I have to completely restart Gulp every time I make a mistake.
(At first I thought this was a gulp-notify issue, but it persists when gulp-notify is disabled.)
My gulp task:
// Build CSS.
const compileCSS = () => {
const sassOptions = {
includePaths: ['node_modules']
}
const stylelintOptions = {
reporters: [
{
formatter: 'string',
console: true
}
]
}
return gulp.src(paths.css.src)
.pipe(stylelint(stylelintOptions))
.pipe(gulpif(isDev, sourcemaps.init()))
.pipe(sass(sassOptions))
.on('error', notify.onError((error) => {
return error.message;
}))
.pipe(postcss([ autoprefixer() ]))
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(gulpif(!isDev, rename({ suffix: '.min' })))
.pipe(gulp.dest(paths.css.dest))
.pipe(browserSyncServer.stream())
}
And the terminal output:
[16:02:18] Starting 'compileCSS'...
[16:02:19]
_src/css/global/_images.scss
90:1 ✖ Expected empty line before comment scss/double-slash-comment-empty-line-before
90:13 ✖ Expected a space after // scss/double-slash-comment-whitespace-inside
[16:02:19] 'compileCSS' errored after 884 ms
[16:02:19] Error in plugin "gulp-stylelint"
Message:
Failed with 2 errors
Details:
domainEmitter: [object Object]
domainThrown: false
This should show a notification on my machine, but it doesn't; it's just failing in the terminal.
I am running the latest of all relevant packages as of this writing:
- gulp 4.0.2
- gulp-stylelint 13.0.0
- stylelint-scss 3.17.2
I'm also having the same issue.
gulp.task('sass:stylelint', function () {
var src = config.sass.watchSrc;
if (config.sass.lint.extraSrc) {
src = src.concat(config.sass.lint.extraSrc);
}
return gulp.src(src)
.pipe(gulp.$.stylelint({
reporters: [
{
formatter: 'string',
console: true,
failAfterError: false,
}
]
}))
});
gulp 4.0.2 gulp-stylelint 13.0.0 stylelint-scss 3.18
Getting the same error as well. Running stylelint with the CL runs just fine. Using the default gulp-stylelint implementation from the readme. Stylelint config just the default as well.
gulp 4.0.2 gulp-stylelint 13.0.0 stylelint 13.10.0 stylelint-config-standard 20.0.0
Just noticed the same. What's up?
By setting the failAfterError option to false of gulpStylelint got it working fine. Appears that Stylelint considers any violation as an error. Which then causes the task to fail. I don't agree with that as it prevents the linting of files. My setup generates a JSON file which is then rendered as a report in the browser. Even if Stylelint wants to say that a violation is an error, gulp-stylelint should disregard that. Please let me know what I'm missing here. Is there some config option in Stylelint to prevent a file with violations to be considered "errored?"
Nothing to add other than to say I'm also running into the same issue. My setup is the same as @danparm . Setting failAfterError
to false also worked for me.