oxc-project/oxc · warning · OxcDiagnostic
Split '{}' declarations into multiple statements.
Error message
Split '{}' declarations into multiple statements. What it means
Diagnostic from the oxlint `one-var` rule in `never` mode. It requires each declarator to have its own declaration statement, so a multi-declarator statement like `var a = 1, b = 2;` is flagged with 'Split \'var\' declarations into multiple statements.' (emitted through one_var_diagnostic at one_var.rs:20-22). The `{}` is `var`, `let`, or `const`.
Source
Thrown at crates/oxc_linter/src/rules/eslint/one_var.rs:21
use oxc_ast::{
AstKind, AstType,
ast::{Expression, Statement, VariableDeclaration, VariableDeclarationKind},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use oxc_syntax::{node::NodeId, scope::ScopeId};
use crate::{
AstNode,
context::LintContext,
fixer::Fix,
rule::{DefaultRuleConfig, Rule},
};
fn one_var_diagnostic(span: Span, message: String) -> OxcDiagnostic {
OxcDiagnostic::warn(message).with_label(span)
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "lowercase")]
/// Controls how variable declarators are grouped into declarations.
enum OneVarMode {
/// Requires one declaration per variable kind in each applicable scope.
#[default]
Always,
/// Requires each declarator to have its own declaration statement.
Never,
/// Requires adjacent declarations of the same kind to be combined.
Consecutive,
}
/// Options for configuring declaration grouping by kind or initialization state.
///
/// `initialized` and `uninitialized` take precedence over the per-kind option for theView on GitHub (pinned to e1e7af627c)
Solutions
- Split the statement into one declaration per variable (run `oxlint --fix`).
- If grouping is preferred, set the mode to `always` or `consecutive`.
- Apply `never` only to selected kinds (e.g. `{ "let": "never" }`) where it matters.
- Suppress inline for deliberate groupings like `let x, y;` in destructuring-heavy code.
Example fix
// before var a = 1, b = 2; // after var a = 1; var b = 2;
Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json — prefer grouping? use "always"
{ "rules": { "one-var": "always" } } Prevention
- Pick the one-declaration-per-variable style consciously; it is the modern default in many teams.
- Run `oxlint --fix` to split grouped declarations when adopting "never".
- Avoid copying config blocks between repos without checking the mode.
When it happens
Trigger: Configure `"one-var": "never"` (or per-kind `{ "var": "never" }`) and lint a declaration containing two or more declarators.
Common situations: One-declaration-per-variable house styles common in newer codebases; upgrading a config that previously used "always"; code with grouped `let i, j;` loop counters written under the old style.
Related errors
- Combine this with the previous '{}' statement.
- Combine this with the previous '{}' statement with initializ
- Combine this with the previous '{}' statement with uninitial
- Split initialized '{}' declarations into multiple statements
- Split uninitialized '{}' declarations into multiple statemen
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/b49d8829103ce217.
Report an issue: GitHub.