From fa08f0944e89915fb215bbeff970f12459121cb8 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 3 Oct 2021 14:39:55 +1300 Subject: [PATCH] feat: deprecate `prefer-to-be-undefined` rule --- README.md | 1 - docs/rules/prefer-to-be-undefined.md | 4 ++++ src/__tests__/__snapshots__/rules.test.ts.snap | 1 - src/rules/prefer-to-be-undefined.ts | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42fd1cc9f..41effa317 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,6 @@ installations requiring long-term consistency. | [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] | | [prefer-to-be](docs/rules/prefer-to-be.md) | Suggest using `toBe()` for primitive literals | | ![fixable][] | -| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | | [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | | [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | diff --git a/docs/rules/prefer-to-be-undefined.md b/docs/rules/prefer-to-be-undefined.md index bafc90f8c..135828cd2 100644 --- a/docs/rules/prefer-to-be-undefined.md +++ b/docs/rules/prefer-to-be-undefined.md @@ -1,5 +1,9 @@ # Suggest using `toBeUndefined()` (`prefer-to-be-undefined`) +## Deprecated + +This rule has been deprecated in favor of [`prefer-to-be`](prefer-to-be.md). + In order to have a better failure message, `toBeUndefined()` should be used upon asserting expectations on undefined value. diff --git a/src/__tests__/__snapshots__/rules.test.ts.snap b/src/__tests__/__snapshots__/rules.test.ts.snap index f38569362..a89e9bc82 100644 --- a/src/__tests__/__snapshots__/rules.test.ts.snap +++ b/src/__tests__/__snapshots__/rules.test.ts.snap @@ -42,7 +42,6 @@ Object { "jest/prefer-spy-on": "error", "jest/prefer-strict-equal": "error", "jest/prefer-to-be": "error", - "jest/prefer-to-be-undefined": "error", "jest/prefer-to-contain": "error", "jest/prefer-to-have-length": "error", "jest/prefer-todo": "error", diff --git a/src/rules/prefer-to-be-undefined.ts b/src/rules/prefer-to-be-undefined.ts index 859429cc6..eeef1e94d 100644 --- a/src/rules/prefer-to-be-undefined.ts +++ b/src/rules/prefer-to-be-undefined.ts @@ -46,6 +46,8 @@ export default createRule({ messages: { useToBeUndefined: 'Use toBeUndefined() instead', }, + deprecated: true, + replacedBy: ['prefer-to-be'], fixable: 'code', type: 'suggestion', schema: [],