Skip to content

fix(noUselessFragments): fix result has invalid syntax when under JSX attribute#4648

Merged
fireairforce merged 1 commit into
biomejs:mainfrom
fireairforce:fix-4553
Nov 27, 2024
Merged

fix(noUselessFragments): fix result has invalid syntax when under JSX attribute#4648
fireairforce merged 1 commit into
biomejs:mainfrom
fireairforce:fix-4553

Conversation

@fireairforce

@fireairforce fireairforce commented Nov 27, 2024

Copy link
Copy Markdown
Member

Summary

closes: #4553

I add judge logic for the fix case like:

<Suspense fallback={<><span>Loading...</span></>}>
   {children}
 </Suspense>;

When the fragment child is a JSXElement like <span>Loading...</span> here, in the fix process, we will keep the JSXAttributeValue.

So it will fix as:

<Suspense fallback={<span>Loading...</span>}>
   {children}
 </Suspense>;

The attribute fallback's value is a JsxExpressionAttributeValue not a JsxTagExpression.

Test Plan

I add test case.

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Nov 27, 2024
@codspeed-hq

codspeed-hq Bot commented Nov 27, 2024

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #4648 will not alter performance

Comparing fireairforce:fix-4553 (3fcc1dc) with main (cd1c8ec)

Summary

✅ 97 untouched benchmarks

@fireairforce fireairforce requested review from a team November 27, 2024 08:50

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great fix!

@fireairforce fireairforce merged commit 516314c into biomejs:main Nov 27, 2024
@maxmorozoff

Copy link
Copy Markdown

Thanks for fixing it!

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.

🐛 noUselessFragments fix result has invalid jsx syntax

3 participants