node.jseslinteslintrc

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');
};

Solution

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

    {
      "env": {
        "node": true,
        "es6": true
      },
    
      "parserOptions": {
        "ecmaVersion": 8
      }
    }