# no-single-promise-race

Disallow Promise.race over one Promise

Racing one Promise cannot select among competing asynchronous work and often indicates a missing Promise.
Instead, you SHOULD use the existing Promise directly when no second input is intended.

`Promise.race` creates a distinct Promise and schedules its settlement through the combinator.

- Category: suspicious
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
import { Promise } from "destack:async";

function first(value: Promise<int32>): Promise<int32> {
    return Promise.race([value]);
}
```

## Accepted

```ds title="main.ds"
import { Promise } from "destack:async";

function first(value: Promise<int32>): Promise<int32> {
    return value;
}
```

## Prior art

- [eslint-plugin-unicorn · no-single-promise-in-promise-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-single-promise-in-promise-methods.md)

[language/linter/src/rules/suspicious/no_single_promise_race.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/suspicious/no_single_promise_race.rs#L8)
