# no-done-callback

Rule `vitest/no-done-callback`. Disallow using a callback in asynchronous tests and hooks

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Deprecated: yes
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1856 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/no-done-callback` | no | suggestion | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md) |
| Biome | `style/noDoneCallback` | no | no | group style, since 1.6.1 | [docs](https://biomejs.dev/linter/rules/no-done-callback/) |

## Code examples

### Incorrect: the rule reports this

```js
test('foo', (done) => {
  setTimeout(done, 1000)
})

test('foo', (done) => {
  setTimeout(() => done(), 1000)
})

test('foo', (done) => {
  setTimeout(() => {
    done()
  }, 1000)
})

test('foo', (done) => {
  setTimeout(() => {
    done()
  }, 1000)
})
```

### Correct: the rule accepts this

```js
test('foo', async () => {
  await new Promise((resolve) => setTimeout(resolve, 1000))
})

test('foo', async () => {
  await new Promise((resolve) => setTimeout(() => resolve(), 1000))
})

test('foo', async () => {
  await new Promise((resolve) =>
    setTimeout(() => {
      resolve()
    }, 1000),
  )
})

test('foo', async () => {
  await new Promise((resolve) =>
    setTimeout(() => {
      resolve()
    }, 1000),
  )
})

test.concurrent('foo', ({ expect }) => {
  expect(1).toMatchSnapshot()
})

test.concurrent('foo', (context) => {
  context.expect(1).toBe(1)
})

// …
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import vitest from "@vitest/eslint-plugin";

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/no-done-callback": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "noDoneCallback": "error"
      }
    }
  }
}
```

## Related rules

- [jest/no-done-callback](https://lintradar.dev/rules/jest/no-done-callback.md): Disallow using a callback in asynchronous tests and hooks
- [vitest/warn-todo](https://lintradar.dev/rules/vitest/warn-todo.md): Disallow `.todo` usage
- [vitest/require-to-throw-message](https://lintradar.dev/rules/vitest/require-to-throw-message.md): Require toThrow() to be called with an error message
- [vitest/require-test-timeout](https://lintradar.dev/rules/vitest/require-test-timeout.md): Require tests to declare a timeout
- [vitest/require-mock-type-parameters](https://lintradar.dev/rules/vitest/require-mock-type-parameters.md): Enforce using type parameters with vitest mock functions
- [vitest/require-hook](https://lintradar.dev/rules/vitest/require-hook.md): Require setup and teardown to be within a hook

---

Web page: https://lintradar.dev/rules/vitest/no-done-callback. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
