oxc-project/oxc · error · OxcDiagnostic

Unexpected newline between object and open bracket of proper

Error message

Unexpected newline between object and open bracket of property access

What it means

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.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs:30

enum DiagnosticKind {
    FunctionCall { open_paren_span: Span },
    PropertyAccess { open_bracket_span: Span },
    TaggedTemplate { backtick_span: Span },
    Division { slash_span: Span },
}

fn no_unexpected_multiline_diagnostic(kind: &DiagnosticKind) -> OxcDiagnostic {
    match kind {
        DiagnosticKind::FunctionCall { open_paren_span } => OxcDiagnostic::warn(
            "Unexpected newline between function name and open parenthesis of function call",
        )
        .with_label(
            open_paren_span.label("this is parsed as a function call, which may be unintentional"),
        )
        .with_help(
            "If you did not intend to make a function call, insert ';' before the parenthesis",
        ),
        DiagnosticKind::PropertyAccess { open_bracket_span } => OxcDiagnostic::warn(
            "Unexpected newline between object and open bracket of property access",
        )
        .with_label(
            open_bracket_span
                .label("this is parsed as a property access, which may be unintentional"),
        )
        .with_help("If you did not intend to access a property, insert ';' before the bracket"),
        DiagnosticKind::TaggedTemplate { backtick_span } => {
            OxcDiagnostic::warn(
                "Unexpected newline between template tag and template literal",
            )
            .with_label(backtick_span.label(
                "this is parsed as a tagged template, which may be unintentional",
            ))
            .with_help("If you did not intend for this to be a tagged template, insert ';' before the backtick")
        }
        DiagnosticKind::Division { slash_span } => {
            OxcDiagnostic::warn(

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Terminate the previous statement with `;`.
  2. Prefix bracket-leading lines with `;` if the previous line is not yours to change.
  3. Enable a formatter that enforces semicolons to prevent recurrence.

Example fix

// before
const first = head
[idx, idx + 1].forEach(render)

// after
const first = head;
[idx, idx + 1].forEach(render);
Defensive patterns

Strategy: validation

Validate before calling

# heuristic: lines starting with '[' after a line ending in a word/paren
rg -n -U '[\w)\]]\s*\n\[\s*\S' src/

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/3dee2de0e73b3297. Report an issue: GitHub.