Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint Parsing error: Unexpected token function with async

I am getting the following error in async usage on ESLINT.

eslint Parsing error: Unexpected token function with async

Here is my eslintsrc

{   "extends": "airbnb-base",   "rules": {     "no-console": "off",     "func-style":"error",     "import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false, "packageDir": "./"}] }, "parserOptions": {   "ecmaVersion":8  } } 

UPDATE

Here is my async

const get = async function get(req, res) {   const user = await service.get();   console.log("From db",user.username);   res.send('ok'); }; 
like image 882
shellakkshellu Avatar asked May 11 '18 05:05

shellakkshellu


2 Answers

I was getting this error also, I added the following to my eslintrc:

{   "env": {     "node": true,     "es6": true   },    "parserOptions": {     "ecmaVersion": 8   } } 
like image 67
Damo Avatar answered Sep 21 '22 06:09

Damo


In my case it got fixed when I just changed from:

"parserOptions": { "ecmaVersion": 8 }

to

"parserOptions": { "ecmaVersion": 2018 }

like image 41
darmis Avatar answered Sep 18 '22 06:09

darmis