{"id":19973,"library":"eslint-plugin-vitest-globals","title":"eslint-plugin-vitest-globals","description":"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.","status":"active","version":"1.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/saqqdy/eslint-plugin-vitest-globals","tags":["javascript","vitest","vitest-globals","vitest-env","vitest-eslint","eslint-plugin","eslint-plugin-vitest","eslint-plugin-vitest-globals","eslint","typescript"],"install":[{"cmd":"npm install eslint-plugin-vitest-globals","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-vitest-globals","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-vitest-globals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to use the plugin; must be installed separately","package":"eslint","optional":false}],"imports":[{"note":"For Flat Config (ESLint 9+), use ESM import. In CommonJS projects with ESLint 8, require() works but is not recommended for new code.","wrong":"const vitestGlobals = require('eslint-plugin-vitest-globals')","symbol":"plugin object (default import for flat config)","correct":"import vitestGlobals from 'eslint-plugin-vitest-globals'"},{"note":"Flat config keys are named differently (prefixed with 'flat/') since v1.6.0. Classic config uses 'recommended' without prefix.","wrong":"vitestGlobals.configs.recommended","symbol":"configs['flat/recommended']","correct":"vitestGlobals.configs['flat/recommended']"},{"note":"In classic .eslintrc format, use 'plugin:vitest-globals/recommended'. Do not include 'flat/' prefix.","wrong":"\"extends\": [\"plugin:vitest-globals/flat/recommended\"]","symbol":"configs['recommended'] (Classic config)","correct":"\"extends\": [\"plugin:vitest-globals/recommended\"]"}],"quickstart":{"code":"// Install: npm install -D eslint eslint-plugin-vitest-globals\n\n// Classic .eslintrc.json (ESLint 8)\n{\n  \"overrides\": [\n    {\n      \"files\": [\"**/__tests__/**/*.[jt]s?(x)\", \"**/*.test.[jt]s?(x)\", \"**/*.spec.[jt]s?(x)\"],\n      \"extends\": [\"plugin:vitest-globals/recommended\"]\n    }\n  ]\n}\n\n// Flat eslint.config.js (ESLint 9+)\nimport vitestGlobals from 'eslint-plugin-vitest-globals';\nexport default [\n  {\n    files: ['**/*.test.js', '**/*.spec.js'],\n    ...vitestGlobals.configs['flat/recommended']\n  }\n];\n\n// Now Vitest globals like describe, it, expect are recognized in test files.","lang":"javascript","description":"Configures ESLint to recognize Vitest globals only in test files, using either classic or flat config."},"warnings":[{"fix":"Upgrade to v1.6.0+ and use vitestGlobals.configs['flat/recommended'].","message":"In v1.6.0, flat config keys changed from 'flat/recommended' to require the full 'flat/recommended' path; previously there was no flat support.","severity":"breaking","affected_versions":"<1.6.0"},{"fix":"Install eslint-plugin-vitest separately if you need Vitest-specific lint rules beyond globals.","message":"This plugin only defines globals, it does not set up any rules. Users expecting rule enforcement must combine with eslint-plugin-vitest.","severity":"gotcha","affected_versions":"all"},{"fix":"Prefer extending the recommended config or using the flat config approach.","message":"Using env: { 'vitest-globals/env': true } is still supported but less explicit than using the recommended config.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always use overrides or files filters to restrict the plugin to test file patterns.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Node.js to >=16 or pin to an older version of the plugin (not recommended).","message":"Node.js <16 is not supported as of v1.6.0 due to engine requirement.","severity":"breaking","affected_versions":">=1.6.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add the plugin to ESLint config (recommended or environment) as shown in quickstart.","cause":"ESLint does not recognize Vitest globals without this plugin's configuration.","error":"ESLint: 'describe' is not defined. (no-undef)"},{"fix":"Run 'npm install -D eslint-plugin-vitest-globals' and ensure it's in package.json.","cause":"Plugin not installed or ESLint cannot resolve it.","error":"Failed to load config 'plugin:vitest-globals/recommended' from file..."},{"fix":"Use eslint-plugin-vitest for rules; this plugin only provides globals.","cause":"Trying to use a rule from this plugin, but it exposes only globals, not rules.","error":"Configuration for rule 'vitest-globals/...' not found"},{"fix":"Use dynamic import or ensure your eslint.config.js uses ESM syntax with 'import vitestGlobals from 'eslint-plugin-vitest-globals';'","cause":"In flat config, the plugin import path may be incorrect or CJS/ESM mismatch.","error":"Cannot find module 'eslint-plugin-vitest-globals' (ESLint 9 flat config)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}