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.
function submit(form: Form) {
const payload = serialize(form);
for (const field of form.fields) {
field.disabled = true;
field.touched = false;
}
send(payload);
}3:3 block-spacingReport 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 parallelifruns are fine; - the statement above is a call or an assignment and the
finallyof thetrybelow repeats the same callee or target, as insetBusy(true)thentry { work(); } finally { setBusy(false); }. Thefinallyhas to call it directly:later(() => setBusy(false))does not count.