promise/valid-params

Require the right number of arguments for Promise methods

Promise methods don't complain about extra or missing arguments. Promise.all(a, b) ignores b, and rejects unless a is iterable. promise.catch() without a handler catches nothing.

MethodArguments
Promise.resolve, Promise.reject0 or 1
Promise.all, Promise.allSettled, Promise.any, Promise.race1
then1 or 2
catch, finally1

A then, catch or finally method on something that clearly isn't a promise, such as an object literal or new Parser(), isn't reported.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"promise/valid-params" = "error" # or "warn"

Examples#

example.js1 problem
const results = Promise.all(loadUser(), loadOrders());
example.js2 problems
save(draft).then().catch();
example.jsNo problems
const results = Promise.all([loadUser(), loadOrders()]);

save(draft).then(notify, retry).catch(showError);

const parser = new Parser();
parser.then();