# prefer-each

Rule `vitest/prefer-each`. Enforce using `each` rather than manual loops

- 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: #1793 by reach

## Linters

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

## Enable it

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

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/prefer-each": "error"
  }
}
```

## Related rules

- [jest/prefer-each](https://lintradar.dev/rules/jest/prefer-each.md): Prefer using `.each` rather than manual loops
- [vitest/prefer-comparison-matcher](https://lintradar.dev/rules/vitest/prefer-comparison-matcher.md): Enforce using the built-in comparison matchers
- [vitest/prefer-expect-assertions](https://lintradar.dev/rules/vitest/prefer-expect-assertions.md): Enforce using expect assertions instead of callbacks
- [vitest/prefer-called-once](https://lintradar.dev/rules/vitest/prefer-called-once.md): Enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()`
- [vitest/prefer-expect-resolves](https://lintradar.dev/rules/vitest/prefer-expect-resolves.md): Enforce using `expect().resolves` over `expect(await ...)` syntax
- [vitest/padding-around-test-blocks](https://lintradar.dev/rules/vitest/padding-around-test-blocks.md): Enforce padding around `test` blocks

---

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