Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

no-unexpected-multiline

Disallow lines that look like a new statement but continue the previous one

JavaScript only ends a statement at a line break if the next line can't continue it. A line that starts with (, [, a template literal, or / can. Then two lines that look like two statements run as one call, property access, tagged template, or division.

This mostly happens in code without semicolons.

This rule is on by default.

Configure

On by default as an error. To turn it off:

bunfig.toml
[lint.rules]
"no-unexpected-multiline" = "off" # or "warn"

Examples

Reported. This reads an element of whatever getName() returns:

const name = getName()
[first, last].forEach(print)

This calls now with a function as its argument:

const started = now
(async () => {
  await run()
})()

This calls prefix as a template tag:

const label = prefix
`item-${id}`.trim()

This divides input by id and then by g.test(text):

const value = input
/id/g.test(text)

Not reported:

const name = getName();
[first, last].forEach(print);

const started = now;
(async () => {
  await run();
})();

If you do mean one expression, keep the opening ( or [ on the first line:

const name = getName(
  user,
);