From 0019f6d5a53d4db79bc231a10ff7bfdd2fd108ba Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Tue, 29 Nov 2016 08:39:15 -0800 Subject: [PATCH] build: Introduce stylelint and make pass Change-Id: I48d542580d767df2d17ce4c6668e9e233a0f7904 --- .stylelintrc | 7 +++++++ Gruntfile.js | 11 +++++++++-- package.json | 4 +++- responsive.less | 2 +- screen-hd.less | 2 +- screen.less | 11 +++++------ skinStyles/mediawiki.notification.less | 12 ++++++------ .../mediawiki.special.preferences.styles.less | 14 +++++++------- variables.less | 2 +- 9 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 .stylelintrc diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 000000000..449f45bd6 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,7 @@ +{ + "extends": "stylelint-config-wikimedia", + "rules": { + "selector-no-id": null, + "no-descending-specificity": null + } +} diff --git a/Gruntfile.js b/Gruntfile.js index 94cb4bfc6..fe329c62c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,6 +4,7 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.initConfig( { eslint: { @@ -20,9 +21,15 @@ module.exports = function ( grunt ) { '!node_modules/**' ] }, - banana: conf.MessagesDirs + banana: conf.MessagesDirs, + stylelint: { + all: [ + '*.{le,c}ss', + 'skinStyles/*.{le,c}ss' + ] + } } ); - grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] ); + grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana', 'stylelint' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/package.json b/package.json index 2ee773369..6218adf3e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "grunt-eslint": "19.0.0", "eslint-config-wikimedia": "0.3.0", "grunt-banana-checker": "0.5.0", - "grunt-jsonlint": "1.0.7" + "grunt-jsonlint": "1.0.7", + "grunt-stylelint": "0.6.0", + "stylelint-config-wikimedia": "0.3.0" } } diff --git a/responsive.less b/responsive.less index ac483d3c7..700bdc102 100644 --- a/responsive.less +++ b/responsive.less @@ -5,7 +5,7 @@ */ div#mw-head { - position: static !important; + position: static !important; /* stylelint-disable-line declaration-no-important */ margin-top: 0.5em; } diff --git a/screen-hd.less b/screen-hd.less index 7c1d48b3b..96c96cce8 100644 --- a/screen-hd.less +++ b/screen-hd.less @@ -1,6 +1,6 @@ /* Vector screen styles for high definition displays */ -@import "variables.less"; +@import 'variables.less'; .mw-body { margin-left: 11em; diff --git a/screen.less b/screen.less index 353f35fc6..4a5e3b87e 100644 --- a/screen.less +++ b/screen.less @@ -1,8 +1,7 @@ /* Vector screen styles */ -@import "variables.less"; - -@import "components/common.less"; -@import "components/navigation.less"; -@import "components/footer.less"; -@import "components/externalLinks.less"; +@import 'variables.less'; +@import 'components/common.less'; +@import 'components/navigation.less'; +@import 'components/footer.less'; +@import 'components/externalLinks.less'; diff --git a/skinStyles/mediawiki.notification.less b/skinStyles/mediawiki.notification.less index 783d1898a..239bd92f8 100644 --- a/skinStyles/mediawiki.notification.less +++ b/skinStyles/mediawiki.notification.less @@ -1,4 +1,4 @@ -@import "../variables"; +@import '../variables'; /* mediawiki.notification */ @@ -15,20 +15,20 @@ body { .mw-notification { background-color: #fff; - background-color: rgba(255, 255, 255, 0.93); + background-color: rgba( 255, 255, 255, 0.93 ); padding: 0.75em 1.5em; border: solid 1px @content-border-color; border-radius: 0.75em; - box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.125); + box-shadow: 0 2px 10px 0 rgba( 0, 0, 0, 0.125 ); } .mw-notification-type-warn { border-color: #f5be00; /* yellow */ - box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.125), 0 0 0.75em rgba(245, 190, 0, 0.25) inset; + box-shadow: 0 2px 10px 0 rgba( 0, 0, 0, 0.125 ), 0 0 0.75em rgba( 245, 190, 0, 0.25 ) inset; } .mw-notification-type-error { - border-color: red; - box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.125), 0 0 0.75em rgba(255, 0, 0, 0.25) inset; + border-color: #f00; /* red */ + box-shadow: 0 2px 10px 0 rgba( 0, 0, 0, 0.125 ), 0 0 0.75em rgba( 255, 0, 0, 0.25 ) inset; } } diff --git a/skinStyles/mediawiki.special.preferences.styles.less b/skinStyles/mediawiki.special.preferences.styles.less index 988b85841..78b5cd0e0 100644 --- a/skinStyles/mediawiki.special.preferences.styles.less +++ b/skinStyles/mediawiki.special.preferences.styles.less @@ -1,5 +1,5 @@ -@import "mediawiki.mixins"; -@import "../variables"; +@import 'mediawiki.mixins'; +@import '../variables'; /** * The following code is highly modified from monobook. It would be nice if the @@ -73,16 +73,16 @@ background-color: #fafafa; fieldset { - border: none; + border: 0; border-top: solid 1px #ccc; } - >fieldset { - border: none; + > fieldset { + border: 0; padding: 0; margin: 1em; - >legend { + > legend { display: none; } } @@ -107,6 +107,6 @@ .htmlform-tip { font-size: x-small; - padding: .2em 2em; + padding: 0.2em 2em; color: #666; } diff --git a/variables.less b/variables.less index c703e22f0..d6a7e02f6 100644 --- a/variables.less +++ b/variables.less @@ -10,7 +10,7 @@ @content-line-height: 1.6; @content-padding: 1em; @content-heading-font-size: 1.8em; -@content-heading-font-family: "Linux Libertine", Georgia, Times, serif; +@content-heading-font-family: 'Linux Libertine', Georgia, Times, serif; @content-heading-font-family-generic: sans-serif; @body-background-color: #fff; @heading-line-height: 1.3;