oxc-project/oxc · error · OxcDiagnostic
Unexpected newline between template tag and template literal
Error message
Unexpected newline between template tag and template literal
What it means
The `TaggedTemplate` variant of `no-unexpected-multiline`: the next line starts with a backtick, so the previous expression is parsed as a tag function for that template literal. The label attaches to the backtick span ("this is parsed as a tagged template, which may be unintentional") and the help recommends inserting `;` before the backtick.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs:39
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(
"Unexpected newline between numerator and division operator",
)
.with_label(
slash_span.label("this is parsed as division, which may be unintentional"),
)
.with_help("If you did not intend to divide, insert ';' before the slash")
}
}
}View on GitHub (pinned to e1e7af627c)
Solutions
- Add `;` to the end of the previous statement.
- Or keep the backtick on the same line as its intended tag/expression.
- Adopt semicolons via formatter to eliminate the whole class.
Example fix
// before
const who = getUser()
`Hello ${who}`
// after
const who = getUser();
`Hello ${who}`; Defensive patterns
Strategy: validation
Validate before calling
# heuristic: lines starting with a backtick after an expression line rg -n -U '[\w)\]]\s*\n`' src/
Prevention
- Insert ';' before lines beginning with a template literal.
- Keep the tag on the same line as its template.
- Enable no-unexpected-multiline in CI if you omit semicolons.
When it happens
Trigger: `const greeting = name\n`hello ${name}`` — a statement ending in an expression, newline, then a line starting with a backtick template. Happens when template literals are introduced into semicolon-less files.
Common situations: Migrating string concatenation to template literals in a semicolon-less codebase; copy-pasting a template literal to the start of a line after an expression statement.
Related errors
- Unexpected newline between function name and open parenthesi
- Unexpected newline between object and open bracket of proper
- Unexpected newline between numerator and division operator
- Template placeholders will not interpolate in regular string
- Unexpected string concatenation.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/94c98107ff45dadf.
Report an issue: GitHub.