Last active
July 29, 2022 13:54
-
-
Save KingScooty/fa4aab7852dd30feb573 to your computer and use it in GitHub Desktop.
Linting Sass stylesheets with Stylelint
This file contains 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
/** | |
* Linting Sass stylesheets with Stylelint | |
* http://www.creativenightly.com/2016/02/How-to-lint-your-css-with-stylelint/ | |
*/ | |
var gulp = require('gulp'); | |
var postcss = require('gulp-postcss'); | |
var reporter = require('postcss-reporter'); | |
var syntax_scss = require('postcss-scss'); | |
var stylelint = require('stylelint'); | |
gulp.task("scss-lint", function() { | |
// Stylelint config rules | |
var stylelintConfig = { | |
"rules": { | |
"block-no-empty": true, | |
"color-no-invalid-hex": true, | |
"declaration-colon-space-after": "always", | |
"declaration-colon-space-before": "never", | |
"function-comma-space-after": "always", | |
"function-url-quotes": "double", | |
"media-feature-colon-space-after": "always", | |
"media-feature-colon-space-before": "never", | |
"media-feature-name-no-vendor-prefix": true, | |
"max-empty-lines": 5, | |
"number-leading-zero": "never", | |
"number-no-trailing-zeros": true, | |
"property-no-vendor-prefix": true, | |
"rule-no-duplicate-properties": true, | |
"declaration-block-no-single-line": true, | |
"rule-trailing-semicolon": "always", | |
"selector-list-comma-space-before": "never", | |
"selector-list-comma-newline-after": "always", | |
"selector-no-id": true, | |
"string-quotes": "double", | |
"value-no-vendor-prefix": true | |
} | |
} | |
var processors = [ | |
stylelint(stylelintConfig), | |
reporter({ | |
clearMessages: true, | |
throwError: true | |
}) | |
]; | |
return gulp.src( | |
['app/assets/css/**/*.scss', | |
// Ignore linting vendor assets | |
// Useful if you have bower components | |
'!app/assets/css/vendor/**/*.scss'] | |
) | |
.pipe(postcss(processors, {syntax: syntax_scss})); | |
}); |
Well spotted. Patched up!
http://www.creativenightly.com/2016/02/How-to-lint-your-css-with-stylelint/ page is unavailable
And function-url-quotes
rule accepts only "always" or "never" options, not "double", see: https://stylelint.io/user-guide/rules/list/function-url-quotes/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 56 should be
.pipe(postcss(processors, {syntax: syntax_scss}));