question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"ecmaVersion": "2017" gives Parsing error: Unexpected token ( on async method

See original GitHub issue
  • ESLint Version: v4.10.0
  • Node Version: v8.10.0
  • npm Version: 6.0.1

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
  "extends": "eslint:recommended",
  "env": {
    "node": true,
    "es6": true,
    "jest": true
  },
  "parserOptions": {
    "ecmaVersion": "2017"
  },
  "plugins": [
    "node"
  ],
  "rules": {
    "arrow-parens": ["error", "always"],
    "no-var": "error",
    "prefer-const": "error",
    "array-bracket-spacing": ["error", "never"],
    "comma-dangle": ["error", "never"],
    "computed-property-spacing": ["error", "never"],
    "eol-last": "error",
    "eqeqeq": ["error", "smart"],
    "indent": ["error", 2, { "SwitchCase": 1 }],
    "no-confusing-arrow": ["error", {"allowParens": false}],
    "no-extend-native": "error",
    "no-mixed-spaces-and-tabs": "error",
    "no-spaced-func": "error",
    "no-trailing-spaces": "error",
    "no-unused-vars": "error",
    "no-use-before-define": ["error", "nofunc"],
    "object-curly-spacing": ["error", "always"],
    "prefer-arrow-callback": "error",
    "quotes": ["error", "single", "avoid-escape"],
    "semi": ["error", "always"],
    "space-infix-ops": "error",
    "spaced-comment": ["error", "always"],
    "keyword-spacing": ["error", { before: true, after: true }],
    "template-curly-spacing": ["error", "never"],
    "semi-spacing": "error",
    "strict": "error",
    "no-console": "off",
    "node/no-unsupported-features": ["error", {"version": 8}],
    "node/no-missing-require": "error"
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

class DeadLetter {
  constructor(options = {}) {
    if (!options.queueUrl)
      throw new Error('queueUrl is undefined');
    this.options = options;
    this.sqs = new AWS.SQS({
      region: url.parse(options.queueUrl).host.split('.')[1],
      params: { QueueUrl: options.queueUrl }
    });

    this.cfn = new AWS.CloudFormation({
      region: url.parse(options.queueUrl).host.split('.')[1],
    });

    const actions = { purse, writeOut, replay, triage };

    findQueues(this.cfn, options);
    const queues = selectQueue(queues);
    const queue = triageSelection(queue);
    const data = actions[data.action](sqs, data.queue);
  }

  async findQueues(options) {
    return new Promise((resolve) => {
      let res = await this.cfn.describeStacks({ StackName: options.stackName}).promise();

npm run lint

this basically runs eslint.

What did you expect to happen? I don’t think the ( on async should error. When I change the "ecmaVersion": "8", I get Parsing error: The keyword 'class' is reserved on the first line which also shouldn’t be the case.

What actually happened? Please include the actual, raw output from ESLint.

"ecmaVersion": "2017"

33:1 error Parsing error: Unexpected token (

"ecmaVersion": "8"

  11:1  error  Parsing error: The keyword 'class' is reserved

I checked on gitter channel members on this, seems like saying "ecmaVersion": "8" should work here, haven’t looked a lot on this, is there something in local setup or what else am I missing here?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Jun 18, 2018

@Aladdin-ADD async/await was added in ES2017.

1reaction
platinumazurecommented, Jun 18, 2018

Did this solve your issue after all?

Agreed that we should catch this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint Parsing error: Unexpected token function with async
Just in case this is happening to people using async/await for the first time. This error also appears if you use await inside...
Read more >
eslint/eslint - Gitter
I am having a problem in eslint-config-hapijs for the arrow function ... 2017 gives me error Parsing error: Unexpected token this for a...
Read more >
Unexpected token error after adding await keyword to Node.js ...
Dylan Sather (Pipedream) : Hi , getting used to async / await and asynchronous programming in JS can take a long time even...
Read more >
Js - Parsing Error For Async Function - ADocLib
Parsing error: Unexpected token function' using async/await + ecmaVersion 2017 #8366. Closed. BlueRaja opened this issue on Mar 30 2017 10 comments.
Read more >
How To Fix - "Parsing error: Unexpected Token" in React.js or ...
This could be due to a typo mistake, missing something in the code etc. Also could be dev environment and ESLint parsing styles...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found