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 the

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Split the statement into one declaration per variable (run `oxlint --fix`).
  2. If grouping is preferred, set the mode to `always` or `consecutive`.
  3. Apply `never` only to selected kinds (e.g. `{ "let": "never" }`) where it matters.
  4. 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

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


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