Skip to content

Commit

Permalink
feat: make no-alias-methods recommended (#1221)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `no-alias-methods` is now recommended as the methods themselves will be removed in the next major version of Jest
  • Loading branch information
G-Rath committed Aug 28, 2022
1 parent 918873b commit 914b24a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -203,7 +203,7 @@ installations requiring long-term consistency.
| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
| [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | |
| [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
| [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | |
Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-alias-methods.md
@@ -1,5 +1,8 @@
# Disallow alias methods (`no-alias-methods`)

> These aliases are going to be removed in the next major version of Jest - see
> https://github.com/facebook/jest/issues/13164 for more
Several Jest methods have alias names, such as `toThrow` having the alias of
`toThrowError`. This rule ensures that only the canonical name as used in the
Jest documentation is used in the code. This makes it easier to search for all
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/rules.test.ts.snap
Expand Up @@ -69,6 +69,7 @@ exports[`rules should export configs that refer to actual rules 1`] = `
],
"rules": {
"jest/expect-expect": "warn",
"jest/no-alias-methods": "error",
"jest/no-commented-out-tests": "warn",
"jest/no-conditional-expect": "error",
"jest/no-deprecated-functions": "error",
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-alias-methods.ts
Expand Up @@ -11,7 +11,7 @@ export default createRule({
docs: {
category: 'Best Practices',
description: 'Disallow alias methods',
recommended: false,
recommended: 'error',
},
messages: {
replaceAlias: `Replace {{ alias }}() with its canonical name of {{ canonical }}()`,
Expand Down

0 comments on commit 914b24a

Please sign in to comment.