Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 655 Bytes

require-number-to-fixed-digits-argument.md

File metadata and controls

37 lines (26 loc) · 655 Bytes

Enforce using the digits argument with Number#toFixed()

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.

This rule is fixable.

Fail

const string = number.toFixed();

Pass

const string = foo.toFixed(0);
const string = foo.toFixed(2);
const integer = Math.floor(foo);
const integer = Math.ceil(foo);
const integer = Math.round(foo);
const integer = Math.trunc(foo);