How to use gulp-eslint

Comprehensive gulp-eslint code examples:

How to use gulp-eslint.failOnError:

189
190
191
192
193
194
195
196
197
198

Type: `function (results, callback) { callback(error); }`

Call an asynchronous function once for all ESLint file results before a stream finishes. The callback must be called for the stream to finish. If a value is passed to the callback, it will be wrapped in a Gulp PluginError and emitted from the stream.

### eslint.failOnError()

Stop a task/stream if an ESLint error has been reported for any file.

```javascript

How to use gulp-eslint.results:

166
167
168
169
170
171
172
173
174
175
Type: `function (result, callback) { callback(error); }`

Call an asynchronous function for each ESLint file result. The callback must be called for the stream to finish. If a value is passed to the callback, it will be wrapped in a Gulp PluginError and emitted from the stream.


### eslint.results(action)

Type: `function (results) {}`

Call a function once for all ESLint file results before a stream finishes. No returned value is expected. If an error is thrown, it will be wrapped in a Gulp PluginError and emitted from the stream.

How to use gulp-eslint.result:

143
144
145
146
147
148
149
150
151
152

Type: `String`

Shorthand for defining `options.configFile`.

### eslint.result(action)

Type: `function (result) {}`

Call a function for each ESLint file result. No returned value is expected. If an error is thrown, it will be wrapped in a Gulp PluginError and emitted from the stream.

How to use gulp-eslint.failAfterError:

200
201
202
203
204
205
206
207
208
209
gulp.src(['**/*.js','!node_modules/**'])
    .pipe(eslint())
    .pipe(eslint.failOnError());
```

### eslint.failAfterError()

Stop a task/stream if an ESLint error has been reported for any file, but wait for all of them to be processed first.

```javascript

How to use gulp-eslint.formatEach:

4
5
6
7
8
9
10
11
12
13
return gulp.src(['src/**/*.js'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
// .pipe(eslint.failOnError());

How to use gulp-eslint.format:

3
4
5
6
7
8
9
10
11
12
gulp.task('lint', module.exports = function () {
  return gulp.src(['src/**/*.js'])
  // eslint() attaches the lint output to the eslint property
  // of the file object so it can be used by other modules.
  .pipe(eslint())
  // eslint.format() outputs the lint results to the console.
  // Alternatively use eslint.formatEach() (see Docs).
  .pipe(eslint.format())
  // To have the process exit with an error code (1) on
  // lint error, return the stream and pipe to failOnError last.