# no-loop-func

Rule `typescript/no-loop-func`. Disallow function declarations that contain unsafe references inside loop statements

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 1.8M weekly downloads of presets that enable it
- Trend: +1.2% last quarter
- Rank: #1562 by reach, #1623 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-loop-func` | no | no | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-loop-func) |
| Biome | `suspicious/noLoopFunc` | no | no | group suspicious, since 2.4.13 | [docs](https://biomejs.dev/linter/rules/no-loop-func/) |

## Code examples

### Incorrect: the rule reports this

```js
for (var i = 0; i < 10; i++) {
    handlers.push(() => i);
}
```

```js
let value = 0;
for (let i = 0; i < 10; i++) {
    queue.push(function () {
        return value;
    });
    value += 1;
}
```

### Correct: the rule accepts this

```js
for (let i = 0; i < 10; i++) {
    handlers.push(() => i);
}
```

```js
for (var i = 0; i < 10; i++) {
    const current = i;
    queue.push(function() {
        return current;
    });
}
```

Examples from the Biome documentation.

## Enable it

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

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/no-loop-func": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noLoopFunc": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb TypeScript](https://lintradar.dev/presets/airbnb-typescript.md) | ESLint | `eslint-config-airbnb-typescript` | 19 | 1.8M | +1.2% |

## Related rules

- [eslint/no-loop-func](https://lintradar.dev/rules/eslint/no-loop-func.md): Disallow function declarations that contain unsafe references inside loop statements
- [typescript/no-unused-private-class-members](https://lintradar.dev/rules/typescript/no-unused-private-class-members.md): Disallow unused private class members
- [typescript/consistent-return](https://lintradar.dev/rules/typescript/consistent-return.md): Require `return` statements to either always or never specify values
- [typescript/prefer-enum-initializers](https://lintradar.dev/rules/typescript/prefer-enum-initializers.md): Require each enum member value to be explicitly initialized
- [typescript/parameter-properties](https://lintradar.dev/rules/typescript/parameter-properties.md): Require or disallow parameter properties in class constructors
- [typescript/explicit-member-accessibility](https://lintradar.dev/rules/typescript/explicit-member-accessibility.md): Require explicit accessibility modifiers on class properties and methods

---

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