admin管理员组文章数量:1201212
Which configuration to use with ESLint to have it accept both code like:
return new Promise(..)
and
async function() {...}
This is used in Node.js
Whatever configuration of ES6 2017.... I keep on having errors like :
'Promise' is not defined no-undef
or
Parsing error: Unexpected token function
Thanks !
Which configuration to use with ESLint to have it accept both code like:
return new Promise(..)
and
async function() {...}
This is used in Node.js
Whatever configuration of ES6 2017.... I keep on having errors like :
'Promise' is not defined no-undef
or
Parsing error: Unexpected token function
Thanks !
Share Improve this question edited Nov 28, 2018 at 17:17 Hunter McMillen 61.5k25 gold badges123 silver badges175 bronze badges asked Nov 28, 2018 at 17:15 DevBabDevBab 8797 silver badges14 bronze badges 3 |2 Answers
Reset to default 26FWIW, eslint needs ES6 specified in the parser AND the environment sections, e.g.
{
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
...
See https://github.com/eslint/eslint/issues/9812 for a discussion.
Just add this line of comment in the top of the file you are working in
/*eslint no-undef: 0*/
Or you can change the eslint config file (change the rules)
And you are good to go!
Hope this helps!
本文标签: javascriptESlintwhich config for Promise and AsyncStack Overflow
版权声明:本文标题:javascript - ESlint : which config for Promise and Async - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738592341a2101583.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
ecmaVersion
to 6? eslint.org/docs/user-guide/… ores6
environment eslint.org/docs/user-guide/configuring#specifying-environments – Jaime Commented Nov 28, 2018 at 17:19