Standard: I got an reserved word error for await statements

Created on 11 May 2017  ·  3Comments  ·  Source: standard/standard

I posted an issue on atom linter-js-standard plugin, but I guess it is most likely an issue with standard itself:

https://github.com/ricardofbarros/linter-js-standard/issues/185

capture d ecran de 2017-05-11 22-18-44

But I use linter-js-standard v3.9.1:

capture d ecran de 2017-05-11 22-19-36

Which use standard v8.6.0 as dependency

https://github.com/ricardofbarros/linter-js-standard/blob/master/package.json

And standard seems support async/await since standard v8.3.0 (> v8.6.0)

https://github.com/feross/standard/issues/645#issuecomment-250550504

capture d ecran de 2017-05-11 22-22-38

What's wrong ?

Most helpful comment

I think the issue here is that the message is misleading / not as informative as it could be .

It would be better (and properly informative) if it said "The 'await' keyword can only be used inside functions marked 'async'."

All 3 comments

Hello!

I think this is working normally. The error isn't very informative, but the await keyword can only be used inside of a function marked async. So the sample above is correctly marked as an error.
https://ponyfoo.com/articles/understanding-javascript-async-await#using-async-await

Just for kicks, I checked out the v8.6.0 tag and tried another sample file with different syntax, and it worked! :)

~/code/standard v8.6.0*
🕦 ❯ cat test.js

```js
/* global foo */

async function yo () {
let x = await foo()
return x
}

module.exports = yo

```bash
~/code/standard v8.6.0*
🕦 ❯ node bin/cmd.js test.js
🕦 ❯ # no error returned!

I'm going to close this issue, but please feel free to continue the conversation.

I think the issue here is that the message is misleading / not as informative as it could be .

It would be better (and properly informative) if it said "The 'await' keyword can only be used inside functions marked 'async'."

I agree @brianmhunt, however the error originates from deep inside eslints parser.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NemoStein picture NemoStein  ·  3Comments

jescalan picture jescalan  ·  3Comments

mightyiam picture mightyiam  ·  3Comments

muhajirdev picture muhajirdev  ·  3Comments

johannes-z picture johannes-z  ·  3Comments