An if starts on the line where the previous block closes, which reads like a forgotten else

tx0/ts:if-after-closing-bracerecommendedwarningreliability/control-flowdepth fastbug

What it finds

} if (b) { on one line looks like an else if, but the second if is a separate statement that runs whatever the first one decided. Either else is missing or the if belongs on its own line.

Reported are if statements that start on the same line as the closing brace of the statement before them.

From the rule's source, if_after_closing_brace.rs.

Example from the rule's tests
export function sign(n: number) {  let s = 0;  if (n > 0) {    s = 1;  } if (n < 0) {tx0 reports: this if starts on the line where the previous block ends    s = -1;  }  return s;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:if-after-closing-brace" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:if-after-closing-brace] reason="..."

tx0 explain tx0/ts:if-after-closing-brace shows the same in the terminal. Found a false positive? Report it.