olegskl / gulp-stylelint

Gulp plugin for running Stylelint results through various reporters.
MIT License
151 stars 29 forks source link

autofix isn't working #106

Closed MatTeague closed 5 years ago

MatTeague commented 5 years ago

Hi, I can't get gulp-stylelint to autofix my scss files. When I run the CLI it fixes all issues. However, when I run gulp-stylelint I get:

mat@Mats-MacBook-Pro kube (development) $ gulp scsslinting
[15:26:36] Failed to load external module @babel/register
[15:26:36] Requiring external module babel-register
[15:26:39] Using gulpfile ~/Sites/mamp/steelvintage/wp-content/themes/kube/gulpfile.babel.js
[15:26:39] Starting 'scsslinting'...
[15:26:39] Finished 'scsslinting' after 433 ms

With the errors still there.

My Gulp task is:

export const scsslinting = () => {
    return src('.src/scss/**/*.scss')
        .pipe($.plumber())
        .pipe($.changed('./src/scss'))
        .pipe($.stylelint({
            fix: true,
            reporters: [{
                formatter: 'string',
                console: true,
            }],
            failAfterError: false,
        }))
        .pipe(dest('./src/scss'));
};

I've also tried seperating them into function and task like so:

function lintCssTask() {
    return src([
            '.src/scss/**/*.scss'
        ])
        .pipe($.stylelint({
            fix: true,
            reporters: [{
                formatter: 'string',
                console: true,
            }],
            failAfterError: false,
        }))
        .pipe(dest('./src/scss'));
}

export const scsslinting = done => {
    lintCssTask();
    done();
};

But I still get the same 😭 . I'm running gulp v4 and gulp-stylelint ^8.0.0. The stylelint I have install is 9.10.1. I just can't seem to figure out why it's not running correctly when the CLI does.

Thanks for the great plugin and any help would be really appreciated.

MatTeague commented 5 years ago

Ah, think I solved it. I was to do with gulp.changed. Not sure why the second example didn't work though.