浏览代码

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.
tags/v1.20.0-rc0
wxiaoguang 1年前
父节点
当前提交
0a9a3c2a6d
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3
    0
      docs/content/doc/developers/guidelines-frontend.en-us.md

+ 3
- 0
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.

正在加载...
取消
保存