From 5bc472f6e2dc911f7f65e04a6f2b04b74fc377a7 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 3 Mar 2023 00:13:50 +0800 Subject: [PATCH] doc --- docs/content/doc/developers/guidelines-frontend.en-us.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/content/doc/developers/guidelines-frontend.en-us.md b/docs/content/doc/developers/guidelines-frontend.en-us.md index 7f4d87d9011ed..66d3e83e938c3 100644 --- a/docs/content/doc/developers/guidelines-frontend.en-us.md +++ b/docs/content/doc/developers/guidelines-frontend.en-us.md @@ -83,6 +83,9 @@ It's not recommended to use `async` event listeners, which may lead to problems. The reason is that the code after await is executed outside the event dispatch. Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md +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. + If we want to call an `async` function in a non-async context, it's recommended to use `const _promise = asyncFoo()` to tell readers that this is done by purpose, we want to call the async function and ignore the Promise.