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.
Examples
Section titled “Examples”const value = 1000000;const value = 100_00;const value = 0xffff;const value = 0b11111111;const value = 10000n;const value = 1_000_000;const value = 10_000;const value = 0xff_ff;const value = 0b1111_1111;const value = 10_000n;const value = 1000;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useNumericSeparators - ESLint:
unicorn/numeric-separators-style - Oxlint:
unicorn/numeric-separators-style
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.