Skip to content

Latest commit

Β 

History

History
27 lines (18 loc) Β· 947 Bytes

File metadata and controls

27 lines (18 loc) Β· 947 Bytes

require-number-to-fixed-digits-argument

πŸ“ 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);