[英]node prevent accidentally calling async function without await
Is there a node or vscode feature that will keep me from accidentally forgetting to call my async functions with await? 是否有一个节点或vscode功能可以使我免于意外忘记在等待时调用异步函数? I've done this a few times and it always costs me hours of bug-hunting. 我已经做过几次了,这总是花费我数小时的错误查找时间。
There is an ESlint rule which warns for async functions which have no await expression. 有一条ESlint规则警告没有等待表达式的异步函数。
EDIT: You need to create '.eslintrc.json' file and add some rules to it. 编辑:您需要创建'.eslintrc.json'文件并向其中添加一些规则。 If you installed ESLint globally, you ca do it by running eslint --init
. 如果全局安装了ESLint,则可以通过运行eslint --init
。 You can find more information in the vscode plugin github repo . 您可以在vscode插件github repo中找到更多信息。
The availabe rules related to async/await are: 与异步/等待相关的可用规则是:
You can find more about ESLint and available rules on the official documentation page . 您可以在官方文档页面上找到有关ESLint和可用规则的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.