# no-unreachable-loop

Rule `eslint/no-unreachable-loop`. Disallow loops with a body that allows only one iteration

- Source: eslint
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 16.8M weekly downloads of presets that enable it
- Trend: +15.1% last quarter
- Rank: #650 by reach, #1405 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-unreachable-loop` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-unreachable-loop) |
| Oxlint | `no-unreachable-loop` | no | no | plugin `eslint`, category nursery | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unreachable-loop.html) |

## Code examples

### Incorrect: the rule reports this

```js
while (foo) {
    doSomething(foo);
    foo = foo.parent;
    break;
}

function verifyList(head) {
    let item = head;
    do {
        if (verify(item)) {
            return true;
        } else {
            return false;
        }
    } while (item);
}

function findSomething(arr) {
    for (let i = 0; i < arr.length; i++) {
        if (isSomething(arr[i])) {
            return arr[i];
        } else {
            throw new Error("Doesn't exist.");
        }
    }
}

for (key in obj) {
    if (key.startsWith("_")) {
        break;
    }
    firstKey = key;
// …
```

### Correct: the rule accepts this

```js
do {
    doSomething();
} while (false)

for (let i = 0; i < 1; i++) {
    doSomething(i);
}

for (const a of [1]) {
    doSomething(a);
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "no-unreachable-loop": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-unreachable-loop": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/symbol-description](https://lintradar.dev/rules/eslint/symbol-description.md): Require symbol descriptions
- [eslint/no-useless-return](https://lintradar.dev/rules/eslint/no-useless-return.md): Disallow redundant return statements
- [eslint/prefer-promise-reject-errors](https://lintradar.dev/rules/eslint/prefer-promise-reject-errors.md): Require using Error objects as Promise rejection reasons
- [eslint/object-shorthand](https://lintradar.dev/rules/eslint/object-shorthand.md): Require or disallow method and property shorthand syntax for object literals
- [eslint/no-restricted-globals](https://lintradar.dev/rules/eslint/no-restricted-globals.md): Disallow specified global variables
- [eslint/no-void](https://lintradar.dev/rules/eslint/no-void.md): Disallow `void` operators

---

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