promise/valid-params
eslint-plugin-promise
No autofixRecommended
eslint.config.js
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/valid-params": "error",
},
},
];Enforces the proper number of arguments are passed to Promise functions.
The documentation shows no incorrect example for this rule.
// Promise.all() requires 1 argument
Promise.all([p1, p2, p3])
Promise.all(iterable)
// Promise.race() requires 1 argument
Promise.race([p1, p2, p3])
Promise.race(iterable)
// Promise.resolve() requires 0 or 1 arguments
Promise.resolve()
Promise.resolve({})
Promise.resolve([1, 2, 3])
Promise.resolve(referenceToObject)
// Promise.reject() requires 0 or 1 arguments
Promise.reject()
Promise.reject(Error())
Promise.reject(referenceToError)
// Promise.then() requires 1 or 2 arguments
somePromise().then((value) => doSomething(value))
somePromise().then(successCallback, errorCallback)
// Promise.catch() requires 1 argument
somePromise().catch((error) => {
handleError(error)
})
somePromise().catch(console.error)
// Promise.finally() requires 1 argument
somePromise().finally(() => {
console.log('done!')
// …Examples from the ESLint documentation.
promise/valid-params
eslint-plugin-promise
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/valid-params": "error",
},
},
];promise/valid-params
promise plugin · correctness
{
"plugins": [
"promise"
],
"rules": {
"promise/valid-params": "error"
}
}Biome does not have this rule.
Disallow using promises inside of callbacks.
Disallow calling new on a Promise static method.
Disallow calling cb() inside of a then() (use [util.callbackify][] instead).
Enforce the use of catch() on un-returned promises.
Require returning inside each then() to create readable and reusable Promise chains.
Disallow nested then() or catch() statements.