rome / tools

Unified developer tools for JavaScript, TypeScript, and the web
https://docs.rome.tools/
MIT License
23.75k stars 664 forks source link

feat(rome_js_parser, rome_js_formatter): support `using` and `await using` declaration #4737

Closed nissy-dev closed 1 year ago

nissy-dev commented 1 year ago

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

netlify[bot] commented 1 year ago

Deploy Preview for docs-rometools canceled.

Name Link
Latest commit f4c46bd01e0485d90c349b3612b04be90d0fffed
Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64cfa5830a95450008926aba
github-actions[bot] commented 1 year ago

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 48863 48863 0
Passed 47810 47808 ❌ ⏬ -2
Failed 1053 1055 ❌ ⏫ +2
Panics 0 0 0
Coverage 97.84% 97.84% -0.00%
:fire: Regression (2): ``` language/statements/labeled/value-await-non-module-escaped.js language/statements/labeled/value-await-non-module.js ```

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6212 6212 0
Passed 1764 1764 0
Failed 4448 4448 0
Panics 0 0 0
Coverage 28.40% 28.40% 0.00%

ts/babel

Test result main count This PR count Difference
Total 639 639 0
Passed 573 573 0
Failed 66 66 0
Panics 0 0 0
Coverage 89.67% 89.67% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17224 17224 0
Passed 13121 13121 0
Failed 4103 4103 0
Panics 0 0 0
Coverage 76.18% 76.18% 0.00%
nissy-dev commented 1 year ago

I checked if rome handle using and await using declaration correctly in playground, but it didn't handle. I'm looking into what happened.

ematipico commented 1 year ago

I checked if rome handle using and await using declaration correctly in playground, but it didn't handle. I'm looking into what happened.

You have to update parse_declaration_clause too

nissy-dev commented 1 year ago

Thank you for your reviews! I will try to fix in a few days.

nissy-dev commented 1 year ago

You have to update parse_declaration_clause too

I seem "using" cannot be allowed inside a declaration_clause.

https://www.typescriptlang.org/play?ts=5.2.0-beta#code/CYUwxgNghgTiAEBXAzgSwHYHN5QFw-QE8BuAKBAA8AHAexgBck0t4AjeAXiXVADMMQwYkA

nissy-dev commented 1 year ago

I update codes by following comments and this PR is ready for the review again!

nissy-dev commented 1 year ago

The CI failure is related to https://github.com/astro-community/astro-compress/issues/163

Conaclos commented 1 year ago

Such a good work!