Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 504 Bytes

no-zero-fractions.md

File metadata and controls

29 lines (22 loc) · 504 Bytes

Disallow number literals with zero fractions or dangling dots

There is no difference in JavaScript between, for example, 1, 1.0 and 1., so prefer the former for consistency.

This rule is fixable.

Fail

const foo = 1.0;
const foo = -1.0;
const foo = 123123123.0;
const foo = 1.;
const foo = 123.111000000;
const foo = 123.00e20;

Pass

const foo = 1;
const foo = -1;
const foo = 123123123;
const foo = 1.1;
const foo = -1.1;
const foo = 123123123.4;
const foo = 1e3;