Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): disable no-await-sync-events by default #984

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ module.exports = [
| [await-async-queries](docs/rules/await-async-queries.md) | Enforce promises from async queries to be handled | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | |
| [await-async-utils](docs/rules/await-async-utils.md) | Enforce promises from async utils to be awaited properly | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | |
| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensures consistent usage of `data-testid` | | | |
| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | ![badge-angular][] ![badge-dom][] ![badge-react][] | | |
| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | ![badge-angular][] ![badge-dom][] | | |
| [no-await-sync-queries](docs/rules/no-await-sync-queries.md) | Disallow unnecessary `await` for sync queries | ![badge-angular][] ![badge-dom][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | |
| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | | |
| [no-debugging-utils](docs/rules/no-debugging-utils.md) | Disallow the use of debugging utilities like `debug` | | ![badge-angular][] ![badge-marko][] ![badge-react][] ![badge-svelte][] ![badge-vue][] | |
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/no-await-sync-events.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unnecessary `await` for sync events (`testing-library/no-await-sync-events`)

💼 This rule is enabled in the following configs: `angular`, `dom`, `react`.
💼 This rule is enabled in the following configs: `angular`, `dom`.

<!-- end auto-generated rule header -->

Expand Down Expand Up @@ -110,6 +110,7 @@ module.exports = {

## When Not To Use It

- When you're using `@testing-library/react` in version 17 and above.
- `"fire-event"` option: should be disabled only for those Testing Library packages where fire-event methods are async.
- `"user-event"` option: should be disabled only if using v14 or greater.

Expand Down
2 changes: 1 addition & 1 deletion lib/configs/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export = {
'testing-library/await-async-queries': 'error',
'testing-library/await-async-utils': 'error',
'testing-library/no-await-sync-events': [
'error',
false,
{ eventModules: ['fire-event'] },
],
'testing-library/no-await-sync-queries': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/no-await-sync-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default createTestingLibraryRule<Options, MessageIds>({
recommendedConfig: {
dom: ['error', { eventModules: DEFAULT_EVENT_MODULES }],
angular: ['error', { eventModules: DEFAULT_EVENT_MODULES }],
react: ['error', { eventModules: DEFAULT_EVENT_MODULES }],
// @testing-library/react >= 17.0 requires `await act()` and therefore `await fireEvent()`
react: [false, { eventModules: DEFAULT_EVENT_MODULES }],
vue: false,
svelte: false,
marko: false,
Expand Down
Loading