{"record":{"id":"b49d8829103ce217","repo":"oxc-project/oxc","slug":"split-declarations-into-multiple-statements","errorCode":null,"errorMessage":"Split '{}' declarations into multiple statements.","messagePattern":"Split '(.+?)' 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 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`.","triggerScenarios":"Configure `\"one-var\": \"never\"` (or per-kind `{ \"var\": \"never\" }`) and lint a declaration containing two or more declarators.","commonSituations":"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.","solutions":["Split the statement into one declaration per variable (run `oxlint --fix`).","If grouping is preferred, set the mode to `always` or `consecutive`.","Apply `never` only to selected kinds (e.g. `{ \"let\": \"never\" }`) where it matters.","Suppress inline for deliberate groupings like `let x, y;` in destructuring-heavy code."],"exampleFix":"// before\nvar a = 1, b = 2;\n\n// after\nvar a = 1;\nvar b = 2;","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — prefer grouping? use \"always\"\n{ \"rules\": { \"one-var\": \"always\" } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick the one-declaration-per-variable style consciously; it is the modern default in many teams.","Run `oxlint --fix` to split grouped declarations when adopting \"never\".","Avoid copying config blocks between repos without checking the 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-14T05:17:10.506Z"}