Skip to content

Commit

Permalink
docs: add no-nesting examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Mar 25, 2018
1 parent 1e95bab commit 8a02435
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/rules/no-nesting.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# Avoid nested `then()` or `catch()` statements (no-nesting)

#### Valid

```js
myPromise
.then(doSomething)
.then(doSomethingElse)
.catch(errors)
```

#### Invalid

```js
myPromise
.then((val) => {
doSomething(val))
.then(doSomethingElse)
})

myPromise
.then((val) => {
doSomething(val))
.catch(errors)
})

myPromise
.catch((err) => {
doSomething(err))
.then(doSomethingElse)
})

myPromise
.catch((err) => {
doSomething(err))
.catch(errors)
})
```

0 comments on commit 8a02435

Please sign in to comment.