# no-restricted-vi-methods

Rule `vitest/no-restricted-vi-methods`. Disallow specific `vi.` methods

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
vi.useFakeTimers()
it('calls the callback after 1 second via advanceTimersByTime', () => {
  // ...

  vi.advanceTimersByTime(1000)

  // ...
})

test('plays video', () => {
  const spy = vi.spyOn(video, 'play')

  // ...
})
```

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-restricted-vi-methods": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/no-restricted-vi-methods": "error"
  }
}
```

## Related rules

- [vitest/no-restricted-matchers](https://lintradar.dev/rules/vitest/no-restricted-matchers.md): Disallow the use of certain matchers
- [vitest/no-test-prefixes](https://lintradar.dev/rules/vitest/no-test-prefixes.md): Disallow using the `f` and `x` prefixes in favour of `.only` and `.skip`
- [vitest/no-large-snapshots](https://lintradar.dev/rules/vitest/no-large-snapshots.md): Disallow large snapshots
- [vitest/padding-around-after-all-blocks](https://lintradar.dev/rules/vitest/padding-around-after-all-blocks.md): Enforce padding around `afterAll` blocks
- [vitest/no-importing-vitest-globals](https://lintradar.dev/rules/vitest/no-importing-vitest-globals.md): Disallow importing Vitest globals
- [vitest/padding-around-after-each-blocks](https://lintradar.dev/rules/vitest/padding-around-after-each-blocks.md): Enforce padding around `afterEach` blocks

---

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