{"record":{"id":"8f9b5d09a1f6f498","repo":"oxc-project/oxc","slug":"combine-this-with-the-previous-statement","errorCode":null,"errorMessage":"Combine this with the previous '{}' statement.","messagePattern":"Combine this with the previous '(.+?)' statement\\.","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. It tells you that a variable declaration should be merged with a preceding declaration of the same kind in the same scope. It appears in two shapes: default mode `always` when two same-kind declarations exist in one scope (one_var.rs:219-228), and `consecutive` mode when both the initialized and uninitialized options are `consecutive` for adjacent same-kind statements (one_var.rs:155-167). The `{}` placeholder is filled with `var`, `let`, or `const`.","triggerScenarios":"Default config `\"one-var\": \"always\"` with `var foo = 1; var bar = 2;` in the same function; or `[{ \"initialized\": \"consecutive\", \"uninitialized\": \"consecutive\" }]` with two adjacent `let` statements.","commonSituations":"Codebases where developers declare variables as they go and the house style is one grouped declaration; enabling one-var without deciding always vs never first; legacy `var` heavy code; codemods that emit one declaration per variable.","solutions":["Merge the declarations: `var foo = 1; var bar = 2;` becomes `var foo = 1, bar = 2;` (run `oxlint --fix`, the rule is conditionally fixable).","If you prefer one declaration per variable, configure `\"one-var\": \"never\"`.","Use `consecutive` if you only want adjacent same-kind statements joined.","Add an inline disable comment where merging would hurt readability (e.g. long initializers)."],"exampleFix":"// before\nvar foo = 1;\nvar bar = 2;\n\n// after\nvar foo = 1, bar = 2;","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — choose the grouping mode explicitly\n{ \"rules\": { \"one-var\": [\"warn\", \"never\"] } } // if you prefer one per statement","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide always vs never vs consecutive up front and share the config; the default is \"always\".","Run `oxlint --fix` on a quiet branch when first enabling one-var — most messages are auto-fixable.","During refactors, re-check that moved declarations still satisfy the grouping mode."],"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-14T00:17:10.932Z"}