-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
New Rule: prefer-exponentiation-operator #10482
New Rule: prefer-exponentiation-operator #10482
Comments
Instead, this rule should probably be called |
@ljharb Good point, that would work too; though I don't know how common |
This is currently doable using That said, I'm not opposed to a new rule for this case. |
It would be wonderful for the airbnb config to have a standalone rule rather than using no-restricted-properties. |
I didn't think about |
I'll champion this proposal. I like the rule name |
If anyone needs this rule, it's available in |
@sindresorhus it'd be great if you PR'd it and its tests into eslint core :-) |
https://stackoverflow.com/questions/41679191/why-is-math-pow-sometimes-not-equal-to-in-javascript According to this questions, use |
The comments suggests it’s just a bug in v8; not a reason to write code differently. |
👍 It's accepted now I don't know is it relevant for the decision to implement the rule, but it seems that the bug hasn't been fixed yet: |
@mdjermanovic I don't think we should let a single runtime's bug prevent us from adding this rule, but it could be nice to include a link to the bug in the rule's docs. |
I'm working on this. From the specification, it seems that the only difference is when both arguments evaluate to bigint, as Re the autofix, I think it's an acceptable change in behavior 👍 |
Please describe what the rule should do:
ES2016 adds an exponentiation operator
**
; this may be preferred over usingMath.pow()
. The rule should disallow the use of theMath.pow()
function, in favor of using**
.What category of rule is this? (place an "X" next to just one item)
[ ] Enforces code style
[ ] Warns about a potential error
[x] Suggests an alternate way of doing something
[ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
Why should this rule be included in ESLint (instead of a plugin)?
This is a ES2016 feature, which can replace an older way of doing things. There should be a rule to force upgrading code; similar to how ESLint has
no-var
,prefer-spread
, etc.The text was updated successfully, but these errors were encountered: