Skip to content

numericSeparatorGroups

Reports numeric literals with inconsistent separator grouping.

✅ This rule is included in the ts stylisticStrict presets.

This rule enforces consistent grouping of digits using numeric separators.

Numeric separators (_) make large numbers more readable by grouping digits. This rule enforces:

  • Groups of 3 for decimal numbers (e.g., 1_000_000)
  • Groups of 4 for binary and octal numbers (e.g., 0b1111_0000)
  • Groups of 2 for hexadecimal numbers (e.g., 0xFF_FF)

Numbers with fewer than 5 digits are not required to use separators.

const
const value: 1000000
value
= 1000000;
const
const value: 10000
value
= 100_00;
const
const value: 65535
value
= 0xffff;
const
const value: 255
value
= 0b11111111;
const
const value: 10000n
value
= 10000n;

This rule is not configurable.

If you prefer not to use numeric separators, or have a codebase with a different convention for digit grouping, you may want to disable this rule.

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