src/content/docs/linter/rules/no-async-promise-executor.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noAsyncPromiseExecutor`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-async-promise-executor`](https://eslint.org/docs/latest/rules/no-async-promise-executor){
"linter": {
"rules": {
"suspicious": {
"noAsyncPromiseExecutor": "error"
}
}
}
}
Disallows using an async function as a Promise executor.
The executor function can also be an async function. However, this is usually a mistake, for a few reasons:
Promise to reject. This could make it difficult to debug and handle some errors.await, this is usually a sign that it is not actually necessary to use the new Promise constructor, or the scope of the new Promise constructor can be reduced.new Promise(async function foo(resolve, reject) {})
new Promise(async (resolve, reject) => {})
new Promise(((((async () => {})))))
new Promise((resolve, reject) => {})
new Promise((resolve, reject) => {}, async function unrelated() {})
new Foo(async (resolve, reject) => {})
new Foo((( (resolve, reject) => {} )))