Skip to content

fix(lint): noUselessFragments should ignore fragments with untrimmed whitespaces#6425

Merged
ematipico merged 1 commit intobiomejs:mainfrom
siketyan:fix/GH-6391
Jun 20, 2025
Merged

fix(lint): noUselessFragments should ignore fragments with untrimmed whitespaces#6425
ematipico merged 1 commit intobiomejs:mainfrom
siketyan:fix/GH-6391

Conversation

@siketyan
Copy link
Copy Markdown
Member

Summary

Fixes #6391

React trims a "padding" whitespaces inside a element when it contains at least one line break; whitespaces without line breaks will never be trimmed and should be considered as a valid text node.

For example, the following code:

<> </>

is equivalent to:

<>{" "}</>

There is the same logic in react/jsx-no-unnecessary-fragment: https://github.com/jsx-eslint/eslint-plugin-react/blob/f2869fd6dc76ceb863c5e2aeea8bf4d392508775/lib/rules/jsx-no-useless-fragment.js#L116-L125

Test Plan

@siketyan siketyan requested review from a team June 19, 2025 15:59
@siketyan siketyan self-assigned this Jun 19, 2025
@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jun 19, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 19, 2025

CodSpeed Performance Report

Merging #6425 will not alter performance

Comparing siketyan:fix/GH-6391 (dee5f7e) with main (94142dd)

Summary

✅ 115 untouched benchmarks

@ematipico ematipico merged commit 00e97ad into biomejs:main Jun 20, 2025
28 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 lint/complexity/noUselessFragments false positive on content with whitespace characters.

2 participants