# no-extra-label

> Disallow labels on `break` and `continue` that name the innermost loop or `switch`

`break` and `continue` without a label already apply to the innermost loop or `switch`. Naming that same statement's label changes nothing, and it sends the reader looking for an outer loop that isn't there.

`--fix` removes the label after `break` or `continue`.

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

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"no-extra-label" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad */}
```js
search: for (const item of items) {
  if (item.id === id) {
    select(item);
    break search;
  }
}
```

Not reported:

{/* good */}
```js
for (const item of items) {
  if (item.id === id) {
    select(item);
    break;
  }
}
```

You do need a label to leave an outer loop from an inner one:

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