0

I use gulp 3.9.1 and stylelint 7.6.0 for SCSS linting. OS is Ubuntu.
A related part of my gulp config looks like this:

var postcss = require('gulp-postcss');
var stylelint = require('stylelint');
var postcssReporter = require('postcss-reporter');
gulp.task('styles', function() {
  ...
  var lintProcessors = [
    stylelint(),
    postcssReporter({ clearMessages: true })
  ];

  gulp.src('app/assets_src/styles/**/*.scss')
    .pipe(postcss(lintProcessors, {syntax: scssSyntax}));
  ...
});

The problem:
Stylelint works great for files like app/assets_src/styles/file.scss
but it doesn't process files in subfolders like: app/assets_src/styles/blocks/home/file.scss Also the weird thing is that in some very rare times it fires once for such nested files, but then stops working again.
I've tried to use such paths:
app/assets_src/styles/**/**/*.scss
/app/assets_src/styles/**/*.scss
'./app/assets_src/styles/**/**/*.scss'
But no luck.

Also using this cli command: stylelint 'app/assets_src/styles/**/*.scss' works good and processes subdirectories. So maybe the issue is related to gulp-postcss plugin.

  • Can you use something like [gulp-debug](https://www.npmjs.com/package/gulp-debug/) to confirm which files are being processed by gulp? – tekniskt Nov 29 '16 at 22:47
  • Thanks for the response. gulp-debug shows that every file is being passed to the stylelint. But only some of them are being processed. I made an issue report here: https://github.com/postcss/gulp-postcss/issues/107 Will see how it will be solved. – Alexander Khramov Dec 14 '16 at 21:12

1 Answers1

0

The answer is - you always have to return a stream from a gulp task, this way gulp understands when the task is terminated.

Docs: https://github.com/gulpjs/gulp/blob/master/docs/API.md#async-task-support

Issue discussion thread: https://github.com/postcss/gulp-postcss/issues/107#issuecomment-267168310