src/content/docs/linter/rules/use-numeric-separators.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v2.0.0` - Diagnostic Category: [`lint/style/useNumericSeparators`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`unicorn/numeric-separators-style`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/numeric-separators-style.md) - Same as [`unreadable_literal`](https://rust-lang.github.io/rust-clippy/master/#unreadable_literal){
"linter": {
"rules": {
"style": {
"useNumericSeparators": "error"
}
}
}
}
Enforce the use of numeric separators in numeric literals.
Enforces a convention of grouping digits using numeric separators.
Long numbers can become difficult to read, so separating groups of digits with an underscore (_) improves code clarity. This rule also enforces proper usage of the numeric separator, by checking if the groups of digits are of the correct size.
var a = 1234567890;
var a = -999_99;
var a = 0.1234567;
var a = 0b11001100;
var a = 1_234_567_890;
var a = -99_999;
var a = 0.123_456_7;
var a = 0b1100_1100;