{"record":{"id":"3dee2de0e73b3297","repo":"oxc-project/oxc","slug":"unexpected-newline-between-object-and-open-bracket","errorCode":null,"errorMessage":"Unexpected newline between object and open bracket of property access","messagePattern":"Unexpected newline between object and open bracket of property access","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs","lineNumber":30,"sourceCode":"enum DiagnosticKind {\n    FunctionCall { open_paren_span: Span },\n    PropertyAccess { open_bracket_span: Span },\n    TaggedTemplate { backtick_span: Span },\n    Division { slash_span: Span },\n}\n\nfn no_unexpected_multiline_diagnostic(kind: &DiagnosticKind) -> OxcDiagnostic {\n    match kind {\n        DiagnosticKind::FunctionCall { open_paren_span } => OxcDiagnostic::warn(\n            \"Unexpected newline between function name and open parenthesis of function call\",\n        )\n        .with_label(\n            open_paren_span.label(\"this is parsed as a function call, which may be unintentional\"),\n        )\n        .with_help(\n            \"If you did not intend to make a function call, insert ';' before the parenthesis\",\n        ),\n        DiagnosticKind::PropertyAccess { open_bracket_span } => OxcDiagnostic::warn(\n            \"Unexpected newline between object and open bracket of property access\",\n        )\n        .with_label(\n            open_bracket_span\n                .label(\"this is parsed as a property access, which may be unintentional\"),\n        )\n        .with_help(\"If you did not intend to access a property, insert ';' before the bracket\"),\n        DiagnosticKind::TaggedTemplate { backtick_span } => {\n            OxcDiagnostic::warn(\n                \"Unexpected newline between template tag and template literal\",\n            )\n            .with_label(backtick_span.label(\n                \"this is parsed as a tagged template, which may be unintentional\",\n            ))\n            .with_help(\"If you did not intend for this to be a tagged template, insert ';' before the backtick\")\n        }\n        DiagnosticKind::Division { slash_span } => {\n            OxcDiagnostic::warn(","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs#L12-L48","documentation":"The `PropertyAccess` variant of `no-unexpected-multiline`: the next line starts with `[`, so JavaScript parses the previous expression's value as an object and the bracket content as a computed member access (or the whole thing becomes a tagged access chain). The label attaches to the open bracket: \"this is parsed as a property access, which may be unintentional\"; the help says to insert `;` before the bracket.","triggerScenarios":"`const x = a\\n[1, 2].forEach(...)` — a statement ending in an identifier or closing token followed by a newline and a line beginning with `[`. Common after array-literal-leading lines like `[i, j] = swap(i, j)` in semicolon-less code.","commonSituations":"Semicolon-less codebases where someone starts a line with an array literal for destructuring or `.forEach` chains; merged diffs that split a long expression across the bracket boundary.","solutions":["Terminate the previous statement with `;`.","Prefix bracket-leading lines with `;` if the previous line is not yours to change.","Enable a formatter that enforces semicolons to prevent recurrence."],"exampleFix":"// before\nconst first = head\n[idx, idx + 1].forEach(render)\n\n// after\nconst first = head;\n[idx, idx + 1].forEach(render);","handlingStrategy":"validation","validationCode":"# heuristic: lines starting with '[' after a line ending in a word/paren\nrg -n -U '[\\w)\\]]\\s*\\n\\[\\s*\\S' src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add ';' before lines that begin with '['.","Keep destructuring assignments on the same line as their target.","Adopt a formatter with semicolons to kill this class of bug."],"tags":["eslint","oxlint","no-unexpected-multiline","asi","semicolons","computed-member"],"backgroundTag":"automatic-semicolon-insertion","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"}