-
-
Notifications
You must be signed in to change notification settings - Fork 442
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(analyze): check if a fragment has only one child element using tokens. #3582
Merged
ematipico
merged 9 commits into
biomejs:main
from
satojin219:fix/no-useless-fragments-one-element
Aug 13, 2024
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7856688
fix: check if a fragment has only one child element
satojin219 5e436db
test: fragment with a single child element on a new line
satojin219 05d946f
fix: expand child kind
satojin219 65fd215
fix: get first element excluding line breaks
satojin219 7951a9c
test: update snap shot
satojin219 d8cea55
refactor: early return
satojin219 11630dd
Merge remote-tracking branch 'upstream/main'
satojin219 68749ff
Merge branch 'main' into fix/no-useless-fragments-one-element
satojin219 fcd861c
chore: updaste CHANGELOG.md
satojin219 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_3545.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// https://github.com/biomejs/biome/issues/3545 | ||
<> | ||
<Component /> | ||
</>; |
41 changes: 41 additions & 0 deletions
41
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_3545.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
assertion_line: 84 | ||
expression: issue_3545.jsx | ||
--- | ||
# Input | ||
```jsx | ||
// https://github.com/biomejs/biome/issues/3545 | ||
<> | ||
<Component /> | ||
</>; | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
issue_3545.jsx:2:1 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
! Avoid using unnecessary Fragment. | ||
|
||
1 │ // https://github.com/biomejs/biome/issues/3545 | ||
> 2 │ <> | ||
│ ^^ | ||
> 3 │ <Component /> | ||
> 4 │ </>; | ||
│ ^^^ | ||
5 │ | ||
|
||
i A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment. | ||
|
||
i Unsafe fix: Remove the Fragment | ||
|
||
1 1 │ // https://github.com/biomejs/biome/issues/3545 | ||
2 │ - <> | ||
3 │ - → <Component·/> | ||
4 │ - </>; | ||
2 │ + ""; | ||
5 3 │ | ||
|
||
|
||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a regression here