Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate no-if in favor of no-conditional-in-test #1049

Merged
merged 1 commit into from Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
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
@@ -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
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
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