oxc-project/oxc · warning · OxcDiagnostic
Invalid group length in numeric value.
Error message
Invalid group length in numeric value.
What it means
Lint diagnostic from oxlint's `unicorn/numeric-separators-style` rule. It enforces how numeric separators (`_`) group digits: by default decimal digits in groups of 3, hex in groups of 2, and binary/octal in groups of 4 (configurable via `groupLength`, `minimumDigits`, `onlyIfContainsSeparator` per base). This message fires when a literal's separator grouping violates the configured style — wrong group length or a long number that should be grouped.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/numeric_separators_style.rs:15
use cow_utils::CowUtils;
use oxc_ast::{
AstKind,
ast::{BigIntLiteral, BigintBase, NumberBase, NumericLiteral},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{AstNode, context::LintContext, rule::Rule};
fn numeric_separators_style_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Invalid group length in numeric value.")
.with_help("Group digits with numeric separators (_) so longer numbers are easier to read.")
.with_label(span)
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize)]
pub struct NumericSeparatorsStyle(Box<NumericSeparatorsStyleConfig>);
#[derive(Debug, Clone, PartialEq, Eq, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NumericSeparatorsStyleConfig {
/// Only enforce the rule when the numeric literal already contains a separator (`_`).
///
/// When `true`, numbers without separators are left as-is; when `false` (default),
/// grouping will be enforced for eligible numbers even if they don't include separators yet.
only_if_contains_separator: bool,
/// Configuration for hexadecimal literals (e.g. `0xAB_CD`, `0Xab_cd`, and bigint variants).
/// Controls how digits are grouped and when separators are applied.
hexadecimal: NumericBaseConfig,View on GitHub (pinned to e1e7af627c)
Solutions
- Regroup the literal to match the rule defaults: `1234567` -> `1_234_567`, `0xAABBCC` -> `0xAA_BB_CC`, `0b10100001` -> `0b1010_0001`.
- If your project uses different group sizes, configure the rule in `.oxlintrc.json` under `rules` with `"unicorn/numeric-separators-style": ["error", {"hexadecimal": {"groupLength": 4}}]` etc.
- Set `"onlyIfContainsSeparator": true` to leave numbers without `_` untouched if you only want consistency among already-separated numbers.
- Run `oxlint --fix` for an automatic rewrite, then eyeball diffs on long constants.
Example fix
// before const million = 1000000; const rgb = 0xFF00FF; const flags = 0b11110000; // after const million = 1_000_000; const rgb = 0xFF_00_FF; const flags = 0b1111_0000;
Defensive patterns
Strategy: validation
Validate before calling
// Check config before enabling: put group lengths in .oxlintrc.json, e.g.
// "unicorn/numeric-separators-style": ["error", {
// "hexadecimal": {"groupLength": 4},
// "number": {"groupLength": 3, "minimumDigits": 5}
// }]
// Then: oxlint --fix . Prevention
- Decide group sizes per base once in `.oxlintrc.json` so rule and codebase agree.
- Set `onlyIfContainsSeparator: true` if you only want consistency, not forced grouping of legacy constants.
- Run `oxlint --fix` in CI after enabling the rule to migrate literals in one reviewed PR.
When it happens
Trigger: Literals such as `const n = 1234567;` (no grouping despite 7 digits), `0xAABBCC` (hex groups of 2 expected -> `0xAA_BB_CC`), `0b1010_0001` is fine but `0b10_100001` is not, `1_0000.000_1` style mismatches. Also fires when config sets `groupLength: 4` but code uses `1_000_000`. Triggered during oxlint runs on numeric literals.
Common situations: Config mistakes: teams copy the ESLint unicorn config with custom `groupLength`/`minimumDigits` that differ from the code's existing style. Version changes: upgrading oxlint brought the rule in via the unicorn category and legacy constants (bit masks, protocol IDs) suddenly fail. Refactoring numbers across bases (dec -> hex) without regrouping separators.
Related errors
- Don't use a zero fraction in the number.
- Don't use a dangling dot in the number.
- Unexpected number literal prefix in uppercase.
- Unexpected exponential notation in uppercase.
- Unexpected hexadecimal digits in lowercase.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/73cb572a796a7445.
Report an issue: GitHub.