Stanza

block-spacing

A block pressed against the statement above it, reported and never fixed.

Reports a multi-line block directly under a statement, when no rule decides the gap.

Example
function submit(form: Form) {
  const payload = serialize(form);
  for (const field of form.fields) {
    field.disabled = true;
    field.touched = false;
  }

  send(payload);
}
Findings
3:3 block-spacing

Report only: --check and --fix both print it, neither changes the code. Stanza cannot tell whether the block belongs to the statement above it or starts a new step, so it leaves the call to you: add a blank line above the block, or put the declaration it reads directly above it so a join rule explains the tight gap.

Reported at the start of the block when a single-line statement is followed, with no blank line, by a multi-line if, loop, try or switch. In the example the for reads form, not payload, so no join rule explains the tight gap, and the finding points at the line where the loop starts.

Not reported when:

  • another rule already decided that gap. guard-join, consume-join, use-join, guard-chain and short-body keep it tight, and after-multiline, after-guard, let-step and switch-clauses report the missing blank line themselves;
  • a blank line is already there;
  • the gap is frozen by a directive;
  • the statement above is also an if: guard chains and parallel if runs are fine;
  • the statement above is a call or an assignment and the finally of the try below repeats the same callee or target, as in setBusy(true) then try { work(); } finally { setBusy(false); }. The finally has to call it directly: later(() => setBusy(false)) does not count.