oxc-project/oxc · warning · OxcDiagnostic
Split uninitialized '{}' declarations into multiple statemen
Error message
Split uninitialized '{}' declarations into multiple statements. What it means
Diagnostic from the oxlint `one-var` rule when the `uninitialized` option is `never`. A declaration statement with multiple uninitialized declarators, such as `let a, b;`, must be split so each uninitialized variable gets its own statement; initialized declarators follow the `initialized` option instead.
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 group: `let a, b;` becomes `let a; let b;` (auto-fixable).
- Set `uninitialized` to `consecutive` or `always` if grouped hoists are acceptable.
- Check that you really want the asymmetry — initialized and uninitialized are configured separately and override per-kind options.
- Suppress inline where a grouped hoist is idiomatic (e.g. `let row, col;`).
Example fix
// before let a, b; // after let a; let b;
Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json — grouped hoists acceptable? use "consecutive"
{ "rules": { "one-var": ["warn", { "uninitialized": "consecutive" }] } } Prevention
- Avoid `let a, b;` groups if your config sets uninitialized to never.
- Review diffs that remove initializers — they turn grouped declares into violations.
- Use the auto-fixer in a hook to keep the tree clean.
When it happens
Trigger: Configure `"one-var": [{ "uninitialized": "never" }]` and lint `let a, b;` or `var x, y, z;`.
Common situations: Styles that forbid hoisted declaration groups; refactors that removed initializers leaving `let a, b;` behind; configs where teams want `let a;` per line but merged initialized declarations.
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 '{}' declarations into multiple statements.
- Split initialized '{}' declarations into multiple statements
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/3865ef935f99c581.
Report an issue: GitHub.