forked from bemusic/bemuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.js
34 lines (30 loc) · 887 Bytes
/
lint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gulp from 'gulp'
import gutil from 'gulp-util'
import { javascripts } from '../config/sources'
import eslint from 'gulp-eslint'
import eslintUtil from 'gulp-eslint/util'
import through2 from 'through2'
gulp.task('lint', function () {
return gulp.src(javascripts)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslintFailOnError())
})
function eslintFailOnError () {
let error = false
return through2.obj(function (file, enc, callback) {
if (file.eslint && file.eslint.messages &&
file.eslint.messages.some(eslintUtil.isErrorMessage)) {
error = new gutil.PluginError('tasks/lint', {
name: 'ESLintError',
message: 'ESLint Complained!!'})
}
callback(null, file)
}, function (callback) {
if (error) {
callback(error)
} else {
callback()
}
})
}