Registry / testing / eslint-plugin-vitest

eslint-plugin-vitest

JSON →
library0.5.4jsnpmunverified

ESLint plugin for Vitest, providing test-specific linting rules. The latest stable version is 1.6.16, released on npm with type definitions included. This plugin helps enforce best practices in Vitest test suites, including rules for consistent naming, focused tests, and proper assertions. It supports both ESLint v8 (flat config and legacy) and v9. Key differentiators include type-testing support, a comprehensive set of rules (e.g., no-focused-tests, valid-expect), and compatibility with Vitest's chaining API. The plugin is actively maintained, with frequent releases addressing bugs and adding features. It requires ESLint >=8.57.0 and Vitest as peer dependencies.

npm install eslint-plugin-vitest
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-VITE
E
eslint-plugin-vitest
testingjavascriptv0.5.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

plugin (default)
✓ import vitest from 'eslint-plugin-vitest'
✗ const vitest = require('eslint-plugin-vitest')
Default import provides the plugin object with configs and rules. CJS require works in Node, but ESM is recommended since v1.
vitest.configs.recommended
✓ import vitest from 'eslint-plugin-vitest'; export default [...vitest.configs.recommended]
✗ import { recommended } from 'eslint-plugin-vitest'
Configs are accessed via the default import, not as named exports.
vitest.environments.env.globals
✓ import vitest from 'eslint-plugin-vitest'; globals: { ...vitest.environments.env.globals }
✗ import { environments } from 'eslint-plugin-vitest'
Globals are under the '.environments.env.globals' property. Named import of 'environments' is not available.
Rule: vitest/no-focused-tests
✓ rules: { 'vitest/no-focused-tests': 'error' }
✗ rules: { no-focused-tests: 'error' }
Rules must be prefixed with 'vitest/' in the config.

Flat config setup with recommended rules, preventing focused tests, and enabling typecheck support.

// Install: npm install --save-dev eslint eslint-plugin-vitest // eslint.config.js (ESLint v9 flat config) import vitest from 'eslint-plugin-vitest'; export default [ { files: ['**/*.test.js', '**/*.test.ts'], plugins: { vitest, }, rules: { ...vitest.configs.recommended.rules, 'vitest/no-focused-tests': 'error', }, settings: { vitest: { typecheck: true, // enable if using Vitest type-testing }, }, }, ];
Debug
Known issues
breakingESLint v9 flat config requires different plugin structure than legacy .eslintrc
fix
Use import vitest from 'eslint-plugin-vitest' and spread vitest.configs.recommended in flat config.
affects: >=1.0.0
deprecatedThe 'vitest/no-alias-methods' rule may have reversed alias direction in v1.6.12
fix
Check your usage: toThrow/toThrowError alias direction was fixed. Update code if needed.
affects: >=1.6.12
gotchaTypeScript type definitions are shipped but need '@typescript-eslint' for full integration
fix
Install and configure @typescript-eslint/parser and plugin to resolve type-aware rules.
affects: >=1.0.0
breakingPlugin requires ESLint >=8.57.0; older versions may not work
fix
Upgrade ESLint to v8.57.0+ or use v9+ for flat config.
affects: >=1.0.0
deprecatedThe 'all' config sets warn level; be aware if using spread
fix
Use 'recommended' instead of 'all' to avoid too many warnings.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'vitest' declared in '.eslintrc.json'
Plugin not installed or ESLint cannot find it
fix
Run 'npm install --save-dev eslint-plugin-vitest' and ensure node_modules includes it.
Definition for rule 'vitest/no-focused-tests' was not found
Using a rule that doesn't exist or incorrect plugin version
fix
Check rule name spelling; verify plugin version supports the rule (v1.0+ includes core rules).
TypeError: vitest.configs is not iterable
Incorrect import or usage in flat config; configs is an object, not array
fix
Use: export default [ ...vitest.configs.recommended ] or spread properly.
ESLint couldn't determine the plugin for rule 'vitest/expect-expect'
Plugin not specified in 'plugins' array or object
fix
Add 'vitest' in the flat config's plugins object: { plugins: { vitest } }
Upgrade
Version history
0.5.4latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; plugin extends ESLint's rule system
vitestrequiredPeer dependency; plugin lints Vitest test files
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-vitest — npm install eslint-plugin-vitest · libregistry