# no-label-var

> Disallow labels that share a name with a variable

Labels and variables live in separate namespaces, so a label can have the same name as a variable that's in scope. Then the same word means two things a few lines apart. `continue rows` jumps to the label, and `rows.length` reads the variable.

{/* 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-label-var" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad */}
```js
const rows = table.rows;

rows: for (const row of rows) {
  for (const cell of row.cells) {
    if (cell.isEmpty) continue rows;
  }
  print(row);
}
```

Not reported:

{/* good */}
```js
const rows = table.rows;

eachRow: for (const row of rows) {
  for (const cell of row.cells) {
    if (cell.isEmpty) continue eachRow;
  }
  print(row);
}
```

Globals count as variables too. `top` is a global in browsers:

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