oxc-project/oxc · warning · OxcDiagnostic

Combine this with the previous '{}' statement with uninitial

Error message

Combine this with the previous '{}' statement with uninitialized variables.

What it means

Diagnostic from the oxlint `one-var` rule when the `uninitialized` option is `consecutive`. Two adjacent declarations of the same kind that both contain uninitialized declarators (e.g. `let a; let b;`) must be merged (one_var.rs:184-198). The `{}` placeholder is the declaration keyword.

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 the

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Merge the uninitialized declarations: `let a; let b;` becomes `let a, b;` (auto-fixable).
  2. Insert a non-declaration statement between them if separation is intentional, since only consecutive declarations are joined.
  3. Rebalance options: set `uninitialized` to `never` if you want one-per-statement, or `always` for scope-wide joining.
  4. Disable the rule inline for grouped style exceptions.

Example fix

// before
let a;
let b;

// after
let a, b;
Defensive patterns

Strategy: validation

Validate before calling

// .oxlintrc.json — "never" if hoisted groups should be split instead
{ "rules": { "one-var": ["warn", { "uninitialized": "never" }] } }

Prevention

When it happens

Trigger: Configure `"one-var": [{ "uninitialized": "consecutive" }]` and write `let a;` immediately followed by `let b;` in the same scope.

Common situations: Style guides that hoist declarations (`let a, b;`) then assign later; splitting declarations during refactoring and forgetting to re-merge; configs copied from another team with different initialized/uninitialized preferences.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/a5e0c0bc29842b16. Report an issue: GitHub.