π Require consistent decimal numbers without redundant zeros.
πΌ This rule is enabled in the following configs: β
recommended, π¨ recommended-css, π§© recommended-json, π recommended-soml, π οΈ recommended-toml, π recommended-yaml, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
Use a leading zero before the decimal point, and remove redundant trailing fractional zeros and dangling decimal points. For example, prefer 0.5 over .5, 1.5 over 1.50, and 1 over 1.0 or 1..
The rule also supports JSON, JSONC, JSON5, SOML, TOML, YAML, and CSS. It preserves CSS units (2.0px β 2px, .5s β 0.5s) and SOML/TOML/YAML float types (1.00 β 1.0). Tagged YAML scalars, strings, .inf, and .nan are skipped.
// β
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;