This is an issue when numeric literals are long and difficult to read, or when numeric separators are used inconsistently.

Why is this an issue?

Long numeric literals without proper grouping are hard to read and prone to errors. When you see a number like 1000000, it’s difficult to quickly determine if it represents one million or ten million.

JavaScript supports numeric separators (underscores) to group digits and improve readability. For example, 1_000_000 is much clearer than 1000000. However, inconsistent use of separators can be just as confusing as not using them at all.

Different number types have conventional grouping patterns:

Inconsistent grouping, such as 1_23_4567 or 0xA_B_CD_EF, defeats the purpose of using separators and can actually make numbers harder to read than if no separators were used at all.

What is the potential impact?

Poor numeric formatting reduces code readability and increases the likelihood of errors when working with large numbers. Developers may misread values, leading to bugs in calculations, incorrect configuration values, or logic errors. This is particularly problematic in financial applications, system configuration, or any domain involving precise numeric values.

How to fix?

Use consistent digit grouping with numeric separators. Group decimal numbers in threes from right to left, with any remainder at the beginning.

Non-compliant code example

const price = 1234567; // Noncompliant
const count = 1_23_4567; // Noncompliant - inconsistent grouping

Compliant code example

const price = 1_234_567;
const count = 1_234_567;

Documentation