Installations
npm install pos-gulp-sass-lint
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.4.6
NPM Version
3.10.2
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (84.86%)
CSS (15.14%)
Developer
sasstools
Download Statistics
Total Downloads
831
Last Day
1
Last Week
2
Last Month
9
Last Year
63
GitHub Statistics
115 Stars
70 Commits
43 Forks
11 Watching
2 Branches
16 Contributors
Bundle Size
631.52 kB
Minified
159.85 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.3.2
Package Id
pos-gulp-sass-lint@1.3.2
Size
5.39 kB
NPM Version
3.10.2
Node Version
4.4.6
Total Downloads
Cumulative downloads
Total Downloads
831
Last day
0%
1
Compared to previous day
Last week
-50%
2
Compared to previous week
Last month
80%
9
Compared to previous month
Last year
-23.2%
63
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Gulp Sass Lint
Install
npm install gulp-sass-lint --save-dev
Usage
gulpfile.js
1'use strict'; 2 3var gulp = require('gulp'), 4 sassLint = require('gulp-sass-lint'); 5 6gulp.task('default', function () { 7 return gulp.src('sass/**/*.s+(a|c)ss') 8 .pipe(sassLint()) 9 .pipe(sassLint.format()) 10 .pipe(sassLint.failOnError()) 11});
API
sassLint(options)
You can pass an object of options to configure gulp-sass-lint to your specific projects needs the options are listed below.
options.options
You can find out more about the specific SassLint options from the SassLint Documentation
1{ 2 options: { 3 formatter: 'stylish', 4 'merge-default-rules': false 5 } 6}
By default SassLint includes it's own configuration file, if you provide one it attempts to merge everything except for the files section below. If you pass options directly into the plugin they take precedence. The order can be visualised below with the SassLint config being the base.
options > config file > SassLint default included config
You can disable this behaviour by setting merge-default-rules
to false within the options.options
object that you pass to gulp-sass-lint
or you can include it in your config file options that you can pass into gulp-sass-lint
with options.configFile
.
More info and examples can be found within the SassLint docs
options.files
Type: Object
Within the files object you can specify a glob pattern as a string or an array of glob pattern for both the include
and ignore
options. Please note that your include option will currently be ignored as you should be passing the glob patterns / file paths to be linted directly to gulp gulp.src('sass/**/*.s+(a|c)ss')
. The ignore option however will still be respected if you'd rather specify them in your config rather than in the gulp.src
method.
1{ 2 files: { 3 include: '**/*.scss', // This will be ignored by gulp-sass-lint 4 ignore: 'test/**/*.scss' // This will still be respected and read 5 } 6}
options.rules
Type: Object
You can define which rules you would like to use here and set a severity too. For more information see how to configure and also the SassLint rules
1{ 2 rules: { 3 'no-ids': 0, // Severity 0 (disabled) 4 'no-mergeable-selectors': 1, // Severity 1 (warning) 5 'hex-length': [ 6 2, // Severity 2 (error) 7 { 8 'style': 'long' 9 } 10 ] 11 } 12}
options.configFile
You can pass the path to a custom config file via the configFile
option. The path will be relative to where you're running gulp from.
1{ 2 configFile: 'app/config/.my-config.yml' 3}
option.updateRules
You can pass a function that can process all existing rules (user defined ones
as well as the defaults that come from sass-lint
).
1 // ... 2 .pipe(sassLint({ 3 configFile: '.sass-lint.yml', 4 // all enabled rules will have the error severity 5 updateRules: (rules) => { 6 const isActiveRule = (x) => (typeof x === 'number' && x !== 0); 7 8 Object.keys(rules).forEach(r => { 9 if (isActiveRule(rules[r])) { 10 rules[r] = 2; 11 } else if (Array.isArray(rules[r])) { 12 if (isActiveRule(rules[r][0])) { 13 rules[r][0] = 2; 14 } 15 } 16 }); 17 18 return rules; 19 } 20 }))
Example
The following highlights all of the above options in use
1 2'use strict'; 3 4var gulp = require('gulp'), 5 sassLint = require('gulp-sass-lint'); 6 7gulp.task('default', function () { 8 return gulp.src('sass/**/*.s+(a|c)ss') 9 .pipe(sassLint({ 10 options: { 11 formatter: 'stylish', 12 'merge-default-rules': false 13 }, 14 files: {ignore: '**/*.scss'}, 15 rules: { 16 'no-ids': 1, 17 'no-mergeable-selectors': 0 18 }, 19 configFile: 'config/other/.sass-lint.yml' 20 })) 21 .pipe(sassLint.format()) 22 .pipe(sassLint.failOnError()) 23}); 24
sassLint.format(writable)
Formats the results dependent on your config file or the options you provided to the sassLint task above. The default format is stylish
but you can choose any of the others that SassLint provides, see the docs.
You can also choose to output to a file from within the options you provide or your config file. See the output-file docs
1gulp.task('lint_sass_jenkins', function () { 2 var file = fs.createWriteStream('reports/lint_sass.xml'); 3 var stream = gulp.src('public/sass/**/*.scss') 4 .pipe(sassLint({ 5 options: { 6 configFile: '.sass-lint.yml', 7 formatter: 'checkstyle' 8 } 9 })) 10 .pipe(sassLint.format(file)); 11 stream.on('finish', function() { 12 file.end(); 13 }); 14 return stream; 15});
sassLint.failOnError()
Fails the task and emits a gulp error when all files have been linted if an error has been detected (rules set to severity 2).
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 7/17 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More