在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):juanfran/gulp-scss-lint开源软件地址(OpenSource Url):https://github.com/juanfran/gulp-scss-lint开源编程语言(OpenSource Language):JavaScript 98.7%开源软件介绍(OpenSource Introduction):gulp-scss-lint
Installnpm install gulp-scss-lint --save-dev This plugin requires Ruby and scss-lint gem install scss_lint Usage
var scsslint = require('gulp-scss-lint');
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint());
}); Apiconfig
scsslint({
'config': 'lint.yml'
}); bundleExec
If your gem is installed via bundler, then set this option to scsslint({
'bundleExec': true
}); reporterOutput
If you want to save the report to a file then set reporterOutput with a file name scsslint({
'reporterOutput': 'scssReport.json'
}); reporterOutputFormat
gulp.src(['**/*.scss'])
.pipe(scsslint({
'reporterOutputFormat': 'Checkstyle',
})) filePipeOutput
If you want the pipe return a report file instead of the //xml
gulp.src(['**/*.scss'])
.pipe(scsslint({
'reporterOutputFormat': 'Checkstyle',
'filePipeOutput': 'scssReport.xml'
}))
.pipe(gulp.dest('./reports'))
//json
gulp.src(['**/*.scss'])
.pipe(scsslint({
'filePipeOutput': 'scssReport.json'
}))
.pipe(gulp.dest('./reports')) maxBuffer
Set maxBuffer for the child_process.exec process. If you get a gulp.src(['**/*.scss'])
.pipe(scsslint({
'maxBuffer': 307200
}))
.pipe(gulp.dest('./reports')) endless
If you use gulp-watch set endless to true. sync
verbose
If you want to see the executed scss-lint command for debugging purposes, set this to true. Glob pattern without gulp.srcvar scsslint = require('gulp-scss-lint');
gulp.task('scss-lint', function() {
return scsslint({
shell: 'bash', // your shell must support glob
src: '**/*.scss'
});
}); ExcludingTo exclude files you should use the gulp.src ignore format '!filePath'' gulp.src(['/scss/*.scss', '!/scss/vendor/**/*.scss'])
.pipe(scsslint({'config': 'lint.yml'})); Or you should use gulp-filter var scsslint = require('gulp-scss-lint');
var gulpFilter = require('gulp-filter');
gulp.task('scss-lint', function() {
var scssFilter = gulpFilter('/scss/vendor/**/*.scss');
return gulp.src('/scss/*.scss')
.pipe(scssFilter)
.pipe(scsslint())
.pipe(scssFilter.restore());
}); Lint only modified filesYou should use gulp-cached In this example, without the gulp-cached plugin, every time you save a var scsslint = require('gulp-scss-lint');
var cache = require('gulp-cached');
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(cache('scsslint'))
.pipe(scsslint());
});
gulp.task('watch', function() {
gulp.watch('/scss/*.scss', ['scss-lint']);
}); ResultsAdds the following properties to the file object: file.scsslint = {
'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 reporterYou can replace the default console log by a custom output with var scsslint = require('gulp-scss-lint');
var myCustomReporter = function(file) {
if (!file.scsslint.success) {
gutil.log(file.scsslint.issues.length + ' issues found in ' + file.path);
}
};
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint({
customReport: myCustomReporter
}))
}); You can even throw an exception var scsslint = require('gulp-scss-lint');
var myCustomReporter = function(file, stream) {
if (!file.scsslint.success) {
stream.emit('error', new gutil.PluginError("scss-lint", "some error"));
}
};
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint({
customReport: myCustomReporter
}))
}); Default reporterThis 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 reporterIf you want the task to fail when "scss-lint" was not a success then call This example will log the issues as usual and then fails if there is any issue. var scsslint = require('gulp-scss-lint');
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint())
.pipe(scsslint.failReporter())
}); if you just want var scsslint = require('gulp-scss-lint');
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint())
.pipe(scsslint.failReporter('E'))
}); TestingTo test you must first have |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论