Registry / testing / eslint-plugin-vitest-globals

eslint-plugin-vitest-globals

JSON →
library1.6.1jsnpmunverified

ESLint plugin that exposes all Vitest globals (describe, it, expect, vi, etc.) to ESLint without requiring an explicit eslint-plugin-vitest dependency. Current stable version is 1.6.1, released with support for ESLint 9+ Flat Config (flat/recommended, flat/base), TypeScript type definitions, and expanded globals including bench, benchmark, xtest, xit, xdescribe. Released as-needed with several minor bumps in 2023. Differentiators: lightweight (only handles globals), supports both classic and flat ESLint configs, and can be applied only to test files via overrides. Compatible with Node >=16.

npm install eslint-plugin-vitest-globals
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-VITE
E
eslint-plugin-vitest-globals
testingjavascriptv1.6.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin object (default import for flat config)
import vitestGlobals from 'eslint-plugin-vitest-globals'
const vitestGlobals = require('eslint-plugin-vitest-globals')
For Flat Config (ESLint 9+), use ESM import. In CommonJS projects with ESLint 8, require() works but is not recommended for new code.
configs['flat/recommended']
vitestGlobals.configs['flat/recommended']
vitestGlobals.configs.recommended
Flat config keys are named differently (prefixed with 'flat/') since v1.6.0. Classic config uses 'recommended' without prefix.
configs['recommended'] (Classic config)
"extends": ["plugin:vitest-globals/recommended"]
"extends": ["plugin:vitest-globals/flat/recommended"]
In classic .eslintrc format, use 'plugin:vitest-globals/recommended'. Do not include 'flat/' prefix.

Configures ESLint to recognize Vitest globals only in test files, using either classic or flat config.

// Install: npm install -D eslint eslint-plugin-vitest-globals // Classic .eslintrc.json (ESLint 8) { "overrides": [ { "files": ["**/__tests__/**/*.[jt]s?(x)", "**/*.test.[jt]s?(x)", "**/*.spec.[jt]s?(x)"], "extends": ["plugin:vitest-globals/recommended"] } ] } // Flat eslint.config.js (ESLint 9+) import vitestGlobals from 'eslint-plugin-vitest-globals'; export default [ { files: ['**/*.test.js', '**/*.spec.js'], ...vitestGlobals.configs['flat/recommended'] } ]; // Now Vitest globals like describe, it, expect are recognized in test files.
Debug
Known issues
breakingIn v1.6.0, flat config keys changed from 'flat/recommended' to require the full 'flat/recommended' path; previously there was no flat support.
fix
Upgrade to v1.6.0+ and use vitestGlobals.configs['flat/recommended'].
affects: <1.6.0
gotchaThis plugin only defines globals, it does not set up any rules. Users expecting rule enforcement must combine with eslint-plugin-vitest.
fix
Install eslint-plugin-vitest separately if you need Vitest-specific lint rules beyond globals.
affects: all
deprecatedUsing env: { 'vitest-globals/env': true } is still supported but less explicit than using the recommended config.
fix
Prefer extending the recommended config or using the flat config approach.
affects: >=1.0.0
gotchaThe plugin must be applied to test files only; applying globally may cause false positives in non-test code using 'describe' or 'it' as variable names.
fix
Always use overrides or files filters to restrict the plugin to test file patterns.
affects: all
breakingNode.js <16 is not supported as of v1.6.0 due to engine requirement.
fix
Upgrade Node.js to >=16 or pin to an older version of the plugin (not recommended).
affects: >=1.6.0
Errors
Common errors & fixes
ESLint: 'describe' is not defined. (no-undef)
ESLint does not recognize Vitest globals without this plugin's configuration.
fix
Add the plugin to ESLint config (recommended or environment) as shown in quickstart.
Failed to load config 'plugin:vitest-globals/recommended' from file...
Plugin not installed or ESLint cannot resolve it.
fix
Run 'npm install -D eslint-plugin-vitest-globals' and ensure it's in package.json.
Configuration for rule 'vitest-globals/...' not found
Trying to use a rule from this plugin, but it exposes only globals, not rules.
fix
Use eslint-plugin-vitest for rules; this plugin only provides globals.
Cannot find module 'eslint-plugin-vitest-globals' (ESLint 9 flat config)
In flat config, the plugin import path may be incorrect or CJS/ESM mismatch.
fix
Use dynamic import or ensure your eslint.config.js uses ESM syntax with 'import vitestGlobals from 'eslint-plugin-vitest-globals';'
Upgrade
Version history
1.6.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to use the plugin; must be installed separately
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-vitest-globals — npm install eslint-plugin-vitest-globals · libregistry