New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async function and await expression! #287
Comments
I wonder if acorn will do it natively, or if we'll need their plugin?
|
I think @nzakas is waiting for response: acornjs/acorn#441 |
Yup, waiting to hear back from Acorn. If they don't want to do it yet, then we'll hack it in here. |
Any progress on this? Could we start by using this plugin? |
I'm working on acornjs/acorn#446 😉 |
YEAAAAH! |
Wow, awesome! 🎉 |
Released a few hours ago, looks like: acornjs/acorn#446 (comment) |
Cool, if someone wants to put a PR together, we can merge into Espree and it will make it into the next version of ESLint. |
Cool - I'll try to get to it tonight if someone doesn't beat me to it |
If you can't get to it, I'll be backup :) |
Unfortunately, didn't end up having as much time as I thought I would tonight - feel free to take it, @xjamundx! |
I'll do it. |
Ugh, something is really wrong - a bunch of tests are failing with parsing errors. I don't have the energy to investigate but I've pushed the |
K will try to take a look in a bit, thanks for starting this friends! |
Confirmed 24 errors with the upgrade. Mostly related to the exponential operator. |
Wonder if it has something to do with this:
|
Oh n/m I didn't |
Heh, I was just going to say, I got over 90 errors. :) |
I'm looking into this change and other changes to the recoverable erorrs: This is a pretty common error amongst the 96 (74 instances):
|
Okay no progress yet. Back to work for a bit, will revisit later today if I can. FYI easiest way to test one of the issues is to run:
Funny of course that this works just fine:
Also confirmed error exists in Acorn Possibly related commit: acornjs/acorn@7c75f92 Looking again.. |
okay progress. there's a new |
Okay now there's only 4-5 tests failing. Of course |
Current errors are these. Wondering if we can just go along with their new line numbers or if we're doing something wrong... will take a look later tonight.
|
We should see if the new locations are more accurate than the old. If not, maybe there's an Acorn bug. |
I'm pretty sure the new numbers are more accurate, I'll take them for now. |
Started adding tests and a basic implementation. Most of the tests aren't working yet and I need to be done for the night, so anyone can take over if they want or I'll try to take it back tommorow :) |
Thank you, everyone. For reference, there are many test cases in acorn/test/tests-asyncawait.js and acorn/test/tests-trailing-commas-in-func.js |
Great thanks @mysticatea we'll use those test cases! |
Still working on creating those tests. I remember there was some easy way to generate the tests, but I can't remember how. |
K continuing this work today... |
Looks like my comment didn't go through :-/ Look at |
|
In case it needs to be used later, I'm going to paste in my test cases (stolen from acorn): /*!espree-section: async*/
async function foo() {}
/*!espree-section: no-async*/
function foo() {}
/*!espree-section: async-and-no-async*/
async
function foo() {}
/*!espree-section: export-async*/
export async function foo() { }
/*!espree-section: export-default-async*/
export default async function() { }
/*!espree-section: invalid-async-generator*/
async function* foo() { }
/*!espree-section: invalid-nested-async*/
async function wrap() {
async function await() { }
}
/*!espree-section: invalid-async-generator*/
async function* foo() { }
/*!espree-section: invalid-await-param*/
async function foo(await) { }
/*!espree-section: invalid-await-identifier*/
async function foo() { return {await} }
/*!espree-section: invalid-await-identifier*/
async function foo() { return {await} }
/*!espree-section: no-async-expression*/
(function foo() { })
/*!espree-section: async-expression*/
(async function foo() { })
/*!espree-section: invalid-async-expression*/
(async
function foo() { })
/*!espree-section: invalid-async-expression-generators*/
(async function* foo() { })
/*!espree-section: export-default-async-expression*/
export default (async function() { })
/*!espree-section: export-default-async-expression*/
export default (async function() { })
/*!espree-section: arrow-func*/
a => a
/*!espree-section: arrow-func-parens*/
(a) => a
/*!espree-section: async-arrow-func*/
async a => a
/*!espree-section: async-arrow-func-parens*/
async (a) => a
/*!espree-section: async-arrow-func-parens-multi*/
async (a, b) => a
/*!espree-section: async-arrow-func-destructed*/
async ({a = b}) => a
/*!espree-section: async-arrow-func-destructed-defaults*/
async ({a: b = c}) => a
/*!espree-section: async-destructured-assignment*/
async ({a: b = c})
/*!espree-section: async-then-arrow*/
async
a => a
/*!espree-section: async-func*/
async (await)
/*!espree-section: async-yield*/
async yield => 1
/*!espree-section: object-method*/
({foo() { }})
/*!espree-section: async-object-method*/
({async foo() { }})
/*!espree-section: async-named-object-method*/
({async() { }})
/*!espree-section: async-await-named-object-method*/
({async await() { }})
/*!espree-section: class-method*/
class A {foo() { }}
/*!espree-section: async-class-method*/
class A {async foo() { }}
/*!espree-section: async-static-class-method*/
class A {static async foo() { }}
/*!espree-section: async-named-class-method*/
class A {async() { }}
/*!espree-section: static-async-named-class-method*/
class A {static async() { }}
/*!espree-section: async-named-generator-method*/
class A {*async() { }}
/*!espree-section: async-named-static-generator-method*/
class A {static* async() { }}
/*!espree-section: async-class-method-named-await*/
class A {async await() { }}
/*!espree-section: async-static-class-method-named-await*/
class A {static async await() { }}
/*!espree-section: plain-await*/
await
/*!espree-section: async-await*/
async function foo(a, b) { await a }
/*!espree-section: async-arrow-func-parens*/
(async function foo(a) { await a })
/*!espree-section: aasync-await-arrow-expression*/
(async (a) => await a)
/*!espree-section: async-await-object-method*/
({async foo(a) { await a }})
/*!espree-section: async-await-expression-class-method*/
(class {async foo(a) { await a }})
/*!espree-section: async-await-math*/
async function foo(a, b) { await a + await b }
/*!espree-section: await-identifier-math*/
function foo() { await + 1 }
/*!espree-section: async-await-identifier-math*/
async function foo() { await + 1 }
/*!espree-section: async-await-function-param*/
async function foo(a = async function foo() { await b }) {}
/*!espree-section: async-await-arrow-param*/
async function foo(a = async () => await b) {}
/*!espree-section: async-await-object-method-param*/
async function foo(a = {async bar() { await b }}) {}
/*!espree-section: async-await-class-method-param*/
async function foo(a = class {async bar() { await b }}) {}
/*!espree-section: async-await-inside-parens*/
async function wrap() {
(a = await b)
}
/*!espree-section: async-await-destructured-default*/
async function wrap() {
({a = await b} = obj)
}
/*!espree-section: generator-async-func*/
function* wrap() {
async(a = yield b)
} and invalid cases: /*!espree-section: invalid-async-generator*/
async function* foo() { }
/*!espree-section: invalid-nested-async*/
async function wrap() {
async function await() { }
}
/*!espree-section: invalid-async-await-param*/
async function foo(await) { }
/*!espree-section: invalid-async-await-identifier*/
async function foo() { return {await} }
/*!espree-section: invalid-broken-line-async*/
(async
function foo() { })
/*!espree-section: invalid-async-generator-expression*/
(async function* foo() { })
/*!espree-section: invalid-await-func-expression*/
(async function await() { })
/*!espree-section: invalid-await-param-expression*/
(async function foo(await) { })
/*!espree-section: invalid-await-identifier-expression*/
(async function foo() { return {await} })
/*!espree-section: invalid-async-object*/
async ({a = b})
/*!espree-section: invalid-broken-async-arrow-before-parens*/
async
() => a
/*!espree-section: invalid-broken-async-arrow*/
async a
=> a
/*!espree-section: invalid-broken-async-arrow-after-parens*/
async ()
=> a
/*!espree-section: invalid-await-arrow-param*/
async await => 1
/*!espree-section: invalid-await-arrow-param-parens*/
async (await) => 1
/*!espree-section: invalid-await-destructured-param*/
async ({await}) => 1
/*!espree-section: invalid-await-named-destructured-param*/
async ({a: await}) => 1
/*!espree-section: invalid-await-named-destructured-array-param*/
async ([await]) => 1
/*!espree-section: invalid-broken-async-object-method*/
({async
foo() { }})
/*!espree-section: invalid-async-getter-method*/
({async get foo() { }})
/*!espree-section: invalid-async-getter-method-with-params*/
({async set foo(value) { }})
/*!espree-section: invalid-async-generator-method*/
({async* foo() { }})
/*!espree-section: invalid-nested-async-await-method*/
async function wrap() {
({async await() { }})
}
/*!espree-section: invalid-async-method-expression*/
({async foo() { var await }})
/*!espree-section: invalid-async-method-await-param*/
({async foo(await) { }})
/*!espree-section: invalid-async-method-return-await*/
({async foo() { return {await} }})
/*!espree-section: invalid-async-prop*/
({async foo: 1})
/*!espree-section: invalid-async-class-broken*/
class A {async
foo() { }}
/*!espree-section: invalid-async-static-method-broken*/
class A {static async
foo() { }}
/*!espree-section: invalid-async-constructor*/
class A {async constructor() { }}
/*!espree-section: invalid-async-class-getter*/
class A {async get foo() { }}
/*!espree-section: invalid-async-class-setter*/
class A {async set foo(value) { }}
/*!espree-section: invalid-async-class-generator*/
class A {async* foo() { }}
/*!espree-section: invalid-static-async-getter*/
class A {static async get foo() { }}
/*!espree-section: invalid-static-async-setter*/
class A {static async set foo(value) { }}
/*!espree-section: invalid-static-async-generator*/
class A {static async* foo() { }}
/*!espree-section: invalid-async-wrapped-class-await*/
async function wrap() {
class A {async await() { }}
}
/*!espree-section: invalid-async-method-await-identifier*/
class A {async foo() { var await }}
/*!espree-section: invalid-async-method-await-param*/
class A {async foo(await) { }}
/*!espree-section: invalid-async-class-method-await*/
class A {async foo() { return {await} }}
/*!espree-section: invalid-plain-await*/
await
/*!espree-section: invalid-await-top-level*/
await a
/*!espree-section: invalid-async-plain-await*/
async function foo() { await }
/*!espree-section: invalid-async-expression-plain-await*/
(async function foo() { await })
/*!espree-section: invalid-plain-await-arrow*/
async () => await
/*!espree-section: invalid-async-method-empty-await*/
({async foo() { await }})
/*!espree-section: invalid-async-class-method-empty-await*/
(class {async foo() { await }})
/*!espree-section: invalid-async-generator*/
async function foo(a = await b) {}
/*!espree-section: invalid-async-generator*/
(async function foo(a = await b) {})
/*!espree-section: invalid-async-generator*/
async (a = await b) => {}
/*!espree-section: invalid-async-generator*/
async function wrapper() {
async (a = await b) => {}
}
/*!espree-section: invalid-async-generator*/
({async foo(a = await b) {}})
/*!espree-section: invalid-async-generator*/
(class {async foo(a = await b) {}})
/*!espree-section: invalid-class-await-extend*/
async function foo(a = class extends (await b) {}) {}
/*!espree-section: invalid-await-default*/
async function wrap() {
(a = await b) => a
}
/*!espree-section: invalid-await-destructured-default*/
async function wrap() {
({a = await b} = obj) => a
}
/*!espree-section: invalid-yield-default*/
function* wrap() {
async(a = yield b) => a
} |
Updated the branch with fairly working code, realized I need to update the |
Issue appears to be that the newly generated nodes are missing |
I'm not sure if this is the issue, but in the test fixtures we don't include |
@nzakas cool that makes sense I made some minor modifications to |
@nzakas it seems like The branch is up to date if you want to pull it down and see. |
added this thing to
i'm obviously doing something wrong :-p |
Once this was fixed new issues revolve around the |
@xjamundx Espree outputs |
Thanks @nzakas ! |
Found what I need. Filename magic :)
|
Got all tests to pass. Updating now. Probably some additional tests may be needed, but it's getting close hopefully! |
Let me open a PR |
Note to self: |
We can support those now!
The text was updated successfully, but these errors were encountered: