promise/no-return-wrap
eslint-plugin-promise
No autofixRecommended
eslint.config.js
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/no-return-wrap": "error",
},
},
];Disallow wrapping values in Promise.resolve or Promise.reject when not needed.
myPromise.then(function (val) {
return Promise.resolve(val * 2)
})
myPromise.then(function (val) {
return Promise.reject('bad thing')
})myPromise.then(function (val) {
return val * 2
})
myPromise.then(function (val) {
throw 'bad thing'
})Examples from the ESLint documentation.
promise/no-return-wrap
eslint-plugin-promise
import promise from "eslint-plugin-promise";
export default [
{
plugins: { promise },
rules: {
"promise/no-return-wrap": "error",
},
},
];promise/no-return-wrap
promise plugin · style
{
"plugins": [
"promise"
],
"rules": {
"promise/no-return-wrap": "error"
}
}Biome does not have this rule.
Enforce consistent param names and ordering when creating new promises.
Disallow nested then() or catch() statements.
Require returning inside each then() to create readable and reusable Promise chains.
Enforce the use of catch() on un-returned promises.
Disallow calling cb() inside of a then() (use [util.callbackify][] instead).
Disallow calling new on a Promise static method.