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

number-literal-case breaks with bigints #812

Closed
hayes opened this issue Aug 30, 2020 · 6 comments · Fixed by #815
Closed

number-literal-case breaks with bigints #812

hayes opened this issue Aug 30, 2020 · 6 comments · Fixed by #815

Comments

@hayes
Copy link

hayes commented Aug 30, 2020

There isn't a good way to write hex big int literals with this rule enabled.

0x7Fn is marked as an error presumably because of the lower case n.

@fisker
Copy link
Collaborator

fisker commented Aug 30, 2020

It was fixed long time ago #490, are you using old version?

@fisker
Copy link
Collaborator

fisker commented Aug 30, 2020

Ah, maybe you are using a old version of Node.js? Maybe there is actually something wrong in that rule.

Can you share what version of Node.js and what parser you are using? That can help

@hayes
Copy link
Author

hayes commented Aug 31, 2020

Sorry for the delayed response. and thanks for the quick reply @fisker!

I dug into it a bit more, and I am seeing the same thing with multiple versions of node (14.9.0, 12.18.3). All my direct dependencies are up to date (but possible some nested dependencies are not), but there is only one version of eslint-plugin-unicorn and it is 21.0.0.

Looking at the actual rule, the issue seems to be that for BigInts when it grabs the bigint value for a bigint hex literal here https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/rules/number-literal-case.js#L16, it is a base 10 string rather than a hex string. (eg. 0x7fn will be '127') which means the "fixed" version it compares against will be 127n.

@fisker
Copy link
Collaborator

fisker commented Sep 1, 2020

Located the problem, broken on @typescript-eslint/parser, is this the parser you use?

@hayes
Copy link
Author

hayes commented Sep 1, 2020

yup, it is!

@fisker
Copy link
Collaborator

fisker commented Sep 1, 2020

Fixed in #815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants