-
Notifications
You must be signed in to change notification settings - Fork 662
feat(rome_js_parser, rome_js_formatter): support using
and await using
declaration
#4737
Conversation
✅ Deploy Preview for docs-rometools canceled.
|
using
and await using
declarationusing
and await using
declaration
using
and await using
declarationusing
and await using
declaration
Parser conformance results on ubuntu-latestjs/262
🔥 Regression (2):
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
using
and await using
declarationusing
and await using
declaration
I checked if rome handle using and await using declaration correctly in playground, but it didn't handle. |
@@ -1107,7 +1158,7 @@ pub(super) enum VariableDeclarationParent { | |||
Clause, | |||
} | |||
|
|||
/// Parses a variable declaration that consist of a variable kind (`let`, `const` or `var` and a list | |||
/// Parses a variable declaration that consist of a variable kind (`let`, `const`, `using` or `var` and a list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is not correct anymore. The function also checks for await
in case of using
. We should document this information
You have to update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on the tests!
@@ -52,7 +52,11 @@ impl Rule for UseSingleVarDeclarator { | |||
semicolon_token, | |||
} = node.as_fields(); | |||
|
|||
let JsVariableDeclarationFields { kind, declarators } = declaration.ok()?.as_fields(); | |||
let JsVariableDeclarationFields { | |||
await_token: _, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this token should be added to the rule’s state, so it can be preserved in the fixer action. I had actually made this change here: main...arendjr:rome-tools:using-proposal#diff-b62c2afc841e799795a6707e4bcdf0f415da3b3183303b3a8507d844f546d455R41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing! I will create a separate PR for some fixes in Linter.
Thank you for your reviews! I will try to fix in a few days. |
I seem "using" cannot be allowed inside a declaration_clause. |
I update codes by following comments and this PR is ready for the review again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no further comments, just the tests are red, but that might've been a network issue affecting CI :)
The CI failure is related to PlayForm/Compress#163 |
Such a good work! |
Summary
Fix a part of #4646
This PR is basic support for using and await using declaration.
After merging this PR, I will check if we need to modify more existing lint rules and create another PR for resolving todo tests.
Test Plan
I added some parser tests based on esbuild test cases
ref: https://github.com/evanw/esbuild/blob/af7cfc5d0d5108aae0f9f02447f08761e9b604f2/internal/js_parser/js_parser_test.go#L6090