Linter · Rules
unicorn/no-zero-fractions
Disallow numbers with a zero fraction or a dangling dot
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
Reported:
const scale = 1.0;
const opacity = 0.50;
const total = 10.;
const limit = 2.0e3;
Not reported:
const scale = 1;
const opacity = 0.5;
const total = 10;
const limit = 2e3;