This rule raises an issue when number literals contain unnecessary decimal points (like 1.) or trailing zeros after the decimal point (like 1.0 or 123.000).

Why is this an issue?

JavaScript treats number literals like 1, 1.0, and 1. as identical values. Using different formats for the same number creates inconsistency in your codebase and makes it harder to read.

When developers see 1.0, they might wonder if there’s a specific reason for the decimal notation, such as indicating precision or mathematical context. However, in JavaScript, there’s no functional difference between these representations.

Using the simplest form (1 instead of 1.0) makes your code:

This is especially important in large codebases where consistency helps developers quickly understand and maintain the code.

What is the potential impact?

This issue affects code maintainability and readability. While it doesn’t cause functional problems, inconsistent number formatting can make code harder to review and maintain, potentially slowing down development and code reviews.

How to fix?

Remove unnecessary decimal points and trailing zeros from number literals. Use the simplest form that represents the same value.

Non-compliant code example

const price = 10.0; // Noncompliant
const count = 42.; // Noncompliant
const amount = 123.000; // Noncompliant
const scientific = 456.00e10; // Noncompliant

Compliant code example

const price = 10;
const count = 42;
const amount = 123;
const scientific = 456e10;

Documentation