# Jest style

A few rules that keep Jest assertions consistent, such as preferring toHaveLength.

- Linter: ESLint
- Package: `eslint-plugin-jest` (https://github.com/jest-community/eslint-plugin-jest#style)
- Author: jest-community (official)
- Rules: 3
- Weekly downloads: 16.7M, +10.1% last quarter
- Technologies: testing (3)

## Install

```sh
npm install -D eslint eslint-plugin-jest
pnpm add -D eslint eslint-plugin-jest
yarn add -D eslint eslint-plugin-jest
bun add -d eslint eslint-plugin-jest
```

## Config: `eslint.config.js`

```js
// eslint.config.js
import jest from "eslint-plugin-jest";

export default [
  jest.configs["flat/style"],
];
```

## Rules it enables

| Rule | Severity | Description | Reach |
| --- | --- | --- | --- |
| [jest/prefer-to-contain](https://lintradar.dev/rules/jest/prefer-to-contain.md) | error | Suggest using `toContain()` | 4.2M |
| [jest/prefer-to-have-length](https://lintradar.dev/rules/jest/prefer-to-have-length.md) | error | Suggest using `toHaveLength()` | 4.2M |
| [jest/prefer-to-be](https://lintradar.dev/rules/jest/prefer-to-be.md) | error | Suggest using `toBe()` for primitive literals | 4.2M |

---

Web page: https://lintradar.dev/presets/jest-style. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
