# no-unused-labels

> Disallow labels that no `break` or `continue` refers to

A label only does something when a `break` or `continue` names it. If nothing names it, either the label is left over, or the `break` that should name it leaves the wrong loop.

An unused label can also be a failed object literal. In `item => { id: item.id }` the braces are a function body and `id:` is a label, so the function returns `undefined`.

`--fix` removes the label.

This rule is on by default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-unused-labels" = "off" # or "error"
```

{/* End of the generated section. */}

## Examples

Reported. The `break` only leaves the inner loop:

{/* bad */}
```js
rows: for (const row of table) {
  for (const cell of row) {
    if (cell.isEmpty) break;
  }
}
```

{/* bad */}
```js
const ids = items.map(item => { id: item.id });
```

Not reported:

{/* good */}
```js
rows: for (const row of table) {
  for (const cell of row) {
    if (cell.isEmpty) break rows;
  }
}
```

{/* good */}
```js
const ids = items.map(item => ({ id: item.id }));
```
