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

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

Closed
@scottohara

Description

@scottohara

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions