Skip to Content

Promise

Promise correctness and style rules from eslint-plugin-promise. Checks the chain shape of Promise-using code: every chain ends with catch, no callback inside a then, no nested .then().then(), and so on. AST-local only, type-aware Promise checks belong with typescript/* checker rules.

Source: eslint-plugin-promise (ISC).

  • promise/always-return: Require every then() callback to either return a value or throw.
  • promise/avoid-new: Reject every new Promise(...) construction.
  • promise/catch-or-return: Require unreturned promise chains to terminate with catch() so unhandled rejections cannot escape.
  • promise/no-callback-in-promise: Reject direct invocation of an error-first callback inside a then() or catch() handler.
  • promise/no-multiple-resolved: Detect Promise executor bodies with more than one resolve/reject call.
  • promise/no-native: Require every file that uses Promise to import or require the implementation explicitly, instead of reaching the native global.
  • promise/no-nesting: Reject nested then()/catch() calls inside the body of a Promise callback.
  • promise/no-new-statics: Reject new applied to Promise statics such as new Promise.resolve(x), new Promise.all([...]), or new Promise.race([...]).
  • promise/no-promise-in-callback: Reject building a promise chain inside the body of an error-first callback.
  • promise/no-return-in-finally: Reject return from inside a finally() callback.
  • promise/no-return-wrap: Reject return Promise.resolve(x) and return Promise.reject(x) inside promise callbacks; return the bare value or throw instead.
  • promise/param-names: Enforce canonical parameter names (resolve, reject) on Promise executor functions.
  • promise/prefer-await-to-callbacks: Flag continuation-passing callback shapes (last parameter is a function and an error-first invocation pattern is detected), suggesting an async/await rewrite.
  • promise/prefer-await-to-then: Prefer await over explicit .then()/.catch()/.finally() chains inside async functions.
  • promise/prefer-catch: Prefer .catch(handler) over the two-argument form .then(onFulfilled, onRejected).
  • promise/spec-only: Reject non-standard Promise statics such as Promise.done, Promise.spread, or library-specific extensions shimmed onto the global.
  • promise/valid-params: Enforce the argument counts the Promise spec defines for each method, Promise.all/Promise.race take exactly one argument, Promise.resolve/Promise.reject take zero or one, .then takes one or two, .catch/.finally take exactly one.
Last updated on