-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(noUselessFragments): fix result has invalid jsx when under JSX at…
…tribute
- Loading branch information
1 parent
cd1c8ec
commit 3fcc1dc
Showing
5 changed files
with
93 additions
and
9 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
9 changes: 9 additions & 0 deletions
9
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_4553.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,9 @@ | ||
<Suspense | ||
fallback={ | ||
<> | ||
<span>Loading...</span> | ||
</> | ||
} | ||
> | ||
{children} | ||
</Suspense>; |
51 changes: 51 additions & 0 deletions
51
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_4553.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,51 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: issue_4553.jsx | ||
snapshot_kind: text | ||
--- | ||
# Input | ||
```jsx | ||
<Suspense | ||
fallback={ | ||
<> | ||
<span>Loading...</span> | ||
</> | ||
} | ||
> | ||
{children} | ||
</Suspense>; | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
issue_4553.jsx:3:9 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Avoid using unnecessary Fragment. | ||
1 │ <Suspense | ||
2 │ fallback={ | ||
> 3 │ <> | ||
│ ^^ | ||
> 4 │ <span>Loading...</span> | ||
> 5 │ </> | ||
│ ^^^ | ||
6 │ } | ||
7 │ > | ||
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 │ <Suspense | ||
2 │ - ····fallback={ | ||
3 │ - ········<> | ||
4 │ - ············<span>Loading...</span> | ||
5 │ - ········</> | ||
6 │ - ····} | ||
2 │ + ····fallback={<span>Loading...</span>} | ||
7 3 │ > | ||
8 4 │ {children} | ||
``` |