Disallow wrapping values in Promise.resolve or Promise.reject when not needed (promise/no-return-wrap)
💼 This rule is enabled in the following configs: ✅ flat/recommended, ✅
recommended.
Ensure that inside a then() or a catch() we always return or throw a raw
value instead of wrapping in Promise.resolve or Promise.reject
myPromise.then(function (val) {
return val * 2
})
myPromise.then(function (val) {
throw 'bad thing'
})myPromise.then(function (val) {
return Promise.resolve(val * 2)
})
myPromise.then(function (val) {
return Promise.reject('bad thing')
})Pass { allowReject: true } as an option to this rule to permit wrapping
returned values with Promise.reject, such as when you would use it as another
way to reject the promise.