eslint-plugin-jest
Advanced tools
Comparing version 25.6.0 to 25.7.0
@@ -0,1 +1,9 @@ | ||
# [25.7.0](https://github.com/jest-community/eslint-plugin-jest/compare/v25.6.0...v25.7.0) (2022-01-15) | ||
### Features | ||
* create `prefer-equality-matcher` rule ([#1016](https://github.com/jest-community/eslint-plugin-jest/issues/1016)) ([341353b](https://github.com/jest-community/eslint-plugin-jest/commit/341353bc7d57685cc5e0b31501d6ca336a0dbaf0)) | ||
* **valid-expect:** support `asyncMatchers` option and default to `jest-extended` matchers ([#1018](https://github.com/jest-community/eslint-plugin-jest/issues/1018)) ([c82205a](https://github.com/jest-community/eslint-plugin-jest/commit/c82205a73a4e8de315a2ad4d413b146e27c14a34)) | ||
# [25.6.0](https://github.com/jest-community/eslint-plugin-jest/compare/v25.5.0...v25.6.0) (2022-01-15) | ||
@@ -2,0 +10,0 @@ |
@@ -41,2 +41,7 @@ # Enforce valid `expect()` usage (`valid-expect`) | ||
}, | ||
asyncMatchers: { | ||
type: 'array', | ||
items: { type: 'string' }, | ||
default: ['toResolve', 'toReject'], | ||
}, | ||
minArgs: { | ||
@@ -82,2 +87,10 @@ type: 'number', | ||
### `asyncMatchers` | ||
Allows specifying which matchers return promises, and so should be considered | ||
async when checking if an `expect` should be returned or awaited. | ||
By default, this has a list of all the async matchers provided by | ||
`jest-extended` (namely, `toResolve` and `toReject`). | ||
### `minArgs` & `maxArgs` | ||
@@ -84,0 +97,0 @@ |
@@ -74,2 +74,4 @@ "use strict"; | ||
const defaultAsyncMatchers = ['toReject', 'toResolve']; | ||
var _default = (0, _utils.createRule)({ | ||
@@ -100,2 +102,8 @@ name: __filename, | ||
}, | ||
asyncMatchers: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
} | ||
}, | ||
minArgs: { | ||
@@ -115,2 +123,3 @@ type: 'number', | ||
alwaysAwait: false, | ||
asyncMatchers: defaultAsyncMatchers, | ||
minArgs: 1, | ||
@@ -122,2 +131,3 @@ maxArgs: 1 | ||
alwaysAwait, | ||
asyncMatchers = defaultAsyncMatchers, | ||
minArgs = 1, | ||
@@ -232,4 +242,5 @@ maxArgs = 1 | ||
const parentNode = matcher.node.parent; | ||
const shouldBeAwaited = modifier && modifier.name !== _utils.ModifierName.not || asyncMatchers.includes(matcher.name); | ||
if (!parentNode.parent || !modifier || modifier.name === _utils.ModifierName.not) { | ||
if (!parentNode.parent || !shouldBeAwaited) { | ||
return; | ||
@@ -236,0 +247,0 @@ } |
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "25.6.0", | ||
"version": "25.7.0", | ||
"description": "Eslint rules for Jest", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -181,2 +181,3 @@ <div align="center"> | ||
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | Suggest using the built-in comparison matchers | | ![fixable][] | | ||
| [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | Suggest using the built-in equality matchers | | ![suggest][] | | ||
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | | ||
@@ -183,0 +184,0 @@ | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | Prefer `await expect(...).resolves` over `expect(await ...)` syntax | | ![fixable][] | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314737
99
4598
253