This is an issue when numeric literals are long and difficult to read, or when numeric separators are used inconsistently.
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:
1_234_567) 0xFF_EE_DD) 0b1010_1111) 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.
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.
Use consistent digit grouping with numeric separators. Group decimal numbers in threes from right to left, with any remainder at the beginning.
const price = 1234567; // Noncompliant const count = 1_23_4567; // Noncompliant - inconsistent grouping
const price = 1_234_567; const count = 1_234_567;