π Disallow number literals with zero fractions or dangling dots.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
There is no difference in JavaScript between, for example, 1, 1.0 and 1., so prefer the former for consistency and brevity.
// β
const foo = 1.0;
// β
const foo = 1.;
// β
const foo = 1;// β
const foo = -1.0;
// β
const foo = -1;// β
const foo = 123_456.000_000;
// β
const foo = 123_456;// β
const foo = 123.111000000;
// β
const foo = 123.111;// β
const foo = 123.00e20;
// β
const foo = 123e20;// β
const foo = 1.1;// β
const foo = -1.1;// β
const foo = 123.456;// β
const foo = 1e3;