Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 619 Bytes

no-multiple-resolved.md

File metadata and controls

34 lines (27 loc) · 619 Bytes

Disallow creating new promises with paths that resolve multiple times (promise/no-multiple-resolved)

This rule warns of paths that resolve multiple times in executor functions that Promise constructors.

Valid

new Promise((resolve, reject) => {
  fn((error, value) => {
    if (error) {
      reject(error)
    } else {
      resolve(value)
    }
  })
})

Invalid

new Promise((resolve, reject) => {
  fn((error, value) => {
    if (error) {
      reject(error)
    }

    resolve(value) // Both `reject` and `resolve` may be called.
  })
})