oxc-project/oxc · warning · OxcDiagnostic

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

Error message

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

What it means

Diagnostic from the oxlint `one-var` rule when only the `initialized` option is set to `consecutive`. Two adjacent declarations of the same kind both containing initialized declarators must be combined (one_var.rs:169-183). The `{}` is `var`, `let`, or `const`; the qualifier "with initialized variables" appears precisely because initialized grouping differs from uninitialized grouping in your config.

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. Combine the two adjacent initialized declarations into one statement (`let a = 1, b = 2;`), or let `oxlint --fix` do it.
  2. Keep a blank line or other statement between them if they must stay separate — the rule only joins consecutive declarations.
  3. Change `initialized` to `always`/`never` to match the style you actually want.
  4. Remember `initialized` overrides per-kind options (const/let/var), so set the kind options consistently.

Example fix

// before
let a = 1;
let b = 2;

// after
let a = 1, b = 2;
Defensive patterns

Strategy: validation

Validate before calling

// .oxlintrc.json — symmetric options avoid the qualified messages
{ "rules": { "one-var": ["warn", { "initialized": "consecutive", "uninitialized": "consecutive" }] } }

Prevention

When it happens

Trigger: Configure `"one-var": [{ "initialized": "consecutive" }]` (uninitialized unset) and write `let a = 1;` followed immediately by `let b = 2;`.

Common situations: Configs tuned so uninitialized declares stay separate (declared-then-assigned-later style) while initialized ones join; teams migrating a large file gradually; mixing per-kind options (let: consecutive) and forgetting initialized overrides them.

Related errors


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