diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000000..567b945f2c --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,8 @@ +{ + "plugins": [ + "stylelint-order", + "stylelint-scss" + ], + "rules": { + }, +} diff --git a/RoboFile.php b/RoboFile.php index 70a6099d61..26aa37f9ea 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -59,8 +59,14 @@ class RoboFile extends \Robo\Tasks { function watchCss() { $css_files = $this->rsearch('assets/css/src/', array('scss')); $this->taskWatch() - ->monitor($css_files, function() { - $this->compileCss(); + ->monitor($css_files, function($changedFile) { + $file = $changedFile->getResource()->getResource(); + $this->taskExecStack() + ->stopOnFail() + ->exec('npm run stylelint -- "' . $file . '"') + ->exec('npm run scss') + ->exec('npm run autoprefixer') + ->run(); }) ->run(); } @@ -313,6 +319,7 @@ class RoboFile extends \Robo\Tasks { return $this->qaCodeSniffer('all'); }); $collection->addCode(array($this, 'qaLintJavascript')); + $collection->addCode(array($this, 'qaLintCss')); return $collection->run(); } @@ -324,6 +331,10 @@ class RoboFile extends \Robo\Tasks { return $this->_exec('npm run lint'); } + function qaLintCss() { + return $this->_exec('npm run stylelint -- "assets/css/src/components/**/*.scss"'); + } + function qaCodeSniffer($severity='errors') { if ($severity === 'all') { $severityFlag = '-w'; diff --git a/package.json b/package.json index 5fb5f79ca7..8f7997a095 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "lint5": "eslint -c .eslintrc.es5.json --ignore-pattern helpscout.js --max-warnings 0 'assets/js/src/**/*.js'", "lint-tests": "eslint -c .eslintrc.tests.json --max-warnings 0 'tests/javascript'", "autoprefixer": "postcss assets/dist/css/*.css --use autoprefixer --no-map --replace", - "scss": "node-sass assets/css/src/ --output assets/dist/css/ --output-style compact" + "scss": "node-sass assets/css/src/ --output assets/dist/css/ --output-style compact", + "stylelint": "stylelint --fix" }, "dependencies": { "@babel/runtime": "^7.2.0",