# prefer-exponentiation-operator

> Require the `**` operator instead of `Math.pow()`

`Math.pow(base, exponent)` and `base ** exponent` compute the same number. The operator is shorter, reads like the arithmetic around it, and also works with `BigInt`, where `Math.pow` throws.

`--fix` rewrites the call and adds parentheses where the result needs them.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"prefer-exponentiation-operator" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
const area = Math.PI * Math.pow(radius, 2);
const distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
```

Not reported:

{/* good */}
```js
const area = Math.PI * radius ** 2;
const distance = Math.sqrt(dx ** 2 + dy ** 2);
```
