functional/no-promise-reject
February 22, 2026 ยท View on GitHub
๐ Disallow rejecting promises.
This rule disallows rejecting promises.
Rule Details
It is useful when using an Option type (something like { value: T } | { error: Error })
for handling errors. In this case a promise should always resolve with an Option and never reject.
โ Incorrect
/* eslint functional/no-promise-reject: "error" */
async function divide(x, y) {
const [xv, yv] = await Promise.all([x, y]);
return yv === 0
? Promise.reject(new Error("Cannot divide by zero."))
: xv / yv;
}
โ Correct
/* eslint functional/no-promise-reject: "error" */
async function divide(x, y) {
const [xv, yv] = await Promise.all([x, y]);
return yv === 0
? { error: new Error("Cannot divide by zero.") }
: { value: xv / yv };
}