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.

Async class method Unexpected token

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.10.0
  • Node Version: v.8.9.0
  • npm Version: 5.5.1

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

Please show your full configuration:

Configuration



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 test {
	constructor(){
    	this.help();
    }
  
  async help() {
  	const bla = await this.hello();
  }
  
  hello() {
  	return setTimeout(() => console.log('1'), 3000);
  }
}

new test();
REPL

What did you expect to happen? No error.

What actually happened? Please include the actual, raw output from ESLint. Parsing error: Unexpected token help

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mysticateacommented, Nov 3, 2017

Thank you for the issue.

If you don’t have configuration file, you need to create it. ESLint parses source codes in ES5 mode by default. You can configure it via configuration file. For example:

// .eslintrc.json
{
    "parserOptions": {
        "ecmaVersion": 2017
    }
}

See https://eslint.org/docs/user-guide/configuring for more information.

0reactions
st-schneidercommented, Nov 3, 2017

Okay thank you. I always get confused with versions these days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async/Await in a Class : unexpected token `this` - Stack Overflow
To keep things simple, it happens because when you create a Promise, in its' constructor you pass an arrow function, which contains await...
Read more >
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
SyntaxError: Unexpected token function - Async Await Nodejs
JavaScript : SyntaxError: Unexpected token function - Async Await Nodejs [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >
Unexpected token. A constructor, method Error in TS
The "Unexpected token. A constructor, method, accessor, or property was expected" error occurs when we use the var or let keywords to declare...
Read more >
Javascript async keyword not recognized for a class method
ERROR: Parsing error: Unexpected token cameraIni. The code will work normally in browsers, also is widelly used by this kind of application with...
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