unnecessaryNumericFractions
Reports numeric literals with unnecessary zero fractions or dangling dots.
✅ This rule is included in the ts stylistic presets.
Numeric literals with trailing zero fractions (e.g., 1.0) or dangling dots (e.g., 1.) are unnecessarily verbose and can be confusing.
The zero fraction or dangling dot doesn’t add any precision information to the number.
This rule reports numeric literals with unnecessary zero fractions or dangling dots.
Examples
Section titled “Examples”const value = 1.0;const value = 13.000;const value = 1.;const value = 1.20000;const value = 1;const value = 13;const value = 1;const value = 1.2;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer explicit zero fractions or dangling dots in numeric literals for stylistic consistency, this rule may not be for you.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
unicorn/no-zero-fractions - Oxlint:
unicorn/no-zero-fractions
Made with ❤️🔥 around the world by
the Flint team and contributors.