multilineAmbiguities
Reports ambiguous multiline expressions that could be misinterpreted.
✅ This rule is included in the tsstylisticandstylisticStrictpresets.
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 const value: string
value = const identifier: (arg: string) => string
identifier(const expression: string
expression)const doSomething: () => void
doSomething();const const data: string
data = const getArray: { value: string;}[]
getArray[0].value: string
value;const const result: string
result = const calculate: (strings: TemplateStringsArray) => string
calculate`template literal`;function function process(): void
process() { const const a: void
a = const b: (arg: { execute(): void;}) => { execute(): void;}
b (const c: { execute(): void;} | undefined
c || const d: { execute(): void;}
d).function execute(): void
execute();}const const value: string
value = const identifier: string
identifier;const expression: { doSomething(): void;}
expression.function doSomething(): void
doSomething();const const data: { value: string;}[]
data = const getArray: { value: string;}[]
getArray;[0].any
value;const const result: (strings: TemplateStringsArray) => string
result = const calculate: (strings: TemplateStringsArray) => string
calculate;`template literal`;function function process(): void
process() { const const a: string
a = const b: string
b; (const c: { execute(): void;} | undefined
c || const d: { execute(): void;}
d).function execute(): void
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 ❤️🔥 around the world by
the Flint team and contributors.