gulp-eslint-threshold
Version:
A simple gulp stream plugin for counting warnings and/or errors from gulp-eslint and call a callback function when the number rises above a threshold you set.
26 lines (20 loc) • 997 B
JavaScript
;
var gulp = require('gulp'),
eslint = require('gulp-eslint'),
eslintThreshold = require('./');
gulp.task('test', function() {
gulp.src(['**/*.js', '!node_modules/**', '!coverage/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslintThreshold.afterWarnings(1, function(numberOfWarnings) {
console.log('ESLint warnings (' + numberOfWarnings + ') equal to or greater than the threshold');
//throw new Error('ESLint warnings (' + numberOfWarnings + ') equal to or greater than the threshold (' + thresholdWarnings + ')');
}));
gulp.src(['**/*.js', '!node_modules/**', '!coverage/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslintThreshold.afterErrors(1, function(numberOfErrors) {
console.log('ESLint errors (' + numberOfErrors + ') equal to or greater than the threshold');
//throw new Error('ESLint warnings (' + numberOfWarnings + ') equal to or greater than the threshold (' + thresholdWarnings + ')');
}));
});