gpt4 book ai didi

javascript - ESlint : which config for Promise and Async

转载 作者:行者123 更新时间:2023-11-29 20:48:04 26 4
gpt4 key购买 nike

将哪种配置与 ESLint 一起使用以使其接受两种代码,例如:

return new Promise(..)

async function() {...}

这是在 Node.js 中使用的

无论 ES6 2017 的配置如何......我一直有这样的错误:

'Promise' is not defined no-undef

Parsing error: Unexpected token function

谢谢!

最佳答案

FWIW,eslint 需要在解析器和环境部分中指定 ES6,例如

{
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
...

参见 https://github.com/eslint/eslint/issues/9812进行讨论。

关于javascript - ESlint : which config for Promise and Async,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53524805/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com