A block stands inside another block without a reason
What it finds
A block that is not the body of a statement, as in { a(); b(); } standing among other statements, groups nothing: it does not change when or whether its statements run. In JavaScript it may suggest a scope that var declarations do not have.
A block that declares something with let, const, using, class or function creates a scope for it, which is a reason to write it, and is left alone; so is a block with a label, which break can leave, and the body of a case clause. An empty block is left to empty-block.
From the rule's source, bare_block.rs.
function f(a: number[]) { {tx0 reports: this block groups statements without a reason a.push(1); } { const x = 2; a.push(x); } {} switch (a.length) { case 1: { a.pop(); break; } } return a;} 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:bare-block" = "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:bare-block] reason="..."tx0 explain tx0/ts:bare-block shows the same in the terminal. Found a false positive? Report it.