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-loss-of-precision] The rule reports false positives for values with numeric separators #13346

Closed
merlinnot opened this issue May 23, 2020 · 10 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue experimental syntax This change is related to experimental syntax (stage 3 or below)

Comments

@merlinnot
Copy link

Tell us about your environment

  • ESLint Version: v7.1.0
  • Node Version: v14.0.0
  • npm Version: v6.14.4

What parser (default, Babel-ESLint, etc.) are you using?

@typescript-eslint/parser

Please show your full configuration:

It's in a public repository: https://github.com/ridedott/eslint-config

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const x = 1_000;
eslint --cache --cache-location './.cache/eslint' --fix '**/*.ts'

What did you expect to happen?

I expected not to see a no-loss-of-precision issue reported for this number.

What actually happened? Please include the actual, raw output from ESLint.

An issue is reported for this rule.

Are you willing to submit a pull request to fix this bug?

Yes, if the rule creator won't do it themself 🙂

@merlinnot merlinnot added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 23, 2020
@anikethsaha
Copy link
Member

I think it should be reported in typescript-eslint repo ?

cause numeric-separator is still in Stage 3 and eslint doesnt support stage 3 proposal .

also, the compiled JS for this TS code is working fine with eslint

@kaicataldo kaicataldo added experimental syntax This change is related to experimental syntax (stage 3 or below) and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 23, 2020
@kaicataldo
Copy link
Member

As @anikethsaha mentions above, this is still currently experimental syntax. We will add support for this syntax in core rules once it reaches stage 4.

@merlinnot
Copy link
Author

Thanks, I'll be waiting for it :)

@bricss
Copy link

bricss commented May 25, 2020

Hi everyone,

I hit this issue today as well, and it's potential problem in here. 🙂

Fan fact, is that Numeric separators are broadly used in many projects and supported already by ALL modern browsers and node as well, for about of one year.

At the moment, it's impossible to use this new rule in any project that's already use separators in codebase.

It should be at least a way, to add an option to this rule to allow the character / code to be specified in numbers. 🤠

@kaicataldo
Copy link
Member

While we can't implement support until this reaches stage 4, it might be worth checking out babel-eslint to see if that allows you to lint this syntax.

@bricss
Copy link

bricss commented Jul 12, 2020

I have checked rule with babel-eslint and can confirm, that there is no luck. It still failing for every number with _ in it. 😥

@mdjermanovic
Copy link
Member

I have checked rule with babel-eslint and can confirm, that there is no luck. It still failing for every number with _ in it.

The core no-loss-of-precision rule will not work well with numeric separators until that syntax reaches stage 4 and we update the rule, regardless of the parser being used.

In the meantime, if you're using @typescript-eslint/parser, they have already implemented @typescript-eslint/no-loss-of-precision rule which extends the core rule and works well with numeric separators.

If you're using babel-eslint parser, you could ask eslint-plugin-babel to extend the core rule in a similar way.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Aug 14, 2020
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@mdjermanovic
Copy link
Member

Numeric separators are stage 4 now.

#13568 tracks everything that should be updated to support this syntax, and that includes no-loss-of-precision rule.

@mdjermanovic
Copy link
Member

Fixed by #13574, ESLint v7.8.0

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 11, 2021
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue experimental syntax This change is related to experimental syntax (stage 3 or below)
Projects
None yet
Development

No branches or pull requests

5 participants