An if starts on the line where the previous block closes, which reads like a forgotten else
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.
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;} 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:
[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.