guard-join
Keeping a value next to the if that checks it.
a single-line declaration or assignment is followed directly by an if that references what it binds, whatever the body size and with or without else
Applies when a single-line declaration (const, let or var, plain or destructured, every bound name counts) or a single-line assignment is followed by an if that reads one of the names it binds. The blank line between them goes. The size of the if body does not matter and an else does not matter: the if is the step that consumes the value. let count: number; followed by an if that assigns count joins too.
An assignment to a member such as state.count = read() joins when the if reads the same path, state.count. Reading state.counter does not count.
short-body outranks it and removes the blank anyway. after-multiline outranks it the other way: a declaration that spans lines keeps a blank line after it, however clearly the if reads it. A gap next to a stanza-ignore statement is frozen and never joins.
A read that only happens inside a nested function does not count: if (ok) run(() => record) does not join to const record. A name shadowed inside the if does not count either.
Example
function load(id: string, cache: Map<string, Record>) {
const record = cache.get(id);
if (!record) {
log(`miss ${id}`);
return null;
}
return record;
}function load(id: string, cache: Map<string, Record>) {
const record = cache.get(id);
if (!record) {
log(`miss ${id}`);
return null;
}
return record;
}