Skip to content

Commit 35f32cc

Browse files
committed
feat: deprecate no-if in favor of no-conditional-in-test (#1049)
1 parent d56cb0a commit 35f32cc

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ installations requiring long-term consistency.
167167
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
168168
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
169169
| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
170-
| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | |
171170
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
172171
| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
173172
| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |

docs/rules/no-if.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Disallow conditional logic (`no-if`)
22

3+
## Deprecated
4+
5+
This rule has been deprecated in favor of
6+
[`no-conditional-in-test`](no-conditional-in-test.md).
7+
38
Conditional logic in tests is usually an indication that a test is attempting to
49
cover too much, and not testing the logic it intends to. Each branch of code
510
executing within an if statement will usually be better served by a test devoted

src/__tests__/__snapshots__/rules.test.ts.snap

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Object {
2525
"jest/no-focused-tests": "error",
2626
"jest/no-hooks": "error",
2727
"jest/no-identical-title": "error",
28-
"jest/no-if": "error",
2928
"jest/no-interpolation-in-snapshots": "error",
3029
"jest/no-jasmine-globals": "error",
3130
"jest/no-jest-import": "error",

src/rules/no-if.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export default createRule({
4444
messages: {
4545
conditionalInTest: 'Test should not contain {{ condition }} statements.',
4646
},
47+
deprecated: true,
48+
replacedBy: ['no-conditional-in-test'],
4749
schema: [],
4850
type: 'suggestion',
4951
},

0 commit comments

Comments
 (0)