Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 431 Bytes

no-nesting.md

File metadata and controls

30 lines (23 loc) · 431 Bytes

Avoid nested then() or catch() statements (no-nesting)

Valid

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

Invalid

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)
)