eslint-plugin-jest
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@typescript-eslint/utils | 5.62.0 | 77.45 kB | MIT | prod | |
eslint | 8.57.0 | 2.9 MB | MIT | prod peer |
eslint-plugin-jest
is a powerful tool that provides specific ESLint rules for Jest, a widely used JavaScript testing framework. This plugin helps enforce best practices and code styling conventions while writing Jest tests, ensuring clean and readable codebase. It can automatically fix some rule violations and provides various configurations to tailor rule sets to fit specific project requirements.
To use eslint-plugin-jest
, start by installing it in your project alongside ESLint. You can do this using yarn by running:
yarn add --dev eslint eslint-plugin-jest
If ESLint is installed globally, eslint-plugin-jest
should also be installed globally.
The plugin is integrated into the ESLint configuration by adding 'jest' to the plugins section of the .eslintrc configuration file like so:
{
"plugins": ["jest"]
}
You can then configure specific rules under the rules section. For example:
{
"rules": {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
}
}
Remember to tell ESLint about the environment variables provided by Jest, which can be done as follows:
{
"env": {
"jest/globals": true
}
}
You can find detailed information on all rule sets, configurations, usage instructions, and more in the official eslint-plugin-jest documentation.
The eslint-plugin-jest
documentation is located in the project’s GitHub repository. You can conveniently access it at eslint-plugin-jest GitHub repo. The docs contain detailed information about installation, usage, different ESLint rules that the plugin provides, and configurations to customize them as per your project needs. Each rule in the list links to a separate document detailing what the rule does, how it works, and how to configure it.