talira

eslint-plugin-jest

ESLint rules for Jest tests

open sourceMITfree

eslint-plugin-jest adds about 70 rules for Jest test files to ESLint: catching focused or disabled tests, duplicate test titles and invalid expect calls, and preferring clearer matchers. It ships recommended and style configs for flat and legacy configuration, some rules use TypeScript type information, and it can be pointed at other test frameworks such as Vitest or Bun's test runner, though its rules assume Jest's semantics.

Problems it solves

  • stop a focused or skipped Jest test from being committed
  • lint Jest test files for common mistakes
  • enforce consistent Jest matchers across a JavaScript project

Features

  • about 70 lint rules for Jest test files
  • recommended, style and all configs for flat and legacy ESLint configuration
  • rules that use TypeScript type information
  • configurable for other test frameworks such as Vitest and Bun

Limitations

  • Its rules assume Jest's semantics, so they may not hold when applied to other test frameworks.1
  • Its rules assume the files they check are test files, so it shouldn't run on every source file.1

Alternatives

The same job

These do what eslint-plugin-jest does.

  1. RuboCop RSpec RuboCop extension with cops for RSpec test files
  2. actionlint Static checker for GitHub Actions workflow files
  3. eslint-plugin-react React-specific linting rules for ESLint
  4. yamllint A linter for YAML files
  5. ESLint Find and fix problems in your JavaScript code.
  6. Credo Static code analysis for Elixir, with a focus on teaching and code consistency

Compare eslint-plugin-jest with the top 3