Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

[no-unused-vars] crashes with initialized enums #193

Closed
targos opened this issue Nov 28, 2018 · 3 comments
Closed

[no-unused-vars] crashes with initialized enums #193

targos opened this issue Nov 28, 2018 · 3 comments
Labels
bug/incomplete rule parser bug bugs with typescript-eslint-parser / typescript-estree
Milestone

Comments

@targos
Copy link

targos commented Nov 28, 2018

Repro

{
  "rules": {
    "no-unused-vars": "error",
    "typescript/no-unused-vars": "error"
  }
}
export enum Environment {
  development = 'development',
  staging = 'staging',
  production = 'production'
}

Expected Result

No error.

Actual Result

The no-unused-vars core rule's code of ESLint crashes.

Additional Info

Stack trace:

TypeError: Cannot read property 'type' of undefined
    at isForInRef (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:436:18)
    at variable.references.some (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:474:13)
    at Array.some (<anonymous>)
    at isUsedVariable (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:473:34)
    at collectUnusedVariables (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:613:14)
    at collectUnusedVariables (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:623:9)
    at collectUnusedVariables (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:623:9)
    at Program:exit (D:\project\node_modules\eslint\lib\rules\no-unused-vars.js:673:28)
    at listeners.(anonymous function).forEach.listener (D:\project\node_modules\eslint\lib\util\safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)

Versions

package version
eslint 5.9.0
eslint-plugin-typescript 0.14.0
typescript-eslint-parser 21.0.1
typescript 3.1.6
@bradzacher
Copy link
Owner

Downgrade your version of typescript-eslint-parser to ^17 and let me know if the issue persists

@bradzacher bradzacher added bug/incomplete rule awaiting response Issues waiting for a reply from the OP labels Nov 28, 2018
@armano2
Copy link
Contributor

armano2 commented Nov 28, 2018

issue is in parser, and got fixed in eslint/typescript-eslint-parser@491ebca

@bradzacher bradzacher added this to the 1.0.0 milestone Nov 29, 2018
@bradzacher bradzacher added parser bug bugs with typescript-eslint-parser / typescript-estree and removed awaiting response Issues waiting for a reply from the OP labels Nov 29, 2018
@targos
Copy link
Author

targos commented Nov 30, 2018

Oh, I see. I just realized that this package relies on a specific version of the typescript parser, sorry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/incomplete rule parser bug bugs with typescript-eslint-parser / typescript-estree
Projects
None yet
Development

No branches or pull requests

3 participants