Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-jest-extended

Package Overview
Dependencies
Maintainers
8
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jest-extended

Eslint rules for Jest Extended

  • 2.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
83K
increased by21.96%
Maintainers
8
Weekly downloads
 
Created
Source

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.

NameDescription🔧
prefer-to-be-arraySuggest using toBeArray()🔧
prefer-to-be-falseSuggest using toBeFalse()🔧
prefer-to-be-objectSuggest using toBeObject()🔧
prefer-to-be-trueSuggest using toBeTrue()🔧
prefer-to-have-been-called-onceSuggest 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

Keywords

FAQs

Package last updated on 20 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc