numeric-separators-style
UnreleasedConfiguration
Rule details
Enforce consistent _ separators in numeric and BigInt literals. The rule can
automatically regroup digits while preserving the value and notation of each
literal.
Examples of incorrect code for this rule
Examples of correct code for this rule
Options
The rule accepts binary, octal, hexadecimal, and number option objects.
minimumDigits sets the digit count at which grouping starts. For decimals,
it applies independently to the integer, fractional, and exponent parts.
groupLength groups digits from the right. number.fractionGroupLength
groups fractional digits from the decimal point toward the right.
onlyIfContainsSeparator defaults to false. Set it to true to check only
literals that already contain _. Each option object can override the
top-level setting.
Differences from upstream
Rslint checks JavaScript and TypeScript files. Use the upstream rule to check TOML and SOML files.
Legacy literals such as 099999.12 and 0777777 produce a syntax error in
scripts. Write them as 99999.12 and 0o777777 to check their grouping.
With languageOptions.ecmaVersion set to 2020 or earlier, 12345 still gets a
diagnostic. The rule withholds the autofix to 12_345 because that syntax
requires ES2021.