Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jest-community/eslint-plugin-jest-extended
Eslint plugin for https://github.com/jest-community/jest-extended
https://github.com/jest-community/eslint-plugin-jest-extended
Last synced: 3 months ago
JSON representation
Eslint plugin for https://github.com/jest-community/jest-extended
- Host: GitHub
- URL: https://github.com/jest-community/eslint-plugin-jest-extended
- Owner: jest-community
- License: mit
- Created: 2020-02-26T20:26:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T11:55:18.000Z (7 months ago)
- Last Synced: 2024-04-14T02:48:44.957Z (7 months ago)
- Language: TypeScript
- Size: 8.26 MB
- Stars: 20
- Watchers: 5
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jest - eslint-plugin-jest-extended - extended](https://github.com/jest-community/jest-extended). (Packages / Linting)
README
[![Actions Status](https://github.com/jest-community/eslint-plugin-jest-extended/workflows/Unit%20tests%20%26%20Release/badge.svg?branch=main)](https://github.com/jest-community/eslint-plugin-jest-extended/actions)
## 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](https://eslint.org/docs/latest/use/configure/configuration-files-new)
> for more.Add `jest-extended` to the plugins section of your `.eslintrc` configuration
file. You can omit the `eslint-plugin-` prefix:```json
{
"plugins": ["jest-extended"]
}
```Then configure the rules you want to use under the rules section.
```json
{
"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:```json
{
"extends": ["plugin:jest-extended/all"]
}
```To enable this configuration with `eslint.config.js`, use
`jestExtended.configs['flat/all']`:```js
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](https://eslint.org/docs/user-guide/command-line-interface#--fix).| Name | Description | 🔧 |
| :------------------------------------------------------------------------------- | :------------------------------------- | :-- |
| [prefer-to-be-array](docs/rules/prefer-to-be-array.md) | Suggest using `toBeArray()` | 🔧 |
| [prefer-to-be-false](docs/rules/prefer-to-be-false.md) | Suggest using `toBeFalse()` | 🔧 |
| [prefer-to-be-object](docs/rules/prefer-to-be-object.md) | Suggest using `toBeObject()` | 🔧 |
| [prefer-to-be-true](docs/rules/prefer-to-be-true.md) | Suggest using `toBeTrue()` | 🔧 |
| [prefer-to-have-been-called-once](docs/rules/prefer-to-have-been-called-once.md) | Suggest using `toHaveBeenCalledOnce()` | 🔧 |## Credit
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
## 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
[fixable]: https://img.shields.io/badge/-fixable-green.svg