eslint-plugin-jest

raw JSON →
29.15.2 verified Sat Apr 25 auth: no javascript

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.

error Error: Failed to load plugin 'jest': Cannot find module 'eslint-plugin-jest'
cause Missing or incorrect installation of the plugin.
fix
Run 'npm install eslint-plugin-jest --save-dev' to install it.
error Configuration for rule 'jest/no-disabled-tests' is invalid: Value "warn" is invalid.
cause Using 'warn' in flat config; flat config requires severity numbers or 'error'/'warn' as strings but only in certain contexts.
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.
error ESLint couldn't find the config 'plugin:jest/recommended'.
cause Trying to use 'plugin:jest/recommended' in flat config (eslint.config.js).
fix
In flat config, use jestPlugin.configs['flat/recommended'] instead of the string 'plugin:jest/recommended'.
error Parsing error: The keyword 'const' is reserved
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).
fix
Use CommonJS require syntax or ensure your config file is .js and uses module.exports.
error TypeError: jestPlugin.environments.globals is not a function
cause Assuming environments.globals() is a function when it's an object.
fix
Access as jestPlugin.environments.globals.globals (property access).
breaking ESLint v9+ requires flat config; legacy .eslintrc config is deprecated.
fix Migrate to eslint.config.js using flat config format. See README for examples.
gotcha TypeScript peer dependency is optional but required for TypeScript-specific rules (e.g., valid-describe-callback).
fix Install typescript as a devDependency if using TypeScript rules: npm install --save-dev typescript.
deprecated The 'globalAliases' setting in legacy config is deprecated in favor of 'settings.jest.globalAliases'.
fix Use settings.jest.globalAliases instead of top-level globalAliases.
gotcha Rules only apply to test files; including them in top-level config will lint source files.
fix Always scope the plugin's rules to test file patterns using 'files' in flat config or 'overrides' in legacy config.
breaking Plugin no longer auto-enables globals; must explicitly set languageOptions.globals in flat config.
fix Add globals: jestPlugin.environments.globals.globals to your flat config's languageOptions.
npm install eslint-plugin-jest
yarn add eslint-plugin-jest
pnpm add eslint-plugin-jest

Sets up eslint-plugin-jest with flat config, enabling three common rules on test files.

const jestPlugin = require('eslint-plugin-jest');

module.exports = [
  {
    files: ['**/*.test.js', '**/*.spec.js'],
    plugins: { jest: jestPlugin },
    languageOptions: {
      globals: jestPlugin.environments.globals.globals,
    },
    rules: {
      'jest/no-disabled-tests': 'warn',
      'jest/no-focused-tests': 'error',
      'jest/no-identical-title': 'error',
    },
  },
];