Skip to content

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.

const value = 1.0;
const value = 13.000;
const value = 1.;
const value = 1.20000;

This rule is not configurable.

If you prefer explicit zero fractions or dangling dots in numeric literals for stylistic consistency, this rule may not be for you.

Made with ❤️‍🔥 around the world by the Flint team and contributors.