# @typescript-eslint/require-await

> Disallow `async` functions that never `await` and do not return a promise

An `async` function with no `await` in it does its work right away and then wraps the result in a promise for nothing. Often the `async` is left over from a refactor, or an `await` is missing.

This is `require-await` with types, so it can allow a function that returns a promise. There, `async` turns an error thrown before the `return` into a rejection. `for await` and `await using` count as an `await`, and a function with an empty body isn't reported.

With `bunfig.toml`, turning this rule on runs it in TypeScript files and `require-await` in JavaScript files, so nothing is reported twice. With an ESLint config, turn the other rule off when you use this one.

`bun lint --type-aware` turns this rule on in TypeScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. This rule needs types, so turning it on makes `bun lint` type check your code first.

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/require-await" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```ts
async function total(prices: number[]) {
  return prices.reduce((sum, price) => sum + price, 0);
}

const log = async (message: string) => {
  console.log(message);
};
```

Not reported:

{/* good */}
```ts
function total(prices: number[]) {
  return prices.reduce((sum, price) => sum + price, 0);
}

async function readConfig(path: string) {
  const text = await Bun.file(path).text();
  return JSON.parse(text);
}

async function loadUser(id: string) {
  return fetch(`/users/${id}`);
}
```
