Skip to content

Commit 0b231da

Browse files
ChristianMurphymacklinu
authored andcommitted
docs: add no-nesting examples (#120)
1 parent 5956eca commit 0b231da

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/rules/no-nesting.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# Avoid nested `then()` or `catch()` statements (no-nesting)
2+
3+
#### Valid
4+
5+
```js
6+
myPromise
7+
.then(doSomething)
8+
.then(doSomethingElse)
9+
.catch(errors)
10+
```
11+
12+
#### Invalid
13+
14+
```js
15+
myPromise.then(val => {
16+
doSomething(val).then(doSomethingElse)
17+
})
18+
19+
myPromise.then(val => {
20+
doSomething(val).catch(errors)
21+
})
22+
23+
myPromise.catch(err => {
24+
doSomething(err).then(doSomethingElse)
25+
})
26+
27+
myPromise.catch(err => {
28+
doSomething(err).catch(errors)
29+
})
30+
```

0 commit comments

Comments
 (0)