-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(analyze): check if a fragment has only one child element using to…
…kens. (#3582)
- Loading branch information
1 parent
73e4805
commit ecbc627
Showing
5 changed files
with
129 additions
and
10 deletions.
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
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
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 │ + <Component·/>; | ||
5 3 │ | ||
``` |