Skip to content

Instantly share code, notes, and snippets.

@VitaliyR
Last active November 19, 2015 14:57
Show Gist options
  • Save VitaliyR/68c1a0267dc84140eb2b to your computer and use it in GitHub Desktop.
Save VitaliyR/68c1a0267dc84140eb2b to your computer and use it in GitHub Desktop.
Grunt PostCSS Stylelint SCSS linter
var stylelint = require('stylelint');
var scss = require('postcss-scss');
var scssGraph = require('sass-graph');
var lintOptions = {
processors: [
stylelint()
],
syntax: scss,
map: false,
loadPaths: 'src'
};
var getDependentStyles = function (src, opts) {
src = Array.isArray(src) ? src : [src];
var files = [];
src.forEach(function (scssGlob) {
var scssFiles = grunt.file.expand(scssGlob);
scssFiles.forEach(function (scssFile) {
var graph = scssGraph.parseFile(scssFile, {
loadPaths: opts.loadPaths,
extensions: ['scss']
});
for (var path in graph.index) {
files.push(path);
}
}, this);
}, this);
return files;
};
module.exports = {
lint: {
options: lintOptions,
src: getDependentStyles('src/applications/app.scss', lintOptions)
}
};
// grunt task:lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment