# oxc/no-async-await

> Disallow `async` functions

Some projects avoid `async` functions. They target engines that don't have them and don't want the helper code a compiler adds, or they use promise chains or callbacks everywhere.

The rule reports the `async` keyword on function declarations, function expressions, arrow functions and methods. Since `await` needs an `async` function around it, that covers `await` too.

Two things aren't reported: `await` at the top level of a module, and an unnamed function that's the value of an object property, as in `{ save: async function () {} }`.

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

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"oxc/no-async-await" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad {"count": 3} */}
```js
async function loadUser(id) {
  const response = await fetch(`/users/${id}`);
  return response.json();
}

const refresh = async () => {
  await loadUser(current.id);
};

class Store {
  async save() {}
}
```

Not reported:

{/* good */}
```js
function loadUser(id) {
  return fetch(`/users/${id}`).then((response) => response.json());
}

const refresh = () => loadUser(current.id);
```

Also not reported, even though they use `async` or `await`:

{/* good */}
```js
const config = await loadConfig();
const handlers = { save: async function () {} };
```

## When not to use it

`async` and `await` work in Bun, Node.js and every current browser. Only turn this rule on if your project has a reason to avoid them.
