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(lint/useShorthandFunctionType): add parens when needed #2601

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

Conaclos
Copy link
Member

@Conaclos Conaclos commented Apr 25, 2024

Summary

Fix #2595

Previously, the rule didn't add parentheses when they were needed.
It now adds parentheses when the function signature is inside an array, a union, or an intersection.

- type Union = { (): number } | string;
+ type Union = (() => number) | string;

Note: we should move the needs_parens utility from biome_js_formatter to biome_js_syntax.
It is not the first time we encounter this need.
Another possibility is to format the code fix with the formatter.
However, it is not actually possible?

Test Plan

I added non-regression tests.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Apr 25, 2024
Copy link

codspeed-hq bot commented Apr 25, 2024

CodSpeed Performance Report

Merging #2601 will degrade performances by 6.11%

Comparing conaclos/useShorthandFunctionType/2580 (29d229a) with main (b24b44c)

Summary

❌ 1 regressions
✅ 91 untouched benchmarks

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

Benchmarks breakdown

Benchmark main conaclos/useShorthandFunctionType/2580 Change
router.ts[uncached] 12.4 ms 13.2 ms -6.11%

@Conaclos Conaclos merged commit bed20b8 into main Apr 25, 2024
12 of 16 checks passed
@Conaclos Conaclos deleted the conaclos/useShorthandFunctionType/2580 branch April 25, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 useShorthandFunctionType suggests incorrect fix for union or intersection
1 participant