# max-nested-callbacks

Rule `eslint/max-nested-callbacks`. Enforce a maximum depth that callbacks can be nested

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 2.7M weekly downloads of presets that enable it
- Trend: +91.2% last quarter
- Rank: #1465 by reach, #289 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `max-nested-callbacks` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/max-nested-callbacks) |
| Oxlint | `max-nested-callbacks` | no | no | plugin `eslint`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.html) |
| Biome | `complexity/noExcessiveNestedCallbacks` | no | no | group complexity, since 2.4.14 | [docs](https://biomejs.dev/linter/rules/no-excessive-nested-callbacks/) |

## Code examples

### Incorrect: the rule reports this

```js
foo1(function() {
    foo2(function() {
        foo3(function() {
            foo4(function() {
                // Do something
            });
        });
    });
});
```

```js
setTimeout(() => {
    new Promise(function nested() {});
});
```

### Correct: the rule accepts this

```js
foo1(handleFoo1);

function handleFoo1() {
    foo2(handleFoo2);
}

function handleFoo2() {
    foo3(handleFoo3);
}

function handleFoo3() {
    foo4(handleFoo4);
}

function handleFoo4() {
    foo5();
}
```

```js
function handler() {
    new Promise(() => {});
}

setTimeout(handler);
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "max-nested-callbacks": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "max-nested-callbacks": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "complexity": {
        "noExcessiveNestedCallbacks": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [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/complexity](https://lintradar.dev/rules/eslint/complexity.md): Enforce a maximum cyclomatic complexity allowed in a program
- [eslint/no-object-constructor](https://lintradar.dev/rules/eslint/no-object-constructor.md): Disallow calls to the `Object` constructor without an argument
- [eslint/require-unicode-regexp](https://lintradar.dev/rules/eslint/require-unicode-regexp.md): Enforce the use of `u` or `v` flag on regular expressions
- [eslint/prefer-object-has-own](https://lintradar.dev/rules/eslint/prefer-object-has-own.md): Disallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`
- [eslint/no-div-regex](https://lintradar.dev/rules/eslint/no-div-regex.md): Disallow equal signs explicitly at the beginning of regular expressions
- [eslint/no-implicit-globals](https://lintradar.dev/rules/eslint/no-implicit-globals.md): Disallow declarations in the global scope

---

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