# too-many-break-or-continue-in-loop

Rule `sonarjs/too-many-break-or-continue-in-loop`. Loops should not contain more than a single "break" or "continue" statement

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2177 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/too-many-break-or-continue-in-loop` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-135/) |

## Code examples

### Incorrect: the rule reports this

```js
for (var i = 1; i <= 10; i++) {  // Noncompliant - 2 continue - one might be tempted to add some logic in between
  if (i % 2 == 0) {
    continue;
  }

  if (i % 3 == 0) {
    continue;
  }

  alert("i = " + i);
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/too-many-break-or-continue-in-loop": "error",
    },
  },
];
```

## Related rules

- [sonarjs/strings-comparison](https://lintradar.dev/rules/sonarjs/strings-comparison.md): Comparison operators should not be used with strings
- [sonarjs/unicode-aware-regex](https://lintradar.dev/rules/sonarjs/unicode-aware-regex.md): Regular expressions using Unicode character classes or property escapes should enable the unicode flag
- [sonarjs/shorthand-property-grouping](https://lintradar.dev/rules/sonarjs/shorthand-property-grouping.md): Shorthand object properties should be grouped at the beginning or end of an object declaration
- [sonarjs/prefer-object-literal](https://lintradar.dev/rules/sonarjs/prefer-object-literal.md): Object literal syntax should be used
- [sonarjs/values-not-convertible-to-numbers](https://lintradar.dev/rules/sonarjs/values-not-convertible-to-numbers.md): Values not convertible to numbers should not be used in numeric comparisons
- [sonarjs/prefer-immediate-return](https://lintradar.dev/rules/sonarjs/prefer-immediate-return.md): Local variables should not be declared and then immediately returned or thrown

---

Web page: https://lintradar.dev/rules/sonarjs/too-many-break-or-continue-in-loop. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
