Reputation: 879
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 !
Upvotes: 7
Views: 8695
Reputation: 22032
FWIW, 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.
Upvotes: 26
Reputation: 493
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!
Upvotes: 0