Skip to content

Commit 0a9a3c2

Browse files
authored
Improve frontend guideline (#23252)
If an event listener must be `async`, the `e.preventDefault()` should be before any `await`, it's recommended to put it at the beginning of the function.
1 parent 294124d commit 0a9a3c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/content/doc/developers/guidelines-frontend.en-us.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ It's not recommended to use `async` event listeners, which may lead to problems.
8383
The reason is that the code after await is executed outside the event dispatch.
8484
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
8585

86+
If an event listener must be `async`, the `e.preventDefault()` should be before any `await`,
87+
it's recommended to put it at the beginning of the function.
88+
8689
If we want to call an `async` function in a non-async context,
8790
it's recommended to use `const _promise = asyncFoo()` to tell readers
8891
that this is done by purpose, we want to call the async function and ignore the Promise.

0 commit comments

Comments
 (0)