multilineAmbiguities
Reports ambiguous multiline expressions that could be misinterpreted.
✅ This rule is included in the ts stylistic preset.
When a line ends with an expression and the next line starts with certain characters (parentheses, brackets, or template literals), JavaScript may interpret them as a continuation of the previous line rather than separate statements. This can lead to unexpected behavior and runtime errors that are difficult to debug.
Examples
Section titled “Examples”const value = identifier(expression)doSomething();const data = getArray[0].value;const result = calculate`template literal`;function process() { const a = b (c || d).execute();}const value = identifier;expression.doSomething();const data = getArray;[0].value;const result = calculate;`template literal`;function process() { const a = b; (c || d).execute();}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you consistently use semicolons and have tooling that enforces their presence, this rule may be unnecessary. However, having this rule enabled provides an additional safety net against accidental multiline ambiguities.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
no-unexpected-multiline - Oxlint:
eslint/no-unexpected-multiline
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.