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

[no-extra-parens] Crash on switch default case #509

Closed
nstepien opened this issue May 10, 2019 · 2 comments
Closed

[no-extra-parens] Crash on switch default case #509

nstepien opened this issue May 10, 2019 · 2 comments
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look

Comments

@nstepien
Copy link
Contributor

Repro

{
  "rules": {
    "typescript/no-extra-parens": [1, "all", {
      "nestedBinaryExpressions": false,
      "ignoreJSX": "multi-line"
    }]
  }
}
function test(key: string) {
  switch (key) {
    case 'a': return 1;
    default: return 2;
  }
}

Expected Result
No crash

Actual Result

$ eslint test.ts
Cannot read property 'type' of null
Occurred while linting C:\dir\test.ts:4

Additional Info

Debug flag output:
> eslint test.ts --debug
  eslint:cli CLI args: [ 'test.ts', '--debug' ] +0ms
  eslint:cli Running on files +4ms
  eslint:glob-utils Creating list of files to process. +0ms
  eslint:ignored-paths baseDir = "C:\\dir" +0ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "/node_modules/*"
  eslint:ignored-paths   cooked   = "/node_modules/*" +2ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "/bower_components/*"
  eslint:ignored-paths   cooked   = "/bower_components/*" +0ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = ".*"
  eslint:ignored-paths   cooked   = ".*" +1ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "!../"
  eslint:ignored-paths   cooked   = "!../" +0ms
  eslint:ignored-paths Looking for ignore file in C:\dir +0ms
  eslint:ignored-paths Loaded ignore file C:\dir\.eslintignore +1ms
  eslint:ignored-paths Adding C:\dir\.eslintignore +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*FakeData*"
  eslint:ignored-paths   cooked   = "*FakeData*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*TestData*"
  eslint:ignored-paths   cooked   = "*TestData*" +1ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "**/fakeData/**/*"
  eslint:ignored-paths   cooked   = "**/fakeData/**/*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "**/testData/**/*"
  eslint:ignored-paths   cooked   = "**/testData/**/*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "test/coverage/**/*"
  eslint:ignored-paths   cooked   = "test/coverage/**/*" +1ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*.d.ts"
  eslint:ignored-paths   cooked   = "*.d.ts" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*FakeData*"
  eslint:ignored-paths   cooked   = "*FakeData*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*TestData*"
  eslint:ignored-paths   cooked   = "*TestData*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "**/fakeData/**/*"
  eslint:ignored-paths   cooked   = "**/fakeData/**/*" +1ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "**/testData/**/*"
  eslint:ignored-paths   cooked   = "**/testData/**/*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "test/coverage/**/*"
  eslint:ignored-paths   cooked   = "test/coverage/**/*" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "*.d.ts"
  eslint:ignored-paths   cooked   = "*.d.ts" +0ms
  eslint:ignored-paths contains: +2ms
  eslint:ignored-paths   target = "C:\\dir\\test.ts" +1ms
  eslint:ignored-paths   result = false +0ms
  eslint:ignored-paths contains: +1ms
  eslint:ignored-paths   target = "C:\\dir\\test.ts" +0ms
  eslint:ignored-paths   result = false +0ms
  eslint:cli-engine Processing C:\dir\test.ts +0ms
  eslint:cli-engine Linting C:\dir\test.ts +1ms
  eslint:config Constructing config file hierarchy for C:\dir +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading C:\dir\.eslintrc.js +1ms
  eslint:config-file Loading JS config file: C:\dir\.eslintrc.js +0ms
  eslint:plugins Loaded plugin @typescript-eslint (@typescript-eslint/eslint-plugin@1.8.0) (from C:\dir\node_modules\@typescript-eslint\eslint-plugin\dist\index.js) +0ms
  eslint:config Using C:\dir\.eslintrc.js +253ms
  eslint:config-ops Using config from partial cache +0ms
  eslint:config-ops Apply environment settings to config +1ms
  eslint:linter Linting code for C:\dir\test.ts (pass 1) +0ms
  eslint:linter An error occurred while traversing +31ms
  eslint:linter Filename: C:\dir\test.ts +0ms
  eslint:linter Line: 4 +0ms
  eslint:linter Parser Options: { ecmaVersion: undefined } +0ms
  eslint:linter Parser Path: C:\dir\node_modules\@typescript-eslint\parser\dist\parser.js +1ms
  eslint:linter Settings: {} +0ms
Cannot read property 'type' of null
Occurred while linting C:\dir\test.ts:4

Versions

package version
@typescript-eslint/eslint-plugin 1.8.0
@typescript-eslint/parser 1.8.0
TypeScript 3.4.5
ESLint 5.16.0
node 12.2.0
npm 6.9.0
@nstepien nstepien added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels May 10, 2019
@bradzacher bradzacher added the bug Something isn't working label May 10, 2019
@juergenzimmermann
Copy link

Same issue with @typescript-eslint/eslint-plugin 1.9.0 and @typescript-eslint/parser 1.9.0.

@nstepien
Copy link
Contributor Author

Looks like the rule is all good now with the latest canary version, thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look
Projects
None yet
Development

No branches or pull requests

3 participants