Skip to content

Latest commit

Β 

History

History
77 lines (56 loc) Β· 1.14 KB

File metadata and controls

77 lines (56 loc) Β· 1.14 KB

no-zero-fractions

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