gulp-scss-lint
Lint your
.scss
files
Install
npm install gulp-scss-lint --save-dev
This plugin requires Ruby and scss-lint
gem install scss_lint
Usage
gulpfile.js
var scsslint = ; gulp;
Api
config
- Type:
String
- Default: default scss-lint config file.
;
bundleExec
- Type:
Boolean
- Default:
false
If your gem is installed via bundler, then set this option to true
;
reporterOutput
- Type:
String
- Default:
null
If you want to save the report to a file then set reporterOutput with a file name
;
reporterOutputFormat
- Type:
String
- Default:
JSON
- Values:
JSON
orCheckstyle
gulp
filePipeOutput
- Type:
String
- Default:
null
If you want the pipe return a report file instead of the .scss
file then set filePipeOutput with a filename
//xmlgulp //jsongulp
maxBuffer
- Type: Number or Boolean
- Default: 300 * 1024
Set maxBuffer for the child_process.exec process. If you get a maxBuffer exceeded
error, set it with a higher number. maxBuffer specifies the largest amount of data allowed on stdout or stderr.
gulp
endless
- Type: Boolean
- Default: false
If you use gulp-watch set endless to true.
sync
- Type: Boolean
- Default: sync
scss-lint
will be executed in sequence.
verbose
- Type: Boolean
- Default: false
If you want to see the executed scss-lint command for debugging purposes, set this to true.
Glob pattern without gulp.src
var scsslint = ; gulp;
Excluding
To exclude files you should use the gulp.src ignore format '!filePath''
gulp ;
Or you should use gulp-filter
var scsslint = ;var gulpFilter = ; gulp;
Lint only modified files
You should use gulp-cached
In this example, without the gulp-cached plugin, every time you save a .scss
file the scss-lint plugin will check all your files. In case you have gulp-cached plugin, it will only check the modified files.
var scsslint = ;var cache = ; gulp; gulp;
Results
Adds the following properties to the file object:
filescsslint = 'success': false 'errors': 0 'warnings': 1 'issues': 'line': 123 'column': 10 'severity': 'warning' // or `error` 'reason': 'a description of the error' ;
The issues have the same parameters that scss-lint
Custom reporter
You can replace the default console log by a custom output with customReport
. customReport function will be called for each file that includes the lint results See result params
var scsslint = ; var { if !filescsslintsuccess gutil; }; gulp;
You can even throw an exception
var scsslint = ; var { if !filescsslintsuccess stream; }; gulp;
Default reporter
This is an example from the default reporter output
[20:55:10] 3 issues found in test/fixtures/invalid.scss[20:55:10] test/fixtures/invalid.scss:1 [W] IdSelector: Avoid using id selectors[20:55:10] test/fixtures/invalid.scss:2 [W] Indentation: Line should be indented 2 spaces, but was indented 0 spaces[20:55:10] test/fixtures/invalid.scss:2 [W] EmptyRule: Empty rule
Fail reporter
If you want the task to fail when "scss-lint" was not a success then call failReporter
after the scsslint call.
This example will log the issues as usual and then fails if there is any issue.
var scsslint = ; gulp;
if you just want failReporter
to fail just with errors pass the 'E' string
var scsslint = ; gulp;
Testing
To test you must first have scss-lint
installed globally using
gem install scss_lint
as well as via bundler using bundle install
.