adametry / gulp-eslint

A Gulp plugin for identifying and reporting on patterns found in ECMAScript/JavaScript code.
MIT License
563 stars 118 forks source link

Local .eslintrc.json ignored in 6.0.0 #240

Closed vitaly-t closed 3 years ago

vitaly-t commented 5 years ago

Here's my test project, simply clone it and install dependencies.

Running npm test or npm run lint works fine. Now go to the package, upgrade gulp-eslint dependency to 6.0.0, and nothing works anymore, producing tons of linting errors. It looks like from version 6.0.0 the local .eslintrc.json files are ignored.

Any idea how to fix it and/or change the project to make it work with version 6.0.0?

yutasa commented 4 years ago

same with .eslintrc.yml

cashpipeplusplus commented 3 years ago

Same with .eslintrc.js

How exactly is the config file loaded in gulp-eslint? Running eslint directly, it definitely finds the config file.

cashpipeplusplus commented 3 years ago

At least in my case, I figured out that it was indeed reading the config file, but not reporting any of the errors.

This didn't work:

const eslint = require('gulp-eslint');

function lint() {
  return gulp.src([
    '*.js',
    'src/**/*.js',
    'extension/*.js',
  ])
  .pipe(eslint());
}

This almost works:

const eslint = require('gulp-eslint');

function lint() {
  return gulp.src([
    '*.js',
    'src/**/*.js',
    'extension/*.js',
  ])
  .pipe(eslint())
  .pipe(eslint.format());   // <--- added
}

It reports the errors now, but it doesn't fail the task when there are errors. When the errors were not being reported, it seemed like it wan't loading the config file.

cashpipeplusplus commented 3 years ago

And holy crap, here it is:

const eslint = require('gulp-eslint');

function lint() {
  return gulp.src([
    '*.js',
    'src/**/*.js',
    'extension/*.js',
  ])
  .pipe(eslint())

  // Add these:
  .pipe(eslint.format())
  .pipe(eslint.failAfterError());
}

This is all in the README, and I'm super embarrassed that I was too impatient to read it.

vitaly-t commented 3 years ago

Adding this makes it work:

 .pipe(eslint.format())
  .pipe(eslint.failAfterError());