Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upShorthand async function interpreted as beginning of function paren. #865
Comments
This comment has been minimized.
This comment has been minimized.
|
The code that you get after running const bar = async () => { return true }
const foo = bar
;(async () => {
// do something async directly without creating a named function.
await foo
})() |
This comment has been minimized.
This comment has been minimized.
|
Thanks @LinusU, I noticed that I was missing a semicolon in my shorthand function. Is it possible for StandardJS to recognise and correctly fix this mistake? |
This comment has been minimized.
This comment has been minimized.
|
I think it's quite hard since the code you originally wrote still is valid javascript, and it would be weird if |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Apr 20, 2017
|
Yea, it's sounds almost impossible. But still
sounds strange for me and like a bug in ESLint parser. @lesander is it fixed when use semicolon? But yea as @LinusU said, the |
This comment has been minimized.
This comment has been minimized.
|
I think that "Unexpected space between function name and paren." is correct, since there are whitespace between |
This comment has been minimized.
This comment has been minimized.
|
I believe this is working as intended. |
lesander commentedApr 20, 2017
Hi!
Not quite sure if the issue I've described below is a 'bug' in the
standardparser, or if shorthand functions are not supported at all.Let's have a look at the following code snippet.
As you can see,
foois set tobarand after that, we invoke a directly executed async function. Now let's runstandardon the snippet.We see that
standardinterprets the shorthand function and assignment offoo = baras an invalid formatted function.After running
standard --fix, the shorthand function is pasted directly after the assignment offoo.My question is; is this wanted behaviour?