---
url: /docs/guide/usage/linter/rules/promise/no-nesting.md
---

### What it does

Disallow nested `then()` or `catch()` statements.

### Why is this bad?

Nesting promises makes code harder to read and understand.

### Examples

Examples of **incorrect** code for this rule:

```javascript
doThing().then(() => a.then());

doThing().then(function () {
  a.then();
});

doThing().then(() => {
  b.catch();
});

doThing().catch((val) => doSomething(val).catch(errors));
```

Examples of **correct** code for this rule:

```javascript
doThing().then(() => 4);

doThing().then(function () {
  return 4;
});

doThing().catch(() => 4);
```

```javascript
doThing()
  .then(() => Promise.resolve(1))
  .then(() => Promise.resolve(2));
```

This example is not a rule violation as unnesting here would
result in `a` being undefined in the expression `getC(a, b)`.

```javascript
doThing().then((a) => getB(a).then((b) => getC(a, b)));
```

## How to use

## Version

This rule was added in v0.15.13.

## References
