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 long arrow function for AsNeeded arrow parens #1934

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

fireairforce
Copy link
Contributor

@fireairforce fireairforce commented Feb 28, 2024

Summary

Fixes: #1905

Test Plan

@github-actions github-actions bot added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Feb 28, 2024
Copy link

netlify bot commented Feb 28, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 149a9cd
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/65e5cfc9f64b190008ad924b
😎 Deploy Preview https://deploy-preview-1934--biomejs.netlify.app/playground
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95 (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.

@Spades-S
Copy link

Cool

@github-actions github-actions bot added A-Website Area: website A-Changelog Area: changelog labels Feb 28, 2024
@@ -214,7 +214,7 @@ pub(crate) fn should_hug_function_parameters(
) -> FormatResult<bool> {
/// Returns true if the first parameter should be forced onto the same line as the `(` and `)` parentheses.
/// See the `[ParameterLayout::Hug] documentation.
fn hug_formal_parameter(parameter: &self::AnyJsFormalParameter) -> FormatResult<bool> {
fn hug_formal_parameter(parameter: &self::AnyJsFormalParameter, from_arrow_function: bool, has_parentheses: bool) -> FormatResult<bool> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just add a simple judge here to deal this case.

Copy link

codspeed-hq bot commented Feb 28, 2024

CodSpeed Performance Report

Merging #1934 will improve performances by 8.52%

Comparing fireairforce:fix-#1905 (7fb507b) with main (8150c8e)

Summary

⚡ 2 improvements
✅ 91 untouched benchmarks

Benchmarks breakdown

Benchmark main fireairforce:fix-#1905 Change
db.json[cached] 77.7 ms 73.2 ms +6.18%
db.json[uncached] 90.5 ms 83.4 ms +8.52%

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.

This fix has caused our compatibility ratio with prettier. I am going to block it in advance and see if there's a better fix.

My initial advice is to look at Prettier's logic/behaviour.

The second advice is to understand if we really want to accept this change, because if so, we need to diverge.

@fireairforce fireairforce force-pushed the fix-#1905 branch 2 times, most recently from ee02ecc to 2cf766f Compare March 2, 2024 08:49
@fireairforce
Copy link
Contributor Author

I updated this pr, PTAL for free~ @ematipico

@fireairforce fireairforce force-pushed the fix-#1905 branch 2 times, most recently from 98198f9 to 6a44f6c Compare March 2, 2024 15:59
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.

That's more like it! Great contribution, thank you @fireairforce!

@fireairforce
Copy link
Contributor Author

it seems the ci block? i think it has nothing to do with this PR

@ematipico ematipico merged commit 2e2951e into biomejs:main Mar 4, 2024
5 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.

📝 arrow function with long type and single param without parens formats to invalid code
3 participants