Skip to content

eslint/prefer-exponentiation-operator Style

What it does

Disallow the use of Math.pow in favor of the ** operator

Why is this bad?

Introduced in ES2016, the infix exponentiation operator ** is an alternative for the standard Math.pow function. Infix notation is considered to be more readable and thus more preferable than the function notation.

Examples

Examples of incorrect code for this rule:

javascript
Math.pow(a, b);

Examples of correct code for this rule:

javascript
a ** b;

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "prefer-exponentiation-operator": "error"
  }
}
bash
oxlint --deny prefer-exponentiation-operator

References

Released under the MIT License.