no-async-promise-executor
What it does
Section titled “What it does”Reports new Promise(async ...): an async function (or arrow function) as the executor, with or without a second argument.
Why it matters
Section titled “Why it matters”The Promise constructor ignores what its executor returns. An error thrown in an async executor rejects the promise the executor returned, which nobody holds, so the new promise never settles and the caller waits forever; the error shows up only as an unhandled rejection, if at all.
To fix, give the executor as a normal function and call resolve and reject yourself, or drop new Promise and write an async function that returns the value.
Example
Section titled “Example”...new Promise(async (resolve) => resolve()); new Promise(async function () {}); new Promise((resolve) => resolve()); new Promise();...Configuration
Section titled “Configuration”js: lint: rules: no-async-promise-executor: warn # off, warn (default), errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-async-promise-executor in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-async-promise-executor |
full |