require-number-to-fixed-digits-argument

March 27, 2026 ยท View on GitHub

๐Ÿ“ Enforce using the digits argument with Number#toFixed().

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

It's better to make it clear what the value of the digits argument is when calling Number#toFixed(), instead of relying on the default value of 0.

Examples

// โŒ
const string = number.toFixed();

// โœ…
const string = number.toFixed(0);
// โœ…
const string = number.toFixed(2);