---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useNumberToFixedDigitsArgument
description: Learn more about useNumberToFixedDigitsArgument
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JavaScript (and super languages)" icon="seti:javascript">
## Summary
- Rule available since: `v1.8.0`
- Diagnostic Category: [`lint/suspicious/useNumberToFixedDigitsArgument`](/reference/diagnostics#diagnostic-category)
- This rule isn't recommended, so you need to enable it.
- This rule has a [**safe**](/linter/#safe-fixes) fix.
- The default severity of this rule is [**warning**](/reference/diagnostics#warning).
- Sources: 
  - Same as [`unicorn/require-number-to-fixed-digits-argument`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-number-to-fixed-digits-argument.md)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"suspicious": {
				"useNumberToFixedDigitsArgument": "error"
			}
		}
	}
}

```
## Description
Enforce using the digits argument with `Number#toFixed()`.

When using `Number#toFixed()` explicitly specify the number of digits you want to appear after the decimal point,
to avoid unexpected results, rather than relying on its default value of 0.

## Examples

### Invalid

```js
const string = number.toFixed();
```

<pre class="language-text"><code class="language-text">code-block.js:1:30 <a href="https://biomejs.dev/linter/rules/use-number-to-fixed-digits-argument">lint/suspicious/useNumberToFixedDigitsArgument</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">Specify the number of digits you want to appear after the decimal point.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>const string = number.toFixed();<br />   <strong>   │ </strong>                             <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Add explicit digits argument to </span><span style="color: lightgreen;"><strong>toFixed</strong></span><span style="color: lightgreen;"> method.</span><br />  <br />  <strong>  1 │ </strong>const<span style="opacity: 0.8;">·</span>string<span style="opacity: 0.8;">·</span>=<span style="opacity: 0.8;">·</span>number.toFixed(<span style="color: MediumSeaGreen;">0</span>);<br />  <strong>    │ </strong>                              <span style="color: MediumSeaGreen;">+</span>  <br /></code></pre>

### Valid

```js
const string = foo.toFixed(0);
```

```js
const string = foo.toFixed(2);
```

## Caveats

This rule always assumes that `toFixed` is called on a number.
It does not check the type of the callee.

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/suspicious/use_number_to_fixed_digits_argument.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/suspicious/useNumberToFixedDigitsArgument)

</TabItem>
</Tabs>