> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-async-promise-executor

[Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14)
## Configuration

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ js.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-async-promise-executor': 'error',
    },
  },
]);
```

## Rule Details

Disallows passing an `async` function as the executor to `new Promise()`. Using an async executor is usually a mistake because if the async executor throws an error, the error will be lost and will not cause the newly-constructed Promise to reject. Additionally, if a Promise executor uses `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor.

Examples of **incorrect** code for this rule:

```javascript
const result = new Promise(async (resolve, reject) => {
  resolve(await foo);
});

const result = new Promise(async function (resolve, reject) {
  resolve(await foo);
});
```

Examples of **correct** code for this rule:

```javascript
const result = new Promise((resolve, reject) => {
  resolve(foo);
});

const result = new Promise(function (resolve, reject) {
  readFile('foo.txt', function (err, data) {
    if (err) reject(err);
    else resolve(data);
  });
});
```

## Original Documentation

- [ESLint: no-async-promise-executor](https://eslint.org/docs/latest/rules/no-async-promise-executor)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-async-promise-executor.js)
