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

Convert options.rulePaths from string to array to prevent eslint exception #225

Closed serbanghita closed 6 years ago

serbanghita commented 6 years ago

How to reproduce

Create a gulpfile.js:

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

gulp.task("lint", () => {
  return gulp.src(["tests/spec/**/*.js"])
    .pipe(eslint({
      rulePaths: "rules"
    }))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task("watch", ["lint"], () => {
  gulp.watch("rules/*.js", ["lint"]);
});

Will result in

TypeError: this.options.rulePaths.forEach is not a function
    at new CLIEngine (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/eslint/lib/cli-engine.js:407:36)
    at gulpEslint (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/gulp-eslint/index.js:16:17)
    at Gulp.gulp.task (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/gulpfile.js:6:11)
    at module.exports (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/orchestrator/index.js:134:8)
    at /Users/sghita/webserver/www/personal/eslint-plugin-jquery-upgrade/node_modules/gulp/bin/gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Why?

It's better to auto-convert and don't bug the user about this. Most of the eslint plugin projects have the rules in one folder.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.009%) to 99.32% when pulling 7315fbd4a056e509e42560fee8c053552e7c4e92 on serbanghita:rulesPath-fix into a58a58d95d004271f06c4df31138b859fe73b619 on adametry:master.

serbanghita commented 6 years ago

I think the node version should be bumped on Travis https://github.com/adametry/gulp-eslint/blob/master/.travis.yml#L4 because of the ES6 support https://travis-ci.org/adametry/gulp-eslint/jobs/370455727

shinnn commented 6 years ago

Though I don't know whether the ESLint maintainers will accept your proposal, personally,

It's better to auto-convert and don't bug the user about this.

I don't think so.