Last active
November 19, 2015 14:57
-
-
Save VitaliyR/68c1a0267dc84140eb2b to your computer and use it in GitHub Desktop.
Grunt PostCSS Stylelint SCSS linter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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