Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 568 Bytes

no-multiple-resolved.md

File metadata and controls

32 lines (26 loc) · 568 Bytes

Disallow creating new promises with paths that resolve multiple times (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.
  })
})