unicorn/no-zero-fractions
Disallow numbers with a zero fraction or a dangling dot
fixable
1.0, 1. and 1 are the same number. JavaScript has no separate integer and float types, so the extra zeros and the dot suggest a difference that isn't there.
--fix removes the zeros and the dot.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/no-zero-fractions" = "error" # or "warn"Examples#
example.js4 problems
const scale = 1.0Don't use a zero fraction in the number.;
const opacity = 0.50Don't use a zero fraction in the number.;
const total = 10.Don't use a dangling dot in the number.;
const limit = 2.0e3Don't use a zero fraction in the number.;example.jsNo problems
const scale = 1;
const opacity = 0.5;
const total = 10;
const limit = 2e3;