Skip to content

Commit a67d92d

Browse files
committed
feat: deprecate no-truthy-falsy rule
1 parent b6a22e5 commit a67d92d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ installations requiring long-term consistency.
151151
| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![fixable][] |
152152
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] |
153153
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | |
154-
| [no-truthy-falsy](docs/rules/no-truthy-falsy.md) | Disallow using `toBeTruthy()` & `toBeFalsy()` | | |
155154
| [no-try-expect](docs/rules/no-try-expect.md) | Prefer using toThrow for exception tests | ![recommended][] | |
156155
| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | |
157156
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | |

docs/rules/no-truthy-falsy.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Disallow using `toBeTruthy()` & `toBeFalsy()` (`no-truthy-falsy`)
22

3+
## Deprecated
4+
5+
This rule has been deprecated in favor of
6+
[`no-restricted-matchers`](no-restricted-matchers.md) with the following config:
7+
8+
```json
9+
{
10+
"rules": {
11+
"jest/no-restricted-matchers": [
12+
"error",
13+
{
14+
"toBeTruthy": "Avoid `toBeTruthy`",
15+
"toBeFalsy": "Avoid `toBeFalsy`"
16+
}
17+
]
18+
}
19+
}
20+
```
21+
22+
---
23+
324
Tests against boolean values should assert true or false. Asserting `toBeTruthy`
425
or `toBeFalsy` matches non-boolean values as well and encourages weaker tests.
526

src/rules/no-truthy-falsy.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default createRule({
99
description: 'Disallow using `toBeTruthy()` & `toBeFalsy()`',
1010
recommended: false,
1111
},
12+
deprecated: true,
13+
replacedBy: ['no-restricted-matchers'],
1214
messages: {
1315
avoidMatcher: 'Avoid {{ matcherName }}',
1416
},

0 commit comments

Comments
 (0)