Skip to content

Commit 22547bb

Browse files
committed
Update rule severity and documentation for RTL
1 parent 9365214 commit 22547bb

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

docs/react-testing-library.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,43 @@ Config for projects using **React Testing Library** for testing.
1717
import react-testing-library from '@code-pushup/eslint-config/react-testing-library.js';
1818
import tseslint from 'typescript-eslint';
1919

20-
export default tseslint.config(
21-
...react-testing-library,
22-
{
23-
// customize rules if needed:
24-
rules: {
25-
// e.g. to enforce using `queryBy*` or `getBy*` for matchers:
26-
'testing-library/prefer-query-matchers': [
27-
'warn',
28-
{ validEntries: [{ matcher: 'toBeVisible', query: 'get' }] },
29-
]
30-
}
31-
}
32-
);
20+
export default tseslint.config(...react-testing-library);
3321
```
3422

3523
## 📏 Rules (25)
3624

3725
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
3826
39-
### 🚨 Errors (11)
27+
### 🚨 Errors (9)
4028

41-
| Plugin | Rule | Options | Autofix | Overrides |
42-
| :----------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: |
43-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-events.md)<br />Enforce promises from async event methods are handled | <details><summary>eventModule: userEvent</summary><pre lang="json"><code>{&#13; "eventModule": "userEvent"&#13;}</code></pre></details> | 🔧 | |
44-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-queries.md)<br />Enforce promises from async queries to be handled | | | |
45-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-utils.md)<br />Enforce promises from async utils to be awaited properly | | | |
46-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-dom-import](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-dom-import.md)<br />Disallow importing from DOM Testing Library | <details><summary>react</summary><pre lang="json"><code>"react"</code></pre></details> | 🔧 | |
47-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-global-regexp-flag-in-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-global-regexp-flag-in-query.md)<br />Disallow the use of the global RegExp flag (/g) in queries | | 🔧 | |
48-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-manual-cleanup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-manual-cleanup.md)<br />Disallow the use of `cleanup` | | | |
49-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-promise-in-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-promise-in-fire-event.md)<br />Disallow the use of promises passed to a `fireEvent` method | | | |
50-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-unnecessary-act](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-unnecessary-act.md)<br />Disallow wrapping Testing Library utils or empty callbacks in `act` | | | |
51-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-wait-for-side-effects](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-side-effects.md)<br />Disallow the use of side effects in `waitFor` | | | |
52-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-wait-for-snapshot](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-snapshot.md)<br />Ensures no snapshot is generated inside of a `waitFor` call | | | |
53-
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-query-by-disappearance](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-by-disappearance.md)<br />Suggest using `queryBy*` queries when waiting for disappearance | | | |
29+
| Plugin | Rule | Options | Autofix | Overrides |
30+
| :----------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: |
31+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-events.md)<br />Enforce promises from async event methods are handled | <details><summary>eventModule: userEvent</summary><pre lang="json"><code>{&#13; "eventModule": "userEvent"&#13;}</code></pre></details> | 🔧 | |
32+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-queries.md)<br />Enforce promises from async queries to be handled | | | |
33+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [await-async-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/await-async-utils.md)<br />Enforce promises from async utils to be awaited properly | | | |
34+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-dom-import](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-dom-import.md)<br />Disallow importing from DOM Testing Library | <details><summary>react</summary><pre lang="json"><code>"react"</code></pre></details> | 🔧 | |
35+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-global-regexp-flag-in-query](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-global-regexp-flag-in-query.md)<br />Disallow the use of the global RegExp flag (/g) in queries | | 🔧 | |
36+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-promise-in-fire-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-promise-in-fire-event.md)<br />Disallow the use of promises passed to a `fireEvent` method | | | |
37+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-unnecessary-act](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-unnecessary-act.md)<br />Disallow wrapping Testing Library utils or empty callbacks in `act` | | | |
38+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-wait-for-side-effects](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-side-effects.md)<br />Disallow the use of side effects in `waitFor` | | | |
39+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-wait-for-snapshot](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-snapshot.md)<br />Ensures no snapshot is generated inside of a `waitFor` call | | | |
5440

55-
### ⚠️ Warnings (14)
41+
### ⚠️ Warnings (16)
5642

5743
| Plugin | Rule | Options | Autofix | Overrides |
5844
| :----------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :-----: | :-------: |
5945
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-await-sync-events](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-events.md)<br />Disallow unnecessary `await` for sync events | | | |
6046
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-await-sync-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-await-sync-queries.md)<br />Disallow unnecessary `await` for sync queries | | | |
6147
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-container](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-container.md)<br />Disallow the use of `container` methods | | | |
6248
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-debugging-utils](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-debugging-utils.md)<br />Disallow the use of debugging utilities like `debug` | | | |
49+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-manual-cleanup](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-manual-cleanup.md)<br />Disallow the use of `cleanup` | | | |
6350
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-node-access](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-node-access.md)<br />Disallow direct Node access | | | |
6451
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-render-in-lifecycle](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-render-in-lifecycle.md)<br />Disallow the use of `render` in testing frameworks setup functions | | | |
6552
| [![testing-library](./icons/other/testing-library.png)](undefined) | [no-wait-for-multiple-assertions](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/no-wait-for-multiple-assertions.md)<br />Disallow the use of multiple `expect` calls inside `waitFor` | | | |
6653
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-explicit-assert](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-explicit-assert.md)<br />Suggest using explicit assertions rather than standalone queries | | | |
6754
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-find-by](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-find-by.md)<br />Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | | 🔧 | |
6855
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-presence-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-presence-queries.md)<br />Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | | |
56+
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-query-by-disappearance](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-by-disappearance.md)<br />Suggest using `queryBy*` queries when waiting for disappearance | | | |
6957
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-query-matchers](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-query-matchers.md)<br />Ensure the configured `get*`/`query*` query is used with the corresponding matchers | | | |
7058
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-screen-queries.md)<br />Suggest using `screen` while querying | | | |
7159
| [![testing-library](./icons/other/testing-library.png)](undefined) | [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/prefer-user-event.md)<br />Suggest using `userEvent` over `fireEvent` for simulating user interactions | | | |

scripts/helpers/configs.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,6 @@ export const configsExtraEslintrc = {
201201
'vitest/consistent-test-it': ['warn', { fn: 'test', withinDescribe: 'test' }]
202202
}
203203
}`,
204-
'react-testing-library': `,
205-
{
206-
// customize rules if needed:
207-
rules: {
208-
// e.g. to enforce using \`queryBy*\` or \`getBy*\` for matchers:
209-
'testing-library/prefer-query-matchers': [
210-
'warn',
211-
{ validEntries: [{ matcher: 'toBeVisible', query: 'get' }] },
212-
]
213-
}
214-
}`,
215204
};
216205

217206
/**

src/configs/react-testing-library.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export default tseslint.config({
1414
'testing-library/no-await-sync-events': 'warn',
1515
'testing-library/no-await-sync-queries': 'warn',
1616
'testing-library/no-container': 'warn',
17+
'testing-library/no-manual-cleanup': 'warn',
1718
'testing-library/no-node-access': 'warn',
1819
'testing-library/no-render-in-lifecycle': 'warn',
1920
'testing-library/no-wait-for-multiple-assertions': 'warn',
2021
'testing-library/prefer-find-by': 'warn',
2122
'testing-library/prefer-presence-queries': 'warn',
23+
'testing-library/prefer-query-by-disappearance': 'warn',
2224
'testing-library/prefer-query-matchers': 'warn',
2325
'testing-library/prefer-screen-queries': 'warn',
2426
'testing-library/render-result-naming-convention': 'warn',

0 commit comments

Comments
 (0)