eslint-plugin-promise icon indicating copy to clipboard operation
eslint-plugin-promise copied to clipboard

Can this plugin prevent promises that resolve to promises?

Open fantapop opened this issue 7 years ago • 3 comments
trafficstars

Is there a way to enforce that async functions do not return a promise? For example, I'd like to enforce we don't have code like this:

async function publishUser(user) {
 /// something async
}

async function publishAllUsers() {
    const users = await fetchUsersToPublish();
    return Promise.all(users.map(publishUser));
}

in favor of this:

async function getUserDetails() {
    const users = await fetchUsersToPublish();
    await Promise.all(users.map(publishUser));
}

fantapop avatar Nov 20 '18 19:11 fantapop

Did you mean return await here?

xjamundx avatar Nov 28 '18 06:11 xjamundx

Oops yes.

fantapop avatar Nov 29 '18 04:11 fantapop

So looks like a version of https://typescript-eslint.io/rules/return-await/ .

brettz9 avatar Jul 20 '24 09:07 brettz9