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): placements of line comments between function parentheses and body #1485

Conversation

kalleep
Copy link
Contributor

@kalleep kalleep commented Jan 9, 2024

Summary

To match prettier we need to attach a line comment that sits between function parentheses and function body to first statement inside the body.

Before we only did this for function declarations and we attached all types of comments to the body but to match prettier we should only do that for line comments. We should also not exclude empty statements.

I found another non-idempotent formatting issue but we can tackle this in another pr. For this case prettier also has a non-idempotent formatting.

Closes: #1172

Test Plan

Added new tests and uncommented prittier diff

Copy link

netlify bot commented Jan 9, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit bd2c08b
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/659ea769a8e9f00008e3ccb2
😎 Deploy Preview https://deploy-preview-1485--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: 95 (🔴 down 5 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 9, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
@kalleep kalleep force-pushed the fix-comments-function-between-function-parent-body branch from 94666d3 to df3c813 Compare January 9, 2024 09:32
Copy link

codspeed-hq bot commented Jan 9, 2024

CodSpeed Performance Report

Merging #1485 will degrade performances by 8.85%

⚠️ No base runs were found

Falling back to comparing kalleep:fix-comments-function-between-function-parent-body (bd2c08b) with main (352b87d)

Summary

❌ 1 regressions
✅ 92 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main kalleep:fix-comments-function-between-function-parent-body Change
big5-added.json[uncached] 2.9 ms 3.1 ms -8.85%

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Just a tiny comment to address, not a blocker

// ```javascript
// function test() /* comment */ {
// function test() // comment {
Copy link
Member

Choose a reason for hiding this comment

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

The JS snippet didn't need to change, this is now incorrect because the curly bracket { is part of the comment, unless you meant to move the { to a new line too,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah, you are right.

@kalleep kalleep force-pushed the fix-comments-function-between-function-parent-body branch from 250d1c1 to 8828e1b Compare January 9, 2024 12:36
@kalleep kalleep force-pushed the fix-comments-function-between-function-parent-body branch from c2e31e3 to 6feeb93 Compare January 10, 2024 14:17
@kalleep kalleep force-pushed the fix-comments-function-between-function-parent-body branch from 6feeb93 to bd2c08b Compare January 10, 2024 14:19
@ematipico ematipico merged commit b7390da into biomejs:main Jan 11, 2024
18 of 19 checks passed
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.

📝 Comments between function parens and body should be consistently placed
2 participants