Skip to content

willemorvets/eslint-plugin-jest-extended

 
 

Repository files navigation

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

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

Recommended

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"]
}

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

Related Projects

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

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.9%
  • JavaScript 4.9%
  • Shell 0.2%