Skip to content

New Rule: prefer-exponentiation-operator #10482

@RyanZim

Description

@RyanZim

Please describe what the rule should do:

ES2016 adds an exponentiation operator **; this may be preferred over using Math.pow(). The rule should disallow the use of the Math.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:

// Good
const a = 5 ** 7

// Bad
const a = Math.pow(5, 7)

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.

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionfeatureThis change adds a new feature to ESLintruleRelates to ESLint's core rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions