Leo*_*ang 14 javascript webpack babeljs
我正在使用Babel和Webpack.如果我忘记await了异步功能,它通常会被忽视.偶尔,如果我忘记了await,异步函数中会出现错误,我得到一个Unhandled promise rejection.然后,我意识到我忘记了await.
当我忘记添加一个时,有没有办法得到警告await?
Kir*_*eck 12
设置更好的与webpack,repo和代码编辑器的eslint集成.
这是适用的规则,需要等待.
考虑整合以下内容:
由于不推荐使用 TSLint:no-floating-promisesESLint 规则要求您明确处理任何承诺(例如 withawait或void)。
这是一个最小的.eslintrc. 请注意,parserOptions此规则需要:
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-floating-promises": ["error"]
}
}
Run Code Online (Sandbox Code Playgroud)
我觉得OP是寻找类似no-floating-promises的tslint看:https://palantir.github.io/tslint/rules/no-floating-promises/
| 归档时间: |
|
| 查看次数: |
1202 次 |
| 最近记录: |