Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint fails on windows #4080

Closed
ameyms opened this issue Oct 7, 2015 · 16 comments
Closed

Eslint fails on windows #4080

ameyms opened this issue Oct 7, 2015 · 16 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@ameyms
Copy link

ameyms commented Oct 7, 2015

I have the utter misfortune of having to develop on windows at work.
As can be expected, I seem to be encountering the following errors:

Running via Gulp


C:\Users\amey\Code\app-ui>gulp lint
[14:57:51] Using gulpfile ~\Code\Veritas\VRP\itrp\src\ui\src\gulpfile.js
[14:57:51] Starting 'lint'...
C:\Users\amey\Code\app-ui\node_modules\eslint\lib\eslint.js:833
            if (term in opts) {
                        ^

TypeError: Cannot use 'in' operator to search for 'getObjects(row.getProperty(col.field))' in undefined
    at C:\Users\amey\Code\app-ui\node_modules\eslint\lib\eslint.js:833:25
    at String.replace (native)
    at EventEmitter.module.exports.api.report (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\eslint.js:832:27)
    at RuleContext.report (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\rule-context.js:136:20)
    at EventEmitter.Program (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\rules\no-multi-spaces.js:106:37)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\util\node-event-generator.js:42:22)
    at CommentEventGenerator.enterNode (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\util\comment-event-generator.js:98:23)
    at Controller.controller.traverse.enter (C:\Users\amey\Code\app-ui\node_modules\eslint\lib\eslint.js:782:36)

C:\Users\amey\Code\app-ui>

Running directly via CLI

The error also occurs when I directly invoke Eslint CLI:


C:\Users\amey\Code\app-ui>eslint -c .eslintrc main\webapp\js
C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\eslint.js:833
            if (term in opts) {
                        ^

TypeError: Cannot use 'in' operator to search for 'getObjects(row.getProperty(col.field))' in undefined
    at C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\eslint.js:833:25
    at String.replace (native)
    at EventEmitter.module.exports.api.report (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\eslint.js:832:27)
    at RuleContext.report (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\rule-context.js:136:20)
    at EventEmitter.Program (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\rules\no-multi-spaces.js:106:37)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\util\node-event-generator.js:42:22)
    at CommentEventGenerator.enterNode (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\util\comment-event-generator.js:98:23)
    at Controller.controller.traverse.enter (C:\Users\amey\AppData\Roaming\npm\node_modules\eslint\lib\eslint.js:782:36)

I am suspecting this has something to do with the Eslint reporter since it is failing on this line.

I am not using any custom eslint reporters.

Any suggestions?

My setup

OS: Windows 7
Node: v4.1.2
NPM: v2.14.4
Eslint: v1.6.0

gulpfile

var gulp = require('gulp'),
    eslint = require('gulp-eslint');

gulp.task('lint', function() {
    return gulp.src(['main/webapp/js/**/*.js', '!main/webapp/js/lib/{,*/}*.js'])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failOnError());
});

.eslintrc

{
    "parser": "babel-eslint",
    "env": {
        "browser": true,
        "es6": true,
        "node": true
    },

    "rules": {
        "no-undef": 2,
        "no-mixed-requires": [1, false],
        "strict": [1, "never"],
        "curly": 1,
        "no-bitwise": 1,
        "max-len": [1, 110, 4],
        "vars-on-top": 1,
        "guard-for-in": 1,
        "no-underscore-dangle": 0,

        "babel/object-shorthand": 0,
        "babel/generator-star-spacing": 0,

        "no-loop-func": 2,
        "no-multi-spaces": 1,
        "no-console": 0,
        "comma-dangle": [1, "never"],
        "indent": [1, 4],
        "quotes": [1, "single"],
        "semi": [1, "always"],
        "semi-spacing": [1, {"before": false, "after": true}],

        "brace-style": [1, "1tbs", { "allowSingleLine": true }],
        "key-spacing": [1,
            {
                "beforeColon": false,
                "afterColon": true
            }
        ],

        "new-cap": [2, {
            "newIsCap": true,
            "capIsNew": false,
            "newIsCapExceptions": [
              "ngTreetableParams"
            ]
        }],

        "space-after-keywords": [1, "always"],
        "space-before-blocks": [1, "always"],
        "space-in-parens": [1, "never"],
        "space-before-function-paren": [1, "never"],
        "space-infix-ops": [1, {"int32Hint": false}],
        "space-return-throw-case": 1,
        "max-nested-callbacks": [1, 3],
        "one-var": [1, "always"],

        "eol-last": 1
    },

    "ecmaFeatures": {
        "jsx": true,
        "arrowFunctions": true,
        "binaryLiterals": true,
        "blockBindings": true,
        "classes": true,
        "defaultParams": true,
        "destructuring": true,
        "forOf": true,
        "generators": true,
        "modules": true,
        "objectLiteralComputedProperties": true,
        "objectLiteralDuplicateProperties": true,
        "objectLiteralShorthandMethods": true,
        "objectLiteralShorthandProperties": true,
        "octalLiterals": true,
        "regexUFlag": true,
        "regexYFlag": true,
        "restParams": true,
        "spread": true,
        "superInFunctions": true,
        "templateStrings": true,
        "unicodeCodePointEscapes": true,
        "globalReturn": true
    },

    "plugins": [
        "babel"
    ],

    "globals": {
        "angular": true,
        "d3": true,
        "_": true,
        "$": true,
        "Wizard": true
    }
}
@eslintbot
Copy link

Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Oct 7, 2015
@ameyms
Copy link
Author

ameyms commented Oct 7, 2015

It is worth noting that getObjects(row.getProperty(col.field)) is where Eslint seems to be failing and that is a part of a line in a js file from the codebase.

The entire line is:

 '{{getObjects(row.getProperty(col.field))}}' +

@ilyavolodin
Copy link
Member

Can you try to isolate a reproducible code snippet that would fail? It's hard to figure out what's going on from the line you posted above?

P.S. Most of ESLint team uses Windows machines to create ESLint:-)

edit: Hmm.. this seems like an issue in the core, when it tries to replace {{ ... }} with a property in the context.report. This is very strange, and should've been cough by unittests. I think the only way to isolate it is to try to disable rules one by one until this issue goes away.

@ameyms
Copy link
Author

ameyms commented Oct 7, 2015

@ilyavolodin Thanks.

The line that is causing the issue is:

 '{{getObjects(row.getProperty(col.field))}}' +

@ameyms
Copy link
Author

ameyms commented Oct 7, 2015

Disable rules one by one? Wow. That might take some time. Alright. I better get to it.

@ilyavolodin
Copy link
Member

One more thing, before you start disabling rules, can you try running ESLint without babel-eslint? I doubt that's the issue in this case, but who knows. Also, if you are using babel you don't need ecmaFeatures, since babel ignore them anyways

@nzakas
Copy link
Member

nzakas commented Oct 7, 2015

You still need ecmaFeatures even with babel-eslint, as some rules depend on those settings.

From the call stack, it looks like no-multi-spaces is the culprit. Try disabling that first.

@hzoo
Copy link
Member

hzoo commented Oct 7, 2015

Is it only recently that some rules have used ecmaFeatures? I should probably add a note about that in the readme then.

@nzakas
Copy link
Member

nzakas commented Oct 7, 2015

Nope, it's been like that for a while. We need to know about globalReturn and modules for proper scoping, for example.

@nzakas
Copy link
Member

nzakas commented Oct 8, 2015

Also mentioned in the docs: http://eslint.org/docs/user-guide/configuring#specifying-parser

@hzoo
Copy link
Member

hzoo commented Oct 8, 2015

Ok I see can it for modules and globalReturn - I'l add it to babel-eslint readme as well then

@ilyavolodin
Copy link
Member

It looks like this might be due to concatenation in the reported message:

message: "Multiple spaces found before '" + token.value + "'.",

How do we use substitution when using context.report and passing it an object?

@ameyms
Copy link
Author

ameyms commented Oct 8, 2015

Wow! Thanks for your help guys!
@nzakas removing no-multi-spaces worked!

@ilyavolodin ilyavolodin added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 8, 2015
@nzakas
Copy link
Member

nzakas commented Oct 8, 2015

@ilyavolodin
Copy link
Member

Ah, OK, got it. Should we just fix this rule, or should we modify core to not try to do substitution when no data is present? I would guess we should do both.

@nzakas
Copy link
Member

nzakas commented Oct 8, 2015

Yup, both

nzakas added a commit that referenced this issue Oct 11, 2015
Fix: message templates fail when no parameters are passed (fixes #4080)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants