let-step

How a let that feeds the block below it starts its own step.

a let that joins the block below it gets a blank line above it, so it starts its own step

Runs after the gaps are decided. When a single-line let joins the statement below it through guard-join, consume-join or use-join, the let and that statement are one step, and this rule puts a blank line above the let so the step stands apart from what came before. In the example let offset joins the loop that reads it, and the blank line goes between const starts and let offset.

A run of single-line lets directly above, each read by the same block, joins the step too, and the blank line goes above the first of them. Only lets take part: a const right above the run gets a blank line after it even when the block reads it. A let the block does not read ends the run and gets a blank line below it. A let that spans lines ends the run as well.

Skipped when short-body decides the list.

Example

Before
function lineStarts(lines: string[]) {
  const starts: number[] = [];
  let offset = 0;
  for (const line of lines) {
    starts.push(offset);
    offset += line.length + 1;
  }

  return starts;
}
After
function lineStarts(lines: string[]) {
  const starts: number[] = [];

  let offset = 0;
  for (const line of lines) {
    starts.push(offset);
    offset += line.length + 1;
  }

  return starts;
}

On this page