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 --init throws: TypeError: Cannot read property '0' of undefined #7860

Closed
gfx opened this issue Jan 5, 2017 · 5 comments · Fixed by #7919, singapore/lint-condo#218 or renovatebot/renovate#63 · May be fixed by iamhunter/teammates#4
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 cli Relates to ESLint's command-line interface

Comments

@gfx
Copy link

gfx commented Jan 5, 2017

eslint --init fails when my enviroment:

  • ESLint v3.12.2
  • NodeJS v6.9.2
  • npm 3.10.8

with the answers:

$ eslint --init
? How would you like to configure ESLint? Inspect your JavaScript file(s)
? Which file(s), path(s), or glob(s) should be examined? client/
? What format do you want your config file to be in? JSON
? Are you using ECMAScript 6 features? Yes
? Are you using ES6 modules? Yes
? Where will your code run? Browser
? Do you use CommonJS? No
? Do you use JSX? Yes
? Do you use React? Yes
Determining Config: 23% [=======-----------------------] 1.0s elapsed, eta 3.3s Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
    at lintResults.forEach.result (~/.ghq/github.com/proj/node_modules/eslint/lib/config/autoconfig.js:301:60)
    at Array.forEach (native)
    at ruleSets.forEach.ruleSet (~/.ghq/github.com/proj/node_modules/eslint/lib/config/autoconfig.js:296:29)
    at Array.forEach (native)
    at filenames.forEach.filename (~/.ghq/github.com/proj/node_modules/eslint/lib/config/autoconfig.js:292:22)
    at Array.forEach (native)
    at Registry.lintSourceCode (~/.ghq/github.com/proj/node_modules/eslint/lib/config/autoconfig.js:287:19)
    at configureRules (~/.ghq/github.com/proj/node_modules/eslint/lib/config/config-initializer.js:148:25)
    at processAnswers (~/.ghq/github.com/proj/node_modules/eslint/lib/config/config-initializer.js:248:18)
    at inquirer.prompt.err [as completed] (~/.ghq/github.com/proj/node_modules/eslint/lib/config/config-initializer.js:418:30)

with a patch to autoconfig.js:

# line 301
+                    console.log(lintedRegistry.rules[result.ruleId]);
+                    console.log(result.ruleId, ruleSetIdx);
                     if (lintedRegistry.rules[result.ruleId][ruleSetIdx]) {
                         lintedRegistry.rules[result.ruleId][ruleSetIdx].errorCount += 1;
                     }

it shows:

undefined
import/extensions 0

Seams lintedRegistry.rules["import/extensions"] is missing.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jan 5, 2017
@mysticatea mysticatea added bug ESLint is working incorrectly cli Relates to ESLint's command-line interface evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jan 5, 2017
@mysticatea
Copy link
Member

Thank you for the report!

Looks like a bug.
I guess that eslint --init command handles only core rules, but import/extensions was appeared.

@alberto
Copy link
Member

alberto commented Jan 7, 2017

@gfx any idea how eslint-plugin-import got installed and enabled there? I can't reproduce this

@gfx
Copy link
Author

gfx commented Jan 8, 2017

@alberto I just add eslint-plugin-import to devDependencies in package.json and enable it in .elsintrc.

@nzakas
Copy link
Member

nzakas commented Jan 14, 2017

@IanVS any idea why a plugin rule would show up in auto config?

@IanVS
Copy link
Member

IanVS commented Jan 14, 2017

I think that one of his files has an inline config that is enabling import/extensions, and the code is not properly guarded. It guards against core rules, as a result of the fix to #5992, but we also need to check for plugin rules. I can fix this quickly.

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 14, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 6, 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 cli Relates to ESLint's command-line interface
Projects
None yet
6 participants