no-zero-fractions
March 27, 2026 ยท View on GitHub
๐ 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.
Examples
// โ
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;