A label marks a statement that is not a loop, switch or block

tx0/ts:label-on-non-looprecommendedwarningsmell

What it finds

A label is only useful on a statement that break or continue can leave, which in practice is a loop, a switch or a block. A label on any other statement is never jumped to, and often is not meant as a label at all: http://example.com written as code is the label http followed by a comment.

Labels on loops, switches and blocks are left alone.

From the rule's source, label_on_non_loop.rs.

Example from the rule's tests
function f(items: number[]) {  http://example.com  fetchIt();tx0 reports: the label http marks a statement  outer: for (const a of items) {    for (const b of items) {      if (a === b) continue outer;    }  }  block: {    if (items.length) break block;  }}declare function fetchIt(): void;"#        .replace("http://example.com\n  fetchIt(); // want", "http: fetchIt(); // want")        .as_str(),    );} #[test]fn comma_sequence() {    example(        "comma-sequence",        r#"function f(a: number[], g: () => void) {  for (let i = 0, j = 10; i < j; i++, j--) {    a.push(i);  }  (0, g)();  return a.pop(), a.length;tx0 reports: the comma operator joins these expressions}
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:label-on-non-loop" = "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:label-on-non-loop] reason="..."

tx0 explain tx0/ts:label-on-non-loop shows the same in the terminal. Found a false positive? Report it.