Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-jest-extended

jest-community431.9kMIT3.0.0

Eslint rules for Jest Extended

jest, eslint, eslintplugin, eslint-plugin, eslint-plugin-jest

readme

eslint-plugin-jest-extended

ESLint plugin for Jest Extended

Actions Status

Installation

$ yarn add --dev eslint eslint-plugin-jest-extended

Note: If you installed ESLint globally then you must also install eslint-plugin-jest-extended globally.

Usage

[!NOTE]

eslint.config.js is supported, though most of the plugin documentation still currently uses .eslintrc syntax.

Refer to the ESLint documentation on the new configuration file format for more.

Add jest-extended to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["jest-extended"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "jest-extended/prefer-to-be-true": "warn",
    "jest-extended/prefer-to-be-false": "error"
  }
}

Shareable configurations

This plugin does not export a recommended configuration, as the rules provided by this plugin are about enforcing usage of preferred matchers for particular patterns, rather than helping to prevent bugs & commonly overlooked traps.

All

If you want to enable all rules instead of only some you can do so by adding the all configuration to your .eslintrc config file:

{
  "extends": ["plugin:jest-extended/all"]
}

To enable this configuration with eslint.config.js, use jestExtended.configs['flat/all']:

const jestExtended = require('eslint-plugin-jest-extended');

module.exports = [
  {
    files: [
      /* glob matching your test files */
    ],
    ...jestExtended.configs['flat/all'],
  },
];

Note that the all configuration may change in any release and is thus unsuited for installations requiring long-term consistency.

Rules

🔧 Automatically fixable by the --fix CLI option.

Name Description 🔧
prefer-to-be-array Suggest using toBeArray() 🔧
prefer-to-be-false Suggest using toBeFalse() 🔧
prefer-to-be-object Suggest using toBeObject() 🔧
prefer-to-be-true Suggest using toBeTrue() 🔧
prefer-to-have-been-called-once Suggest using toHaveBeenCalledOnce() 🔧

Credit

eslint-plugin-jest

This project aims to provide linting rules to aid in writing tests using jest.

https://github.com/jest-community/eslint-plugin-jest

eslint-plugin-jest-formatting

This project aims to provide formatting rules (auto-fixable where possible) to ensure consistency and readability in jest test suites.

https://github.com/dangreenisrael/eslint-plugin-jest-formatting

changelog

3.0.0 (2025-01-17)

Features

  • adjust Node constraints to match eslint-plugin-jest (#235) (6d2414a)
  • drop support for Node v14 (#232) (fef65e0)
  • support @typescript-eslint/utils v7 & v8 (#241) (40766b0)
  • upgrade @typescript-eslint/utils to v6 (#238) (657bc42)

BREAKING CHANGES

  • Versions of Node v18 up to 18.11.x are no longer supported
  • drop support for Node v14

3.0.0-next.4 (2025-01-17)

Features

  • support @typescript-eslint/utils v7 & v8 (#241) (414dc8f)

3.0.0-next.3 (2025-01-16)

Features

  • upgrade @typescript-eslint/utils to v6 (#238) (3815685)

3.0.0-next.2 (2025-01-16)

Features

  • adjust Node constraints to match eslint-plugin-jest (#235) (c9fb39c)

BREAKING CHANGES

  • Versions of Node v18 up to 18.11.x are no longer supported

3.0.0-next.1 (2025-01-16)

Features

BREAKING CHANGES

  • drop support for Node v14

2.4.0 (2024-04-20)

Features

2.3.0 (2024-04-20)

Features

  • add should-be-fine support for flat configs (#181) (7d106b0)

2.2.0 (2024-04-19)

Features

  • support providing aliases for @jest/globals package (#180) (d070ca7)

2.1.0 (2024-04-19)

Features

2.0.3 (2024-04-19)

Bug Fixes

2.0.2 (2024-04-19)

Performance Improvements

  • use Set instead of iterating, and deduplicate a function (#175) (d0652cd)

2.0.1 (2024-04-19)

Performance Improvements

  • don't collect more info than needed when resolving jest functions (#172) (08e130c)

2.0.0 (2022-08-25)

Features

  • drop support for eslint@6 (#26) (d3d40f3)
  • drop support for Node versions 12 and 17 (#25) (14c90ed)

BREAKING CHANGES

  • Support for ESLint version 6 is removed
  • Node versions 12 and 17 are no longer supported

1.2.0 (2022-08-20)

Features

  • switch to new scope-based jest fn call parser to support @jest/globals (#20) (35ddfed)

1.1.0 (2022-08-20)

Features

  • create prefer-to-have-been-called-once rule (#19) (12e6372)

1.0.0 (2022-08-15)

Features

  • bunch of updates (#5) (8e45c68)
  • create prefer-to-be-array rule (9bd067c)
  • create prefer-to-be-false rule (b35e45c)
  • create prefer-to-be-object rule (676de1d)
  • create prefer-to-be-true rule (22f8093)
  • initial commit (3ed88c4)