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/arrowfunction with conditional expression body #1929

Conversation

mdm317
Copy link
Contributor

@mdm317 mdm317 commented Feb 27, 2024

Summary

Closes #1805
I found an incompatibility issue with Prettier when using arrow functions which body is conditional expression

I found this issue occurs when formatting arrow functions whose body is conditional expression
see below example code when linewidth 17

(someProperty)=>someProperty?'one':'two'

playground

I found prettier enforce space after => this token in this case.
And I tried to implement this without changing to FormatElement but failed. So, I added a HardSpace to FormatElement to implement this.

I am not sure if this approach is acceptable.
Also Documenting can be quite challenging.

Please review my code

Test Plan

add test case

@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 Feb 27, 2024
Copy link

netlify bot commented Feb 27, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 4d55426
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/65df4aafe884290009e74049
😎 Deploy Preview https://deploy-preview-1929--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: 96 (🔴 down 4 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.

Copy link

codspeed-hq bot commented Feb 27, 2024

CodSpeed Performance Report

Merging #1929 will improve performances by 9.79%

Comparing mdm317:fix/arrowfunction-with-conditional-expression-body (4d55426) with main (f73af5d)

Summary

⚡ 1 improvements
✅ 92 untouched benchmarks

Benchmarks breakdown

Benchmark main mdm317:fix/arrowfunction-with-conditional-expression-body Change
big5-added.json[uncached] 3.1 ms 2.8 ms +9.79%

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.

The documentation that you wrote is amazing! Thank you for your contribution and the fix 🙏

@ematipico
Copy link
Member

You need to fix the conflicts, then we can merge it

@mdm317 mdm317 force-pushed the fix/arrowfunction-with-conditional-expression-body branch from f8a3237 to 4d55426 Compare February 28, 2024 15:01
@ematipico ematipico merged commit 78dc430 into biomejs:main Feb 28, 2024
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.

📝 Inconsistency compared to prettier
2 participants