Skip to content

Commit d8a2ac6

Browse files
authored
feat: recommend no-wait-for-empty-callback (#168)
BREAKING CHANGE: `no-wait-for-empty-callback` rule is automatically enabled if recommended, angular, react or vue config enabled. If you have any of those enabled, you could get new ESLint errors related to this rule after upgrading this plugin.
1 parent 58d72d5 commit d8a2ac6

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ To enable this configuration use the `extends` property in your
143143
| [no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | |
144144
| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] |
145145
| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | |
146-
| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | | |
146+
| [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][] | |
147147
| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | |
148148
| [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][] |
149149
| [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Enforce specific queries when checking element is present or not | | |

lib/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const recommendedRules = {
3434
'testing-library/await-async-query': 'error',
3535
'testing-library/await-async-utils': 'error',
3636
'testing-library/no-await-sync-query': 'error',
37+
'testing-library/no-wait-for-empty-callback': 'error',
3738
'testing-library/prefer-find-by': 'error',
3839
'testing-library/prefer-screen-queries': 'error',
3940
};

lib/rules/no-wait-for-empty-callback.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
2121
description:
2222
"It's preferred to avoid empty callbacks in `waitFor` and `waitForElementToBeRemoved`",
2323
category: 'Best Practices',
24-
recommended: false,
24+
recommended: 'error',
2525
},
2626
messages: {
2727
noWaitForEmptyCallback:

tests/__snapshots__/index.test.ts.snap

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Object {
1414
"error",
1515
"angular",
1616
],
17+
"testing-library/no-wait-for-empty-callback": "error",
1718
"testing-library/prefer-find-by": "error",
1819
"testing-library/prefer-screen-queries": "error",
1920
},
@@ -34,6 +35,7 @@ Object {
3435
"error",
3536
"react",
3637
],
38+
"testing-library/no-wait-for-empty-callback": "error",
3739
"testing-library/prefer-find-by": "error",
3840
"testing-library/prefer-screen-queries": "error",
3941
},
@@ -49,6 +51,7 @@ Object {
4951
"testing-library/await-async-query": "error",
5052
"testing-library/await-async-utils": "error",
5153
"testing-library/no-await-sync-query": "error",
54+
"testing-library/no-wait-for-empty-callback": "error",
5255
"testing-library/prefer-find-by": "error",
5356
"testing-library/prefer-screen-queries": "error",
5457
},
@@ -70,6 +73,7 @@ Object {
7073
"error",
7174
"vue",
7275
],
76+
"testing-library/no-wait-for-empty-callback": "error",
7377
"testing-library/prefer-find-by": "error",
7478
"testing-library/prefer-screen-queries": "error",
7579
},

0 commit comments

Comments
 (0)