> 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-done-callback

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

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


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

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/no-done-callback': 'error',
    },
  },
]);
```

## Rule Details

Disallow using a `done`-style callback in Jest tests and hooks. Returning a Promise (or using `async`/`await`) is more reliable than relying on `done`, which can silently pass or time out when not invoked correctly.

For non-`async` functions the rule reports `noDoneCallback` and suggests wrapping the body in `new Promise(done => ...)`. For `async` functions it reports `useAwaitInsteadOfCallback`.

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

```javascript
beforeEach(done => {
  done();
});

test('myFunction()', done => {
  done();
});

test('myFunction()', async done => {
  await fetchData();
  done();
});
```

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

```javascript
beforeEach(() => {
  return setupUsTheBomb();
});

test('myFunction()', () => {
  expect(myFunction()).toBeTruthy();
});

test('myFunction()', async () => {
  const data = await fetchData();
  expect(data).toBe('peanut butter');
});
```

## Original Documentation

- [eslint-plugin-jest: no-done-callback](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-done-callback.md)
- [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-done-callback.ts)
