You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/rules/no-await-sync-events.md
+15-9
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
<!-- end auto-generated rule header -->
6
6
7
-
Ensure that sync simulated events are not awaited unnecessarily.
7
+
Ensure that sync events are not awaited unnecessarily.
8
8
9
9
## Rule Details
10
10
@@ -22,6 +22,12 @@ Some examples of simulating events not returning any Promise are:
22
22
23
23
This rule aims to prevent users from waiting for those function calls.
24
24
25
+
> ⚠️ `fire-event` methods are async only on following Testing Library packages:
26
+
>
27
+
> -`@testing-library/vue` (supported by this plugin)
28
+
> -`@testing-library/svelte` (not supported yet by this plugin)
29
+
> -`@marko/testing-library` (supported by this plugin)
30
+
25
31
Examples of **incorrect** code for this rule:
26
32
27
33
```js
@@ -87,13 +93,9 @@ const qux = async () => {
87
93
88
94
This rule provides the following options:
89
95
90
-
-`eventModules`: array of strings. The possibilities are: `"fire-event"` and `"user-event"`. Defaults to `["fire-event", "user-event"]`
91
-
92
-
### `eventModules`
93
-
94
-
This option gives you more granular control of which event modules you want to report, so you can choose to only report methods from either `fire-event`, `user-event` or both.
96
+
-`eventModules`: array of strings. Defines which event module should be linted for sync event methods. The possibilities are: `"fire-event"` and `"user-event"`. Defaults to `["fire-event"]`.
95
97
96
-
Example:
98
+
### Example:
97
99
98
100
```js
99
101
module.exports= {
@@ -106,7 +108,11 @@ module.exports = {
106
108
};
107
109
```
108
110
111
+
## When Not To Use It
112
+
113
+
-`"fire-event"` option: should be disabled only for those Testing Library packages where fire-event methods are async.
114
+
-`"user-event"` option: should be disabled only if using v14 or greater.
115
+
109
116
## Notes
110
117
111
-
- Since `user-event` v14 all its methods are async, so you should disable reporting them by setting the `eventModules` to just `"fire-event"` so `user-event` methods are not reported.
112
-
- There is another rule `await-async-events`, which is for awaiting async events for `user-event` v14 or `fire-event` only in Vue Testing Library. Please do not confuse with this rule.
118
+
There is another rule `await-async-events`, which is for awaiting async events for `user-event` v14 or `fire-event` only in Testing Library packages with async methods. Please do not confuse with this rule.
0 commit comments