1 | var gulp = require('gulp'),
|
2 | eslint = require('gulp-eslint');
|
3 |
|
4 | gulp.task('lint', function () {
|
5 | // ESLint ignores files with "node_modules" paths.
|
6 | // So, it's best to have gulp ignore the directory as well.
|
7 | // Also, Be sure to return the stream from the task;
|
8 | // Otherwise, the task may end before the stream has finished.
|
9 | return gulp.src(['**/*.js','!node_modules/**'])
|
10 | // eslint() attaches the lint output to the "eslint" property
|
11 | // of the file object so it can be used by other modules.
|
12 | .pipe(eslint())
|
13 | // eslint.format() outputs the lint results to the console.
|
14 | // Alternatively use eslint.formatEach() (see Docs).
|
15 | .pipe(eslint.format())
|
16 | // To have the process exit with an error code (1) on
|
17 | // lint error, return the stream and pipe to failAfterError last.
|
18 | .pipe(eslint.failAfterError());
|
19 | });
|
20 |
|
21 | gulp.task('default', ['lint'], function () {
|
22 | // This will only run if the lint task is successful...
|
23 | });
|