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.

Example

javascript
Math.pow(a, b);

How to use

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

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

References

Released under the MIT License.