Rule proposal: Prefer `Number` methods
See original GitHub issueFail
parseInt(…);
parseFloat(…);
isNaN(…);
isFinite(…);
Pass
Number.parseInt(…);
Number.parseFloat(…);
Number.isNaN(…);
Number.isFinite(…);
This rule cannot be auto-fixable as the globals methods have slightly different behavior. However, it should use the ESLint suggestions API.
Should we also enforce Number.NaN
over NaN
? They equivalent. I’m leaning towards “yes”, for consistency, and also less use of floating globals.
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Proposed Rule: Further Definition of “As a Part of a Regular ...
4 Accordingly, the Commission is proposing to further define what it means to be buying and selling securities “as a part of a...
Read more >A Guide to the Rulemaking Process - Federal Register
Before the Proposed Rule. What gives agencies the authority to issue regulations? How does an agency decide to begin rulemaking?
Read more >Medicare Program: Payment Policies under the Physician Fee ...
Summary. This major proposed rule addresses changes to the physician fee schedule and other Medicare Part B payment policies, such as changes to...
Read more >17 CFR § 240.14a-8 - Shareholder proposals. - Law.Cornell.Edu
(2) One of the following methods must be used to demonstrate your eligibility to submit a proposal: (i) If you are the registered...
Read more >Outline for Research Proposal - Portland State University
Outline for Research Project Proposal · 1. Introduction · 2. Background/Review of the Literature · 3. Rationale · 4. Method and Design ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would like to see a reasoning for why number properties are better, (and not just because of global-phobia) If you can’t argument for a good reason, then don’t break something that isn’t broken.
I came here for the
Number.NaN
reason… never seen anyone write that …or using NumberNumber.NEGATIVE_INFINITY
That’s just too long and unpleasant to write Some functions are the same,parseInt === Number.parseInt
,Number.parseFloat === parseFloat
, So why should you useNumber[xxx]
?isNaN i can understand it’s not the same as
Number.isNaN
and dose things differentlyThere may just be usecases where you would prefer to use one over the other, just because of it’s differences
I think
is more correct.