Skip to content
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

refactor(js_grammar): improve representation of imports #1163

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

Conaclos
Copy link
Member

@Conaclos Conaclos commented Dec 12, 2023

Summary

This implements the proposal I made in the corresponding discussion.

This refactoring provides several advantages:

  • the CST is now closer to the spec
  • the following invalid states cannot be represented (which is more in line with the philosophy of Biome)
    import type A, { B } from "";
    import type A, * as B from "";
  • there is a single way to represent a namespace import

Test Plan

I updated the parser tests and the associated snapshots.

Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for biomejs canceled.

Name Link
🔨 Latest commit 8f858b7
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/6579a45b5685d00008c9f518

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages labels Dec 12, 2023
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 49701 49701 0
Passed 48721 48721 0
Failed 980 980 0
Panics 0 0 0
Coverage 98.03% 98.03% 0.00%

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 6322 6322 0
Passed 2036 2036 0
Failed 4286 4286 0
Panics 0 0 0
Coverage 32.20% 32.20% 0.00%

ts/babel

Test result main count This PR count Difference
Total 662 662 0
Passed 592 592 0
Failed 70 70 0
Panics 0 0 0
Coverage 89.43% 89.43% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17646 17646 0
Passed 13452 13452 0
Failed 4192 4192 0
Panics 2 2 0
Coverage 76.23% 76.23% 0.00%

@Conaclos Conaclos changed the title wip refactor(js_grammar): improve representation of imports Dec 12, 2023
lol.ts Outdated Show resolved Hide resolved
xtask/codegen/js.ungram Outdated Show resolved Hide resolved

× expected `from` but instead found `*`

> 1 │ import defer * as ns from "x";
Copy link
Member Author

@Conaclos Conaclos Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer reported because this is recovered as a combined import clause (defer is the default specifier). Not sure why it didn't error asking for a comma?

match p.cur() {
T![,] | T!['{'] => {
let syntax_type = match p.cur() {
T![,] | T!['{'] | T![*] => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is responsible for the behavior change discussed here

Copy link
Contributor

@denbezrukov denbezrukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦄

xtask/codegen/js.ungram Show resolved Hide resolved
@ematipico ematipico merged commit f49e6df into main Dec 14, 2023
19 checks passed
@ematipico ematipico deleted the conaclos/ast/js-import branch December 14, 2023 20:02
@Conaclos Conaclos added the A-Changelog Area: changelog label Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants