# no-importing-vitest-globals

Rule `vitest/no-importing-vitest-globals`. Disallow importing Vitest globals

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```ts
import { test, expect } from 'vitest'

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

```ts
const { test, expect } = require('vitest')

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

### Correct: the rule accepts this

```ts
test('foo', () => {
  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-importing-vitest-globals": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/no-importing-vitest-globals": "error"
  }
}
```

## Related rules

- [vitest/no-conditional-tests](https://lintradar.dev/rules/vitest/no-conditional-tests.md): Disallow conditional tests
- [vitest/no-large-snapshots](https://lintradar.dev/rules/vitest/no-large-snapshots.md): Disallow large snapshots
- [vitest/no-conditional-in-test](https://lintradar.dev/rules/vitest/no-conditional-in-test.md): Disallow conditional tests
- [vitest/no-restricted-matchers](https://lintradar.dev/rules/vitest/no-restricted-matchers.md): Disallow the use of certain matchers
- [vitest/no-alias-methods](https://lintradar.dev/rules/vitest/no-alias-methods.md): Disallow alias methods
- [vitest/no-restricted-vi-methods](https://lintradar.dev/rules/vitest/no-restricted-vi-methods.md): Disallow specific `vi.` methods

---

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