{"id":19809,"library":"eslint-plugin-jest","title":"eslint-plugin-jest","description":"ESLint plugin providing a comprehensive set of rules for Jest testing framework. Current stable version is 29.15.2 (April 2026). Active development with frequent releases (multiple per month). Key differentiators: official Jest community plugin, supports both flat and legacy ESLint configs, includes TypeScript support via optional peer dependency, offers aliased Jest globals and custom global package settings for use with other testing libraries (e.g., vitest, bun). Ships TypeScript type definitions.","status":"active","version":"29.15.2","language":"javascript","source_language":"en","source_url":"https://github.com/jest-community/eslint-plugin-jest","tags":["javascript","eslint","eslintplugin","eslint-plugin","typescript"],"install":[{"cmd":"npm install eslint-plugin-jest","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-jest","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-jest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for TypeScript-aware rules","package":"@typescript-eslint/eslint-plugin","optional":true},{"reason":"Core peer dependency for ESLint integration","package":"eslint","optional":false},{"reason":"Expected testing framework - plugin provides rules for Jest syntax","package":"jest","optional":true},{"reason":"Optional peer dependency for TypeScript support (>=4.8.4 <7.0.0)","package":"typescript","optional":true}],"imports":[{"note":"CommonJS is the primary import style due to ESLint's CJS core. ESM users should use dynamic import or await import('eslint-plugin-jest').","wrong":"import pluginJest from 'eslint-plugin-jest' (CJS default in flat config works, but ESM users need dynamic import)","symbol":"default","correct":"const pluginJest = require('eslint-plugin-jest')"},{"note":"For flat config (eslint.config.js), use string key 'flat/recommended'. For legacy .eslintrc, use 'plugin:jest/recommended'.","wrong":"module.exports = ['plugin:jest/recommended'] (this is for legacy .eslintrc configs)","symbol":"flat/recommended","correct":"const jestPlugin = require('eslint-plugin-jest'); module.exports = [...jestPlugin.configs['flat/recommended']]"},{"note":"The environment object has a 'globals' property containing the globals map, and that map has a 'globals' key with the actual globals object.","wrong":"environments.globals (missing .globals access)","symbol":"environments","correct":"const { environments } = require('eslint-plugin-jest'); globals: environments.globals.globals"}],"quickstart":{"code":"const jestPlugin = require('eslint-plugin-jest');\n\nmodule.exports = [\n  {\n    files: ['**/*.test.js', '**/*.spec.js'],\n    plugins: { jest: jestPlugin },\n    languageOptions: {\n      globals: jestPlugin.environments.globals.globals,\n    },\n    rules: {\n      'jest/no-disabled-tests': 'warn',\n      'jest/no-focused-tests': 'error',\n      'jest/no-identical-title': 'error',\n    },\n  },\n];","lang":"javascript","description":"Sets up eslint-plugin-jest with flat config, enabling three common rules on test files."},"warnings":[{"fix":"Migrate to eslint.config.js using flat config format. See README for examples.","message":"ESLint v9+ requires flat config; legacy .eslintrc config is deprecated.","severity":"breaking","affected_versions":">=29.0.0"},{"fix":"Install typescript as a devDependency if using TypeScript rules: npm install --save-dev typescript.","message":"TypeScript peer dependency is optional but required for TypeScript-specific rules (e.g., valid-describe-callback).","severity":"gotcha","affected_versions":">=29.12.2"},{"fix":"Use settings.jest.globalAliases instead of top-level globalAliases.","message":"The 'globalAliases' setting in legacy config is deprecated in favor of 'settings.jest.globalAliases'.","severity":"deprecated","affected_versions":">=28.0.0"},{"fix":"Always scope the plugin's rules to test file patterns using 'files' in flat config or 'overrides' in legacy config.","message":"Rules only apply to test files; including them in top-level config will lint source files.","severity":"gotcha","affected_versions":"all"},{"fix":"Add globals: jestPlugin.environments.globals.globals to your flat config's languageOptions.","message":"Plugin no longer auto-enables globals; must explicitly set languageOptions.globals in flat config.","severity":"breaking","affected_versions":">=29.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 eslint-plugin-jest --save-dev' to install it.","cause":"Missing or incorrect installation of the plugin.","error":"Error: Failed to load plugin 'jest': Cannot find module 'eslint-plugin-jest'"},{"fix":"Use 'warn' (string) is actually allowed, but ensure you're not using a number like 1. If using shared configs, they may map to numbers. Use 'warn' or 'error' as strings.","cause":"Using 'warn' in flat config; flat config requires severity numbers or 'error'/'warn' as strings but only in certain contexts.","error":"Configuration for rule 'jest/no-disabled-tests' is invalid: Value \"warn\" is invalid."},{"fix":"In flat config, use jestPlugin.configs['flat/recommended'] instead of the string 'plugin:jest/recommended'.","cause":"Trying to use 'plugin:jest/recommended' in flat config (eslint.config.js).","error":"ESLint couldn't find the config 'plugin:jest/recommended'."},{"fix":"Use CommonJS require syntax or ensure your config file is .js and uses module.exports.","cause":"Using ES6 syntax in a file that ESLint's parser doesn't recognize as modern JavaScript (e.g., .eslintrc.json doesn't support it).","error":"Parsing error: The keyword 'const' is reserved"},{"fix":"Access as jestPlugin.environments.globals.globals (property access).","cause":"Assuming environments.globals() is a function when it's an object.","error":"TypeError: jestPlugin.environments.globals is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}