{"record":{"id":"e6121a7af3df36e2","repo":"oxc-project/oxc","slug":"combine-this-with-the-previous-statement-with","errorCode":null,"errorMessage":"Combine this with the previous '{}' statement with initialized variables.","messagePattern":"Combine this with the previous '(.+?)' statement with initialized variables\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/one_var.rs","lineNumber":21,"sourceCode":"\nuse oxc_ast::{\n    AstKind, AstType,\n    ast::{Expression, Statement, VariableDeclaration, VariableDeclarationKind},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::{node::NodeId, scope::ScopeId};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    fixer::Fix,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn one_var_diagnostic(span: Span, message: String) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message).with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"lowercase\")]\n/// Controls how variable declarators are grouped into declarations.\nenum OneVarMode {\n    /// Requires one declaration per variable kind in each applicable scope.\n    #[default]\n    Always,\n    /// Requires each declarator to have its own declaration statement.\n    Never,\n    /// Requires adjacent declarations of the same kind to be combined.\n    Consecutive,\n}\n\n/// Options for configuring declaration grouping by kind or initialization state.\n///\n/// `initialized` and `uninitialized` take precedence over the per-kind option for the","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/one_var.rs#L3-L39","documentation":"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.","triggerScenarios":"Configure `\"one-var\": [{ \"initialized\": \"consecutive\" }]` (uninitialized unset) and write `let a = 1;` followed immediately by `let b = 2;`.","commonSituations":"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.","solutions":["Combine the two adjacent initialized declarations into one statement (`let a = 1, b = 2;`), or let `oxlint --fix` do it.","Keep a blank line or other statement between them if they must stay separate — the rule only joins consecutive declarations.","Change `initialized` to `always`/`never` to match the style you actually want.","Remember `initialized` overrides per-kind options (const/let/var), so set the kind options consistently."],"exampleFix":"// before\nlet a = 1;\nlet b = 2;\n\n// after\nlet a = 1, b = 2;","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — symmetric options avoid the qualified messages\n{ \"rules\": { \"one-var\": [\"warn\", { \"initialized\": \"consecutive\", \"uninitialized\": \"consecutive\" }] } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set both initialized and uninitialized deliberately; each overrides per-kind options.","Keep adjacent initialized declarations merged as you write them.","Let the fixer join them automatically in pre-commit."],"tags":["oxlint","eslint","style","variables","declaration"],"backgroundTag":"eslint-one-var","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}