Skip to content

[no-magic-number] fails on numeric literal types #99

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

Closed
scottohara opened this issue Jan 21, 2019 · 0 comments · Fixed by #373
Closed

[no-magic-number] fails on numeric literal types #99

scottohara opened this issue Jan 21, 2019 · 0 comments · Fixed by #373
Assignees
Labels
bug Something isn't working has pr there is a PR raised to close this package: parser Issues related to @typescript-eslint/parser

Comments

@scottohara
Copy link
Contributor

Note: this issue was originally filed here eslint/typescript-eslint-parser#588.

The original issue (now archived) was marked as closed, and suggested as being fixed by eslint/typescript-eslint-parser#596, however it does still appear to be an issue when using the latest 1.0.0 versions of the parser & plugin from the @typescirpt-eslint monorepo (unless I'm holding it wrong).

What code were you trying to parse?

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

const movement: Amount = 10

What did you expect to happen?
No errors

What actually happened?

  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?

Versions

package version
@typescript-eslint/parser 1.0.0
TypeScript 3.2.1
ESLint 5.11.1
node 11.5.0
npm 6.5.0
@scottohara scottohara added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Jan 21, 2019
@armano2 armano2 self-assigned this Jan 21, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Feb 19, 2019
@bradzacher bradzacher added the has pr there is a PR raised to close this label Apr 25, 2019
@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 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 has pr there is a PR raised to close this package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants