Skip to content

asyncUnnecessaryPromiseWrappers

Reports unnecessary Promise.resolve() or Promise.reject() in async contexts.

✅ This rule is included in the ts logical preset.

Wrapping a return value in Promise.resolve() in an async function or a promise callback is unnecessary because return values are already wrapped in a Promise. Similarly, returning an error wrapped in Promise.reject() is equivalent to throwing the error. This applies to yield expressions in async generators as well.

async function getValue() {
return Promise.resolve(42);
}
async function failWithError() {
return Promise.reject(new Error("failed"));
}
promise.then(() => Promise.resolve(42));
promise.catch(() => Promise.reject(new Error("error")));

This rule is not configurable.

If you have a codebase that intentionally uses Promise.resolve() and Promise.reject() for consistency across async and non-async functions, you may want to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.