{"record":{"id":"22341667962340cd","repo":"oxc-project/oxc","slug":"split-initialized-declarations-into-multiple","errorCode":null,"errorMessage":"Split initialized '{}' declarations into multiple statements.","messagePattern":"Split initialized '(.+?)' declarations into multiple statements\\.","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 the `initialized` option is `never`. A single declaration statement that contains more than one initialized declarator (e.g. `let a = 1, b = 2;`) is flagged and must be split; uninitialized declarators in the same statement are governed by the separate `uninitialized` option (one_var.rs:37-60 documents the precedence).","triggerScenarios":"Configure `\"one-var\": [{ \"initialized\": \"never\" }]` and declare two initialized variables in one statement.","commonSituations":"Styles that split initialized declarations (each with its own comment/initializer) but allow grouped hoists like `let a, b;`; migrating from a shared config where initialized and uninitialized were treated differently; codemod output that collapses declarations.","solutions":["Split each initialized declarator into its own statement (`oxlint --fix` handles it).","Change `initialized` to `always`/`consecutive` if grouping initialized variables is fine.","Verify you did not accidentally set only one of initialized/uninitialized — they are independent and override per-kind modes.","Inline-disable for tightly-coupled pairs (e.g. `let min = 0, max = 1;`)."],"exampleFix":"// before\nlet a = 1, b = 2;\n\n// after\nlet a = 1;\nlet b = 2;","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — align initialized/uninitialized with your real style\n{ \"rules\": { \"one-var\": [\"warn\", { \"initialized\": \"always\", \"uninitialized\": \"consecutive\" }] } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember initialized/uninitialized options override the per-kind (const/let/var) settings.","One initialized declarator per statement as you code, or let the fixer split them.","Re-run the linter after codemods that merge declarations."],"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"}