How to use the format function from gulp-eslint

Find comprehensive JavaScript gulp-eslint.format code examples handpicked from public code repositorys.

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.
fork icon763
star icon0
watch icon2

211
212
213
214
215
216
217
218
219
220
gulp.src(['**/*.js','!node_modules/**'])
    .pipe(eslint())
    .pipe(eslint.failAfterError());
```

### eslint.format(formatter, output)

Format all linted files once. This should be used in the stream after piping through `eslint`; otherwise, this will find no ESLint results to format.

The `formatter` argument may be a `String`, `Function`, or `undefined`. As a `String`, a formatter module by that name or path will be resolved as a module, relative to `process.cwd()`, or as one of the [ESLint-provided formatters](https://github.com/eslint/eslint/tree/master/lib/formatters). If `undefined`, the ESLint “stylish” formatter will be resolved. A `Function` will be called with an `Array` of file linting results to format.
fork icon122
star icon562
watch icon10

+ 7 other calls in file

22
23
24
25
26
27
28
29
30
31
return combiner(
  src,
  print(),
  filenameHint({ regExp: /(^|\/)[a-z0-9.-]+\.js$/ }),
  eslint(),
  eslint.format(),
  eslint.failAfterError(),
  checkGrep(/console\.log(.(?!noqa$))+$/gm, { message: 'console.log' }),
  checkGrep(/debugger$(.(?!noqa$))+$/gm, { message: 'debugger' }),
  checkGrep.failOnError(),
fork icon3
star icon14
watch icon10

+ 3 other calls in file

48
49
50
51
52
53
54
55
56
57
// Will process JS files
function jsStart() {
  return src(helpers.trim(`${helpers.source()}/${global.config.js.src}/*.js`))
    .pipe(gulpif(global.config.js.sourcemaps, sourcemaps.init()))
    .pipe(gulpif(global.config.js.lint, eslint(thisEslintConfig)))
    .pipe(gulpif(global.config.js.lint, eslint.format()))
    .pipe(gulpif(global.config.js.lint, eslint.failAfterError()))
    .pipe(gulpif(global.config.js.lint, eslint.result((result) => {
      console.log(`[JS] ESLint complete: ${result.filePath}`);
      console.log(`[JS] Messages: ${result.messages.length}`);
fork icon3
star icon17
watch icon3

3
4
5
6
7
8
9

module.exports = function( src ) {
  return gulp.src( src )
    .pipe(plumber())
    .pipe(eslint()) // eslint() attaches the lint output to the "eslint" property of the file object so it can be used by other modules.
    .pipe(eslint.format()) // eslint.format() outputs the lint results to the console. Alternatively use eslint.formatEach() (see Docs).
}
fork icon0
star icon8
watch icon5