# unicorn/require-number-to-fixed-digits-argument

> Require the digits argument of `Number#toFixed()`

Without an argument, `toFixed()` rounds to zero decimals, so `(1.5).toFixed()` is `"2"`. A reader might expect two decimals, or the number unchanged. Writing the number of digits out removes the guesswork.

The rule only looks at the method name, so it reports `.toFixed()` without arguments on any object.

`--fix` adds `0`, which keeps the result the same.

{/* 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]
"unicorn/require-number-to-fixed-digits-argument" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad */}
```js
const total = price.toFixed();
```

Not reported:

{/* good */}
```js
const total = price.toFixed(2);
const rounded = price.toFixed(0);
```
