ESLint plugin designed to enforce best practices and catch common mistakes when using jest-dom matchers (like toBeChecked, toHaveAttribute) in Testing Library tests. The current stable version is 5.5.0, released in November 2024, with releases every few months. It supports ESLint v6–v9 and provides a recommended configuration as well as flat configs for the new ESLint configuration system. Unlike generic lint rules, this plugin is specifically tailored to the jest-dom API, offering autofixable rules and suggestions to improve test quality. It ships TypeScript definitions and makes @testing-library/dom an optional peer dependency.
npm install eslint-plugin-jest-domVerified import paths — ran on the pinned version, not inferred.
Shows how to install and configure eslint-plugin-jest-dom using both legacy .eslintrc and flat config, enabling recommended rules and custom rules.
Install @testing-library/dom@^8.0.0 || ^9.0.0; or upgrade to v5.1.0+ where it's optional
Watch the changelog and test your config after ESLint updates
Use require('eslint-plugin-jest-dom') without .defaultUpgrade to v5.1.1+ which fixes false positives for variable property names
Upgrade to v5.5.0+ or use @types/eslint-plugin-jest-dom if available
Run 'npm install --save-dev eslint-plugin-jest-dom'
Run 'npm install --save-dev @testing-library/dom@^9.0.0' or upgrade the plugin to v5.1.0+
Use the config via the plugin object: const jestDom = require('eslint-plugin-jest-dom'); ...jestDom.configs['flat/recommended']; or upgrade to v5.2.0+