Skip to content

Commit

Permalink
feat: deprecate no-if in favor of no-conditional-in-test (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Feb 6, 2022
1 parent d56cb0a commit 35f32cc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ installations requiring long-term consistency.
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | |
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |
Expand Down
5 changes: 5 additions & 0 deletions docs/rules/no-if.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Disallow conditional logic (`no-if`)

## Deprecated

This rule has been deprecated in favor of
[`no-conditional-in-test`](no-conditional-in-test.md).

Conditional logic in tests is usually an indication that a test is attempting to
cover too much, and not testing the logic it intends to. Each branch of code
executing within an if statement will usually be better served by a test devoted
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/__snapshots__/rules.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Object {
"jest/no-focused-tests": "error",
"jest/no-hooks": "error",
"jest/no-identical-title": "error",
"jest/no-if": "error",
"jest/no-interpolation-in-snapshots": "error",
"jest/no-jasmine-globals": "error",
"jest/no-jest-import": "error",
Expand Down
2 changes: 2 additions & 0 deletions src/rules/no-if.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default createRule({
messages: {
conditionalInTest: 'Test should not contain {{ condition }} statements.',
},
deprecated: true,
replacedBy: ['no-conditional-in-test'],
schema: [],
type: 'suggestion',
},
Expand Down

0 comments on commit 35f32cc

Please sign in to comment.