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;