vitest/prefer-importing-vitest-globals
January 2, 2026 ยท View on GitHub
๐ Enforce importing Vitest globals.
โ ๏ธ This rule warns in the ๐ all config.
๐ง This rule is automatically fixable by the --fix CLI option.
โ ๏ธ This rule warns in the ๐ all config.
๐ง This rule is automatically fixable by the --fix CLI option.
Rule Details
This rule enforces importing Vitest globals.
Examples of incorrect code for this rule:
test('foo', () => {
expect(1).toBe(1)
})
Examples of correct code for this rule:
import { test, expect } from 'vitest'
test('foo', () => {
expect(1).toBe(1)
})
const { test, expect } = require('vitest')
test('foo', () => {
expect(1).toBe(1)
})