eslint-community / eslint-plugin-promise

Enforce best practices for JavaScript promises
ISC License
942 stars 91 forks source link

Can this plugin prevent promises that resolve to promises? #153

Open fantapop opened 5 years ago

fantapop commented 5 years ago

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));
}
xjamundx commented 5 years ago

Did you mean return await here?

fantapop commented 5 years ago

Oops yes.

brettz9 commented 3 months ago

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