Skip to content

Commit

Permalink
feat: deprecate no-truthy-falsy rule
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed May 16, 2020
1 parent b6a22e5 commit a67d92d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ installations requiring long-term consistency.
| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![fixable][] |
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] |
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | |
| [no-truthy-falsy](docs/rules/no-truthy-falsy.md) | Disallow using `toBeTruthy()` & `toBeFalsy()` | | |
| [no-try-expect](docs/rules/no-try-expect.md) | Prefer using toThrow for exception tests | ![recommended][] | |
| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | |
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | |
Expand Down
21 changes: 21 additions & 0 deletions docs/rules/no-truthy-falsy.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Disallow using `toBeTruthy()` & `toBeFalsy()` (`no-truthy-falsy`)

## Deprecated

This rule has been deprecated in favor of
[`no-restricted-matchers`](no-restricted-matchers.md) with the following config:

```json
{
"rules": {
"jest/no-restricted-matchers": [
"error",
{
"toBeTruthy": "Avoid `toBeTruthy`",
"toBeFalsy": "Avoid `toBeFalsy`"
}
]
}
}
```

---

Tests against boolean values should assert true or false. Asserting `toBeTruthy`
or `toBeFalsy` matches non-boolean values as well and encourages weaker tests.

Expand Down
2 changes: 2 additions & 0 deletions src/rules/no-truthy-falsy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default createRule({
description: 'Disallow using `toBeTruthy()` & `toBeFalsy()`',
recommended: false,
},
deprecated: true,
replacedBy: ['no-restricted-matchers'],
messages: {
avoidMatcher: 'Avoid {{ matcherName }}',
},
Expand Down

0 comments on commit a67d92d

Please sign in to comment.