{"id":19975,"library":"eslint-plugin-vitest","title":"eslint-plugin-vitest","description":"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.","status":"active","version":"0.5.4","language":"javascript","source_language":"en","source_url":"https://github.com/veritem/eslint-plugin-vitest","tags":["javascript","eslint","eslintplugin","eslint-plugin","vitest eslint plugin","vitest","eslint plugin","typescript"],"install":[{"cmd":"npm install eslint-plugin-vitest","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-vitest","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-vitest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin extends ESLint's rule system","package":"eslint","optional":false},{"reason":"Peer dependency; plugin lints Vitest test files","package":"vitest","optional":false}],"imports":[{"note":"Default import provides the plugin object with configs and rules. CJS require works in Node, but ESM is recommended since v1.","wrong":"const vitest = require('eslint-plugin-vitest')","symbol":"plugin (default)","correct":"import vitest from 'eslint-plugin-vitest'"},{"note":"Configs are accessed via the default import, not as named exports.","wrong":"import { recommended } from 'eslint-plugin-vitest'","symbol":"vitest.configs.recommended","correct":"import vitest from 'eslint-plugin-vitest'; export default [...vitest.configs.recommended]"},{"note":"Globals are under the '.environments.env.globals' property. Named import of 'environments' is not available.","wrong":"import { environments } from 'eslint-plugin-vitest'","symbol":"vitest.environments.env.globals","correct":"import vitest from 'eslint-plugin-vitest'; globals: { ...vitest.environments.env.globals }"},{"note":"Rules must be prefixed with 'vitest/' in the config.","wrong":"rules: { no-focused-tests: 'error' }","symbol":"Rule: vitest/no-focused-tests","correct":"rules: { 'vitest/no-focused-tests': 'error' }"}],"quickstart":{"code":"// Install: npm install --save-dev eslint eslint-plugin-vitest\n\n// eslint.config.js (ESLint v9 flat config)\nimport vitest from 'eslint-plugin-vitest';\n\nexport default [\n  {\n    files: ['**/*.test.js', '**/*.test.ts'],\n    plugins: {\n      vitest,\n    },\n    rules: {\n      ...vitest.configs.recommended.rules,\n      'vitest/no-focused-tests': 'error',\n    },\n    settings: {\n      vitest: {\n        typecheck: true, // enable if using Vitest type-testing\n      },\n    },\n  },\n];","lang":"javascript","description":"Flat config setup with recommended rules, preventing focused tests, and enabling typecheck support."},"warnings":[{"fix":"Use import vitest from 'eslint-plugin-vitest' and spread vitest.configs.recommended in flat config.","message":"ESLint v9 flat config requires different plugin structure than legacy .eslintrc","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Check your usage: toThrow/toThrowError alias direction was fixed. Update code if needed.","message":"The 'vitest/no-alias-methods' rule may have reversed alias direction in v1.6.12","severity":"deprecated","affected_versions":">=1.6.12"},{"fix":"Install and configure @typescript-eslint/parser and plugin to resolve type-aware rules.","message":"TypeScript type definitions are shipped but need '@typescript-eslint' for full integration","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade ESLint to v8.57.0+ or use v9+ for flat config.","message":"Plugin requires ESLint >=8.57.0; older versions may not work","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'recommended' instead of 'all' to avoid too many warnings.","message":"The 'all' config sets warn level; be aware if using spread","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev eslint-plugin-vitest' and ensure node_modules includes it.","cause":"Plugin not installed or ESLint cannot find it","error":"Error: Failed to load plugin 'vitest' declared in '.eslintrc.json'"},{"fix":"Check rule name spelling; verify plugin version supports the rule (v1.0+ includes core rules).","cause":"Using a rule that doesn't exist or incorrect plugin version","error":"Definition for rule 'vitest/no-focused-tests' was not found"},{"fix":"Use: export default [ ...vitest.configs.recommended ] or spread properly.","cause":"Incorrect import or usage in flat config; configs is an object, not array","error":"TypeError: vitest.configs is not iterable"},{"fix":"Add 'vitest' in the flat config's plugins object: { plugins: { vitest } }","cause":"Plugin not specified in 'plugins' array or object","error":"ESLint couldn't determine the plugin for rule 'vitest/expect-expect'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}