eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
916 stars 75 forks source link

no-magic-number regression starting with v20.1.0 #588

Closed scottohara closed 5 years ago

scottohara commented 5 years ago

What version of ESLint are you using? 5.11.1

What version of TypeScript are you using? 3.1.1

What version of typescript-eslint-parser are you using? Any version from 20.1.0 onwards

What code were you trying to parse?

{
  "parser": "typescript-eslint-parser",
  "rules": {
    "no-magic-numbers": "error"
  }
}
type Amount = 10 | -10;

const amount: Amount = 10;

What did you expect to happen? No errors

What happened? In typescript-eslint-parser@20.0.0, code passes with no errors.

With typescript-eslint-parser@20.1.0 onwards, the errors below occur:

1:15  error  No magic number: 10   no-magic-numbers
1:20  error  No magic number: -10  no-magic-numbers

The magic numbers that the rule is complaining about are the allowed values of the Typescript numeric literal type type Amount = 10 | -10.

I'm not aware of any way to define a numeric literal type that doesn't violate the magic numbers rule?

armano2 commented 5 years ago

issue is solved in #584

JamesHenry commented 5 years ago

584 turned into #596 and has been merged