no-unexpected-multiline
Configuration
rslint.config.ts
Rule Details
JavaScript inserts semicolons automatically (ASI), but only at certain positions. When a line break appears between an expression and tokens like (, [, `, or /, the parser treats the next line as a continuation rather than a new statement, which often surprises the author.
This rule reports four cases where a newline produces an unintended continuation:
- A function call where
(opens on the next line. - A computed property access where
[opens on the next line. - A tagged template where the
`opens on the next line. - A division by a value that visually resembles a regular-expression literal (e.g.
foo / bar /gym), where what looks like a regex is actually parsed as two divisions.
Examples of incorrect code for this rule:
Examples of correct code for this rule: