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

fix(js_formatter): fix invalid formatting of nested multiline comments #1581

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

ah-yu
Copy link
Contributor

@ah-yu ah-yu commented Jan 17, 2024

Summary

Closes #1571

The potential cause of the incorrect formatting of nested multiline comments may stem from nesting Aligns.

 align(2, [
    "{",
    group(expand: true, [
      indent([
        soft_line_break_or_space,
        group(expand: propagated, [
          "/**",
          align(1, [
            hard_line_break,
            "* blah",
            hard_line_break,
            "*/"
          ]),
          hard_line_break,
          "id: string"
        ]),
        if_group_breaks([";"])
      ]),
      soft_line_break_or_space
    ]),
    "}"
  ]),
  soft_line_break_or_space,
  "| ",
  align(2, ["boolean"])
])

Referencing the comment

/// Nesting (Aligns)[TagKind::Align] has the effect that all except the most inner align are handled as (Indent)[TagKind::Indent].
it provides an explanation of how nesting Align functions. In the reported issue, Transforming Align(2) Indent Align(1) to Indent Indent Align(1) results in an invalid formatting.

To address this, we can follow the approach used by Prettier and use text(" ") instead of Align(1, ...).

Test Plan

Add a new test case

Copy link

netlify bot commented Jan 17, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit da01bd1
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/65a75672964de30008864ec4
😎 Deploy Preview https://deploy-preview-1581--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added A-Formatter Area: formatter A-Website Area: website L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Jan 17, 2024
Copy link

codspeed-hq bot commented Jan 17, 2024

CodSpeed Performance Report

Merging #1581 will improve performances by 6.12%

Comparing ah-yu:doc_comment_format (da01bd1) with main (1c91b03)

Summary

⚡ 1 improvements
✅ 92 untouched benchmarks

Benchmarks breakdown

Benchmark main ah-yu:doc_comment_format Change
big5-added.json[uncached] 3 ms 2.9 ms +6.12%

@arendjr
Copy link
Contributor

arendjr commented Jan 17, 2024

Thanks!

@arendjr arendjr merged commit a46230d into biomejs:main Jan 17, 2024
19 checks passed
@ah-yu ah-yu deleted the doc_comment_format branch January 17, 2024 08:05
ematipico pushed a commit to DaniGuardiola/biome that referenced this pull request Jan 24, 2024
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-Website Area: website L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Nested comment adds extra space
2 participants