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 value = 1000000;
const value = 100_00;
const value = 0xffff;
const value = 0b11111111;
const 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 ❤️‍🔥 in Boston by Josh Goldberg and contributors.