-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Rule proposal: warn against unnecessary Number
calls
#6385
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
Comments
TBH in modern code one should avoid Instead using I'm not 100% sold on this being something that's of great value given the above and given that step 1 of the number coercion algorithm is "if number return" - so it will be super low cost to have useless Would love to hear more feedback from others (cc @JoshuaKGoldberg). |
This perhaps not only applies to Number() but also report unnecessary parseInt/parseFloat? |
@kkmuffme you can't really have an unnecessary |
Number
calls
Maybe a general-purpose rule for unnecessary |
On MDN, I'm always slightly in favor of |
@JoshuaKGoldberg yes exactly, that's what I had in mind originally too. @Josh-Cena agree with that |
How often do you need to parse input that's possibly in any of the valid, fully-qualified bases?!? Personally I can count the number of times I've written something other than |
It's been a month and this issue has garnered no additional reactions or comments from the community. As such I'm going to close and reject this from the plugin, as it does not appear to represent a problem the wider community is interested in. |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
Report unnecessary calls to Number() constructor when type is a number already
Fail Cases
Pass Cases
Additional Info
No response
The text was updated successfully, but these errors were encountered: