{"record":{"id":"da2f03dfc342bfa5","repo":"oxc-project/oxc","slug":"unexpected-newline-between-function-name-and-open","errorCode":null,"errorMessage":"Unexpected newline between function name and open parenthesis of function call","messagePattern":"Unexpected newline between function name and open parenthesis of function call","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs","lineNumber":21,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnexpectedMultiline;\n\nenum 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(","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs#L3-L39","documentation":"`no-unexpected-multiline` (the ASI rule) reports code where a newline makes the parser join two lines into one expression. This variant, `DiagnosticKind::FunctionCall`, fires when the next line starts with `(`: the previous statement's last expression is parsed as a function call. The label attaches to the open-paren span with \"this is parsed as a function call, which may be unintentional\" and the help suggests inserting `;` before the parenthesis.","triggerScenarios":"`const a = foo\\n(function () {}())` — i.e. a statement ending in an identifier/literal/closing paren followed by a newline and a line starting with `(`. Classic with IIFEs and function calls split across lines in semicolon-less style.","commonSituations":"Semicolon-less codebases after concatenating files; a line starting with `(` after a `return`/assignment; refactors that move an IIFE or parenthesized expression onto its own line.","solutions":["Add a semicolon at the end of the previous statement.","Or start the risky line with a protective leading `;` (`;(function(){})()`).","Long-term: adopt always-semicolon style (or run a formatter) so ASI joins cannot happen."],"exampleFix":"// before\nconst result = compute()\n(fn || defaultFn)()\n\n// after\nconst result = compute();\n(fn || defaultFn)();","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":["Use semicolons consistently; let a formatter insert them.","In semicolon-less style, prefix '(' leading lines with ';'.","Review any diff that moves an IIFE to the start of a line."],"tags":["eslint","oxlint","no-unexpected-multiline","asi","semicolons","parsing"],"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"}