在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sasstools/gulp-sass-lint开源软件地址(OpenSource Url):https://github.com/sasstools/gulp-sass-lint开源编程语言(OpenSource Language):JavaScript 84.9%开源软件介绍(OpenSource Introduction):Gulp Sass LintInstall
Usage
'use strict';
var gulp = require('gulp'),
sassLint = require('gulp-sass-lint');
gulp.task('default', function () {
return gulp.src('sass/**/*.s+(a|c)ss')
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
}); APIsassLint(options)You can pass an object of options to configure gulp-sass-lint to your specific projects needs the options are listed below. options.optionsYou can find out more about the specific SassLint options from the SassLint Documentation {
options: {
formatter: 'stylish',
'merge-default-rules': false
}
} 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.
You can disable this behaviour by setting More info and examples can be found within the SassLint docs options.filesType: Within the files object you can specify a glob pattern as a string or an array of glob pattern for both the {
files: {
include: '**/*.scss', // This will be ignored by gulp-sass-lint
ignore: 'test/**/*.scss' // This will still be respected and read
}
} options.rulesType: 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 {
rules: {
'no-ids': 0, // Severity 0 (disabled)
'no-mergeable-selectors': 1, // Severity 1 (warning)
'hex-length': [
2, // Severity 2 (error)
{
'style': 'long'
}
]
}
} options.configFileYou can pass the path to a custom config file via the {
configFile: 'app/config/.my-config.yml'
} ExampleThe following highlights all of the above options in use 'use strict';
var gulp = require('gulp'),
sassLint = require('gulp-sass-lint');
gulp.task('default', function () {
return gulp.src('sass/**/*.s+(a|c)ss')
.pipe(sassLint({
options: {
formatter: 'stylish',
'merge-default-rules': false
},
files: {ignore: '**/*.scss'},
rules: {
'no-ids': 1,
'no-mergeable-selectors': 0
},
configFile: 'config/other/.sass-lint.yml'
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
}); 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 You can also choose to output to a file from within the options you provide or your config file. See the output-file docs gulp.task('lint_sass_jenkins', function () {
var file = fs.createWriteStream('reports/lint_sass.xml');
var stream = gulp.src('public/sass/**/*.scss')
.pipe(sassLint({
options: {
configFile: '.sass-lint.yml',
formatter: 'checkstyle'
}
}))
.pipe(sassLint.format(file));
stream.on('finish', function() {
file.end();
});
return stream;
}); 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). |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论