adametry / gulp-eslint

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

gulp-eslint errors out on it's own arrow function #175

Closed mistercoffee66 closed 8 years ago

mistercoffee66 commented 8 years ago

Using latest gulp-eslint with gulp 4.0. On a couple of OSX machines, no problems. On another with identical setup and same package.json, getting the following:

/node_modules/gulp-eslint/index.js:32
return util.transform((file, enc, cb) => {
                                      ^^
SyntaxError: Unexpected token =>
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:427:25)
    at Object.Module._extensions..js (module.js:462:10)
    at Module.load (module.js:339:32)
    at Function.Module._load (module.js:294:12)
    at Module.require (module.js:349:17)
    at require (module.js:368:17)
    at requireFn 

Looking at mismatch version of gulp-cli, but that doesn't seem to be the case. Any thoughts? Thanks!

shinnn commented 8 years ago

http://www.catb.org/esr/faqs/smart-questions.html#forum

mistercoffee66 commented 8 years ago

@shinnn Could you elaborate? There's an ES6 arrow function on line 32 of gulp-eslint/index.js:32. Why would one instance compile fine and another not? There's no Babel or other transpiler in the project. According to http://node.green/ arrow funcs are supported near 100% in Node going back to 4.4.6. One of the machines not throwing an err has 4.2.2, lower than the machine throwing the error.

I must be missing something, since you closed it w/o reply, but I'm not sure what. Any guidance would be appreciated.

package.json

{
  "name": "redacted",
  "title": "redacted",
  "version": "2.0.0",
  "description": "front end build tools, including legacy and current",
  "main": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "gulp": "./node_modules/gulp-cli/bin/gulp.js",
    "generate": "./node_modules/generator/bin/index.js"
  },
  "author": "",
  "devDependencies": {
    "browser-sync": "^2.13.0",
    "camelcase": "^3.0.0",
    "eslint-formatter-pretty": "^0.3.1",
    "fs-extra-promise": "^0.4.0",
    "glob": "^7.0.5",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-angular-templatecache": "^1.8.0",
    "gulp-cli": "latest",
    "gulp-concat": "^2.6.0",
    "gulp-eslint": "^3.0.1",
    "gulp-imagemin": "^2.4.0",
    "gulp-less": "^3.0.5",
    "gulp-load-plugins": "^1.1.0",
    "gulp-ng-annotate": "^1.1.0",
    "gulp-rename": "^1.2.2",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-svg-sprite": "^1.3.3",
    "gulp-template": "^4.0.0",
    "gulp-uglify": "^1.5.1",
    "gulp-util": "^3.0.7",
    "gulp.spritesmith": "^6.2.1",
    "imagemin-jpeg-recompress": "^4.3.0",
    "less-plugin-glob": "^1.1.1",
    "lodash": "^4.14.0",
    "node-notifier": "^4.3.1",
    "request": "^2.72.0",
    "require-dir": "^0.3.0",
    "yargs": "^3.30.0"
  }
}

eslint config

{
  "extends": "eslint:recommended",
  "rules": {
    "no-alert": 1,
    "no-bitwise": 0,
    "camelcase": 1,
    "curly": 0,
    "eqeqeq": 0,
    "no-eq-null": 0,
    "guard-for-in": 1,
    "no-empty": 1,
    "no-unused-vars": 1,
    "no-console": 1,
    "no-mixed-spaces-and-tabs": 0
  },
  "globals": {
    "$": true,
    "angular": true,
    "App": true,
    "MainController": true,
    "Modernizr": true
  },
  "env": {
    "browser": true,
    "node": false
  }
}

gulp task


var gulp = require('gulp'),
        config = require('../config'),
        packages = require('../packages'),
        plugins = require('../plugins'),
        utils = require('../utils');

gulp.task('js:app',function(){
    utils.logImportant('begin js:app');
    return gulp.src([config.paths.src + config.paths.appDir + '/**/*.js'])
            .pipe(plugins.eslint('./gulp_components/eslint.json'))
            .pipe(plugins.eslint.format('node_modules/eslint-formatter-pretty'))
            .pipe(plugins.eslint.results(function(results){
                if (results.errorCount > 0) {
                    packages.nodeNotifier.notify({
                        'title': results.errorCount  + ' ERRORS FOUND',
                        'message': 'see terminal for details',
                        'wait': true,
                        'priority': 2
                    });
                    process.env.errors = true;
                }
                else {
                    process.env.errors = false;
                }
            }))
            //.pipe(plugins.eslint.format())
            .pipe(plugins.sourcemaps.init())
            .pipe(plugins.concat('app.min.js'))
            .pipe(plugins.ngAnnotate())
            .pipe(plugins.uglify())
            .pipe(plugins.sourcemaps.write('.'))
            .pipe(gulp.dest(process.env.target));
});
shinnn commented 8 years ago

you closed it w/o reply

You're missing https://github.com/adametry/gulp-eslint/issues/175#issuecomment-244254081.

We can dig into the problem further by spending our precious lifetime, if:

  1. You create a public Github repository by which we can easily reproduce the problem.
  2. You build the project on Travis CI with macOS environment and show us the log of failing build.

However, I still want you to read and understand https://github.com/adametry/gulp-eslint/issues/175#issuecomment-244254081.

mistercoffee66 commented 8 years ago

Ouch. Well, based on your comment, you're misunderstanding the question. No worries, time to move on.

shinnn commented 8 years ago

If the issue reporter doesn't satisfy the demand for the error-reproducible repository, this issue will never be fixed. Fragments of the code pasted in https://github.com/adametry/gulp-eslint/issues/175#issuecomment-244270928 don't help investigating the problem.