Skip to content

Commit 914b24a

Browse files
authored
feat: make no-alias-methods recommended (#1221)
BREAKING CHANGE: `no-alias-methods` is now recommended as the methods themselves will be removed in the next major version of Jest
1 parent 918873b commit 914b24a

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ installations requiring long-term consistency.
203203
| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
204204
| [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | |
205205
| [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
206-
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
206+
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
207207
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
208208
| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
209209
| [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | |

docs/rules/no-alias-methods.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Disallow alias methods (`no-alias-methods`)
22

3+
> These aliases are going to be removed in the next major version of Jest - see
4+
> https://github.com/facebook/jest/issues/13164 for more
5+
36
Several Jest methods have alias names, such as `toThrow` having the alias of
47
`toThrowError`. This rule ensures that only the canonical name as used in the
58
Jest documentation is used in the code. This makes it easier to search for all

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

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ exports[`rules should export configs that refer to actual rules 1`] = `
6969
],
7070
"rules": {
7171
"jest/expect-expect": "warn",
72+
"jest/no-alias-methods": "error",
7273
"jest/no-commented-out-tests": "warn",
7374
"jest/no-conditional-expect": "error",
7475
"jest/no-deprecated-functions": "error",

src/rules/no-alias-methods.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default createRule({
1111
docs: {
1212
category: 'Best Practices',
1313
description: 'Disallow alias methods',
14-
recommended: false,
14+
recommended: 'error',
1515
},
1616
messages: {
1717
replaceAlias: `Replace {{ alias }}() with its canonical name of {{ canonical }}()`,

0 commit comments

Comments
 (0)