Stanza

after-multiline

The blank line after a statement that spans lines.

A statement that spans several lines is followed by a blank line.

function parseConfig(text: string) {
  const raw = JSON.parse(
    text,
  );

  if (!isRecord(raw)) throw new Error("config must be an object");
  return raw;
}

A statement is multi-line when it starts and ends on different lines: a call with its arguments on their own lines, an object literal, an if whose block body spans lines, a loop, a try. The rule applies to every gap after such a statement, at every level including module top level, except the gap between a multi-line import and the import or re-export after it.

Two rules outrank it. short-body removes the blank when the list holds 2 or 3 compact statements, and guard-chain removes it between guards whose joined lines fit the formatter width. Compact means on one line, or a braceless if, for or while whose joined line fits that width, and an if with else only when every arm does. A too long braceless guard stays on two lines and gets a blank line after it. This rule outranks every join rule, so a multi-line declaration never joins the if, return, loop or try that reads it. The example shows that: the guard reads raw, and the blank line still goes in.

When the next statement begins on the line where the multi-line statement ends, nothing is inserted between them. A switch clause whose body starts on the line after its label is multi-line too, so the blank line before the next label is reported under this rule rather than switch-clauses.