Skip to content

Commit

Permalink
Merge pull request #30 from Arjen-Smit/advanced-linting-options
Browse files Browse the repository at this point in the history
Add advanced linting settings to the sass task, like disabling or using custom configs
  • Loading branch information
ahoek committed Mar 16, 2016
2 parents 3ed49e1 + 3e1e05e commit 128d2e3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,43 @@ if set to true all outputed files are optimized for production when running `gul
all the settings for other tasks like sass, javascript & icons are defined below.


## Sass task
Add the following to the config.json

```json
"sass": {
"src": [
"style/**/*.scss"
],
"dest": "../../web/assets/css",
"watch": [
"style/**/*.scss"
],
"includePaths": [
"node_modules/compass-mixins/lib",
"node_modules/connectholland-sass-mixins/",
"node_modules/node.normalize.scss"
],
"autoprefix": [
"last 2 versions",
"IE >= 8"
]
}
```

###scss-lint
To disable linting or to use a custom config file, you can add a linting object

```json
"sass": {
"linting": {
"enabled": false,
"configfile": ".scss-lint.yml"
}
}
```


## Javascript task

To use the EcmaScript 2015 (ES6) transpiling, add the following dependencies:
Expand Down
22 changes: 19 additions & 3 deletions tasks/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@ module.exports = function(gulp, config) {

var shelljs = require('shelljs');
var util = require('gulp-util');
if (shelljs.which('scss-lint') !== null) {
// Check if linting is available and not disabled
if (shelljs.which('scss-lint') !== null && config.sass.linting.enabled !== false) {
var scssLint = require('gulp-scss-lint');

// Find the correct config file for the linter
var configfile = __dirname + '/sass/.scss-lint.yml';
if (shelljs.test('-f', config.sass.linting.configfile)) {
configfile = config.sass.linting.configfile;
} else if (shelljs.test('-f', '.scss-lint.yml')) {
configfile = '.scss-lint.yml';
}

util.log(util.colors.green("SCSS linting is enabled:"),"using:", util.colors.bold(configfile));

} else {
var scssLint = util.noop;
util.log(util.colors.red("SCSS linting is disabled"),"to enable this feature please install scss_lint '", util.colors.green("gem install scss_lint"), "'");
if (config.sass.linting.enabled === false) {
util.log(util.colors.red("SCSS linting is disabled"),"this feature is disabled in the config.json");
} else {
util.log(util.colors.red("SCSS linting is disabled"),"to enable this feature please install scss_lint '", util.colors.green("gem install scss_lint"), "'");
}
}

return function() {
Expand All @@ -33,7 +49,7 @@ module.exports = function(gulp, config) {
}))
.pipe(
scssLint({
'config': __dirname + '/sass/.scss-lint.yml'
'config': configfile
})
)
.pipe(sourcemaps.init())
Expand Down

0 comments on commit 128d2e3

Please sign in to comment.