Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESlint : which config for Promise and Async

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 !

like image 241
DevBab Avatar asked Dec 08 '22 13:12

DevBab


1 Answers

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.

like image 124
Brian Burns Avatar answered Dec 10 '22 03:12

Brian Burns