# require-hook

Rule `vitest/require-hook`. Require setup and teardown to be within a hook

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1808 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/require-hook` | no | no | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md) |
| Oxlint | `vitest/require-hook` | no | no | plugin `vitest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-hook.html) |

## Enable it

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

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

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/require-hook": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/require-hook": "error"
  }
}
```

## Related rules

- [jest/require-hook](https://lintradar.dev/rules/jest/require-hook.md): Require setup and teardown code to be within a hook
- [vitest/require-awaited-expect-poll](https://lintradar.dev/rules/vitest/require-awaited-expect-poll.md): Ensure that every `expect.poll` call is awaited
- [vitest/require-mock-type-parameters](https://lintradar.dev/rules/vitest/require-mock-type-parameters.md): Enforce using type parameters with vitest mock functions
- [vitest/prefer-todo](https://lintradar.dev/rules/vitest/prefer-todo.md): Enforce using `test.todo`
- [vitest/require-test-timeout](https://lintradar.dev/rules/vitest/require-test-timeout.md): Require tests to declare a timeout
- [vitest/prefer-to-be-truthy](https://lintradar.dev/rules/vitest/prefer-to-be-truthy.md): Enforce using `toBeTruthy`

---

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