# consistent-each-for

Rule `vitest/consistent-each-for`. Enforce using `.each` or `.for` consistently

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
// { test: 'for' }
test.each([[1, 1, 2]])('test', (a, b, expected) => {
  expect(a + b).toBe(expected)
})
```

```js
// { describe: 'for' }
describe.each([[1], [2]])('suite %s', (n) => {
  test('test', () => {})
})
```

```js
// { test: 'each' }
test.for([[1, 1, 2]])('test', ([a, b, expected]) => {
  expect(a + b).toBe(expected)
})
```

### Correct: the rule accepts this

```js
// { test: 'for' }
test.for([[1, 1, 2]])('test', ([a, b, expected]) => {
  expect(a + b).toBe(expected)
})
```

```js
// { describe: 'for' }
describe.for([[1], [2]])('suite %s', ([n]) => {
  test('test', () => {})
})
```

```js
// { test: 'each' }
test.each([[1, 1, 2]])('test', (a, b, expected) => {
  expect(a + b).toBe(expected)
})
```

Examples from the ESLint documentation.

## Enable it

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

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

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

### Oxlint: `.oxlintrc.json`

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

## Related rules

- [vitest/consistent-test-filename](https://lintradar.dev/rules/vitest/consistent-test-filename.md): Require test file pattern
- [vitest/consistent-vitest-vi](https://lintradar.dev/rules/vitest/consistent-vitest-vi.md): Enforce using vitest or vi but not both
- [vitest/hoisted-apis-on-top](https://lintradar.dev/rules/vitest/hoisted-apis-on-top.md): Enforce hoisted APIs to be on top of the file
- [vitest/max-expects](https://lintradar.dev/rules/vitest/max-expects.md): Enforce a maximum number of expect per test
- [vitest/no-alias-methods](https://lintradar.dev/rules/vitest/no-alias-methods.md): Disallow alias methods
- [vitest/no-conditional-in-test](https://lintradar.dev/rules/vitest/no-conditional-in-test.md): Disallow conditional tests

---

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