# no-labels

Rule `sonarjs/no-labels`. Labels should not be used

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1294 by reach, #595 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-labels` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1119/) |

## Code examples

### Incorrect: the rule reports this

```js
myLabel: {
  let x = doSomething();
  if (x > 0) {
    break myLabel;
  }
  doSomethingElse();
}
```

### Correct: the rule accepts this

```js
let x = doSomething();
if (x <= 0) {
  doSomethingElse();
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-labels": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [eslint/no-labels](https://lintradar.dev/rules/eslint/no-labels.md): Disallow labeled statements
- [sonarjs/no-inverted-boolean-check](https://lintradar.dev/rules/sonarjs/no-inverted-boolean-check.md): Boolean checks should not be inverted
- [sonarjs/no-literal-call](https://lintradar.dev/rules/sonarjs/no-literal-call.md): Literals should not be used as functions
- [sonarjs/no-invariant-returns](https://lintradar.dev/rules/sonarjs/no-invariant-returns.md): Function returns should not be invariant
- [sonarjs/no-mime-sniff](https://lintradar.dev/rules/sonarjs/no-mime-sniff.md): Browsers should not be allowed to perform MIME type sniffing
- [sonarjs/no-invalid-regexp](https://lintradar.dev/rules/sonarjs/no-invalid-regexp.md): Regular expressions should be syntactically valid

---

Web page: https://lintradar.dev/rules/sonarjs/no-labels. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
