back to home

jest-community / eslint-plugin-jest

ESLint plugin for Jest

View on GitHub
1,167 stars
248 forks
29 issues

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing jest-community/eslint-plugin-jest in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/jest-community/eslint-plugin-jest)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

eslint-plugin-jest ESLint plugin for Jest Installation **Note:** If you installed ESLint globally then you must also install globally. Usage If you're using flat configuration: With flat configuration, just import the plugin and away you go: With legacy configuration, add to the plugins section of your configuration file. You can omit the prefix: > [!NOTE] > > You only need to explicitly include our globals if you're not using one of our > shared configs Aliased Jest globals You can tell this plugin about any global Jests you have aliased using the setting: Aliased You can tell this plugin to treat a different package as the source of Jest globals using the setting: > [!WARNING] > > While this can be used to apply rules when using alternative testing libraries > and frameworks like , and , there's no guarantee the > semantics this plugin assumes will hold outside of Jest Running rules only on test-related files The rules provided by this plugin assume that the files they are checking are test-related. This means it's generally not suitable to include them in your top-level configuration as that applies to all files being linted which can include source files. For configs you can use overrides to have ESLint apply additional rules to specific files: For you can use and : Jest setting The behaviour of some rules (specifically [ ][]) change depending on the version of Jest being used. By default, this plugin will attempt to determine to locate Jest using , meaning it will start looking in the closest folder to the file being linted and work its way up. Since we cache the automatically determined version, if you're linting sub-folders that have different versions of Jest, you may find that the wrong version of Jest is considered when linting. You can work around this by providing the Jest version explicitly in nested ESLint configs: To avoid hard-coding a number, you can also fetch it from the installed version of Jest if you use a JavaScript config file such as : Shareable configurations > [!NOTE] > > compatible versions of configs are available prefixed with > and may be subject to small breaking changes while ESLint v9 is being > finalized. Recommended This plugin exports a recommended configuration that enforces good testing practices. To enable this configuration with , use the property: To enable this configuration with , use : Style This plugin also exports a configuration named , which adds some stylistic rules, such as , which enforces usage of over . To enable this configuration use the property in your config file: To enable this configuration with , use : All If you want to enable all rules instead of only some you can do so by adding the configuration to your config file: To enable this configuration with , use : While the and configurations only change in major versions the configuration may change in any release and is thus unsuited for installations requiring long-term consistency. Rules 💼 Configurations enabled in.\ ⚠️ Configurations set to warn in.\ ✅ Set in the configuration.\ 🎨 Set in the configuration.\ 🔧 Automatically fixable by the CLI option.\ 💡 Manually fixable by editor suggestions. | Name                              | Description | 💼 | ⚠️ | 🔧 | 💡 | | :----------------------------------------------------------------------------------- | :------------------------------------------------------------------------ | :-- | :-- | :-- | :-- | | consistent-test-it | Enforce and usage conventions | | | 🔧 | | | expect-expect | Enforce assertion to be made in a test body | | ✅ | | | | max-expects | Enforces a maximum number assertion calls in a test body | | | | | | max-nested-describe | Enforces a maximum depth to nested describe calls | | | | | | no-alias-methods | Disallow alias methods | ✅ | | 🔧 | | | no-commented-out-tests | Disallow commented out tests | | ✅ | | | | no-conditional-expect | Disallow calling conditionally | ✅ | | | | | no-conditional-in-test | Disallow conditional logic in tests | | | | | | no-confusing-set-timeout | Disallow confusing usages of jest.setTimeout | | | | | | no-deprecated-functions | Disallow use of deprecated functions | ✅ | | 🔧 | | | no-disabled-tests | Disallow disabled tests | | ✅ | | | | no-done-callback | Disallow using a callback in asynchronous tests and hooks | ✅ | | | 💡 | | no-duplicate-hooks | Disallow duplicate setup and teardown hooks | | | | | | no-export | Disallow using in files containing tests | ✅ | | | | | no-focused-tests | Disallow focused tests | ✅ | | | 💡 | | no-hooks | Disallow setup and teardown hooks | | | | | | no-identical-title | Disallow identical titles | ✅ | | | | | no-interpolation-in-snapshots | Disallow string interpolation inside snapshots | ✅ | | | | | no-jasmine-globals | Disallow Jasmine globals | ✅ | | 🔧 | | | no-large-snapshots | Disallow large snapshots | | | | | | no-mocks-import | Disallow manually importing from | ✅ | | | | | no-restricted-jest-methods | Disallow specific methods | | | | | | no-restricted-matchers | Disallow specific matchers & modifiers | | | | | | no-standalone-expect | Disallow using outside of or blocks | ✅ | | | | | no-test-prefixes | Require using and over and | ✅ | | 🔧 | | | no-test-return-statement | Disallow explicitly returning from tests | | | | | | no-unneeded-async-expect-function | Disallow unnecessary async function wrapper for expected promises | | | 🔧 | | | no-untyped-mock-factory | Disallow using factories without an explicit type parameter | | | 🔧 | | | padding-around-after-all-blocks | Enforce padding around blocks | | | 🔧 | | | padding-around-after-each-blocks | Enforce padding around blocks | | | 🔧 | | | padding-around-all | Enforce padding around Jest functions | | | 🔧 | | | padding-around-before-all-blocks | Enforce padding around blocks | | | 🔧 | | | padding-around-before-each-blocks | Enforce padding around blocks | | | 🔧 | | | padding-around-describe-blocks | Enforce padding around bloc…