From 1f49528feafc109d3667e540e5b2246a31dfc30d Mon Sep 17 00:00:00 2001 From: "Jonathan (JB) Belcher" Date: Mon, 8 Aug 2016 15:32:39 -0400 Subject: [PATCH] Add stylelint to repository --- .stylelintrc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Gruntfile.js | 11 ++++++++++ package.json | 1 + 3 files changed, 71 insertions(+) create mode 100644 .stylelintrc diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 00000000000..1c2ab319d43 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,59 @@ +{ + "rules": { + "color-hex-case": "lower", + "color-no-invalid-hex": true, + + "function-calc-no-unspaced-operator": true, + "function-comma-space-after": "always-single-line", + "function-comma-space-before": "never", + "function-name-case": "lower", + "function-url-quotes": "always", + "function-whitespace-after": "always", + + "number-leading-zero": "always", + "number-no-trailing-zeros": true, + "length-zero-no-unit": true, + + "string-no-newline": true, + "string-quotes": "single", + + "unit-case": "lower", + "unit-no-unknown": true, + "unit-whitelist": ["px", "%", "deg", "ms", "em", "vh", "vw", "rem"], + + "value-list-comma-space-after": "always-single-line", + "value-list-comma-space-before": "never", + + "shorthand-property-no-redundant-values": true, + + "property-case": "lower", + + "declaration-block-no-duplicate-properties": true, + "declaration-block-no-ignored-properties": true, + "declaration-block-trailing-semicolon": "always", + "declaration-block-single-line-max-declarations": 0, + "declaration-block-semicolon-space-before": "never", + "declaration-block-semicolon-space-after": "always-single-line", + "declaration-block-semicolon-newline-before": "never-multi-line", + "declaration-block-semicolon-newline-after": "always-multi-line", + + "block-closing-brace-newline-after": "always", + "block-closing-brace-newline-before": "always-multi-line", + "block-no-empty": true, + "block-opening-brace-newline-after": "always-multi-line", + "block-opening-brace-space-before": "always", + + "selector-attribute-brackets-space-inside": "never", + "selector-attribute-operator-space-after": "never", + "selector-attribute-operator-space-before": "never", + "selector-combinator-space-after": "always", + "selector-combinator-space-before": "always", + "selector-pseudo-class-case": "lower", + "selector-pseudo-class-parentheses-space-inside": "always", + "selector-pseudo-element-case": "lower", + "selector-pseudo-element-colon-notation": "double", + "selector-pseudo-element-no-unknown": true, + "selector-type-case": "lower", + "selector-no-id": true + } +} diff --git a/Gruntfile.js b/Gruntfile.js index fdab183b168..2f42544a999 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -28,6 +28,16 @@ module.exports = function( grunt ) { ] }, + // Sass linting with Stylelint. + stylelint: { + options: { + stylelintrc: '.stylelintrc' + }, + all: [ + '<%= dirs.css %>/*.scss', + ] + }, + // Minify .js files. uglify: { options: { @@ -228,6 +238,7 @@ module.exports = function( grunt ) { grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-contrib-clean' ); + grunt.loadNpmTasks( 'grunt-stylelint' ); // Register tasks grunt.registerTask( 'default', [ diff --git a/package.json b/package.json index 4d93312a8a5..f9fc9e63858 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "grunt-contrib-uglify": "~1.0.0", "grunt-contrib-watch": "~1.0.0", "grunt-shell": "~1.3.0", + "grunt-stylelint": "^0.6.0", "grunt-wp-i18n": "~0.5.4", "node-bourbon": "~4.2.3" },