From 57602e6f729386bd2f480e5339216679f145dfa4 Mon Sep 17 00:00:00 2001 From: Nick McCurdy Date: Tue, 16 Jun 2020 22:42:18 -0400 Subject: [PATCH] feat: recommend no-wait-for-empty-callback --- README.md | 5 ++++- lib/index.ts | 1 + lib/rules/no-wait-for-empty-callback.ts | 2 +- tests/__snapshots__/index.test.ts.snap | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4bbd7abd..1335d796 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ [![Tweet][tweet-badge]][tweet-url] + [![All Contributors](https://img.shields.io/badge/all_contributors-24-orange.svg?style=flat-square)](#contributors-) + ## Installation @@ -141,7 +143,7 @@ To enable this configuration use the `extends` property in your | [no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | | | [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | | [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | | -| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | | | +| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | | [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | | | [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | | [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Enforce specific queries when checking element is present or not | | | @@ -212,6 +214,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d + This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/lib/index.ts b/lib/index.ts index 3cc5ec21..02cd94b8 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -34,6 +34,7 @@ const recommendedRules = { 'testing-library/await-async-query': 'error', 'testing-library/await-async-utils': 'error', 'testing-library/no-await-sync-query': 'error', + 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/prefer-find-by': 'error', }; diff --git a/lib/rules/no-wait-for-empty-callback.ts b/lib/rules/no-wait-for-empty-callback.ts index 72c5225f..1c8f4b1a 100644 --- a/lib/rules/no-wait-for-empty-callback.ts +++ b/lib/rules/no-wait-for-empty-callback.ts @@ -21,7 +21,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({ description: "It's preferred to avoid empty callbacks in `waitFor` and `waitForElementToBeRemoved`", category: 'Best Practices', - recommended: false, + recommended: 'error', }, messages: { noWaitForEmptyCallback: diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index fedc3c05..7a67d222 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -14,6 +14,7 @@ Object { "error", "angular", ], + "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", }, } @@ -33,6 +34,7 @@ Object { "error", "react", ], + "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", }, } @@ -47,6 +49,7 @@ Object { "testing-library/await-async-query": "error", "testing-library/await-async-utils": "error", "testing-library/no-await-sync-query": "error", + "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", }, } @@ -67,6 +70,7 @@ Object { "error", "vue", ], + "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", }, }