-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
noUselessFragments
code actions (#1988)
- Loading branch information
1 parent
763844b
commit b8cf046
Showing
11 changed files
with
173 additions
and
64 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
5 changes: 5 additions & 0 deletions
5
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_1926.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,5 @@ | ||
<> | ||
<Hello leftIcon={<>{provider?.icon}</>} /> | ||
{<>{provider?.icon}</>} | ||
<>{provider?.icon}</> | ||
</> |
76 changes: 76 additions & 0 deletions
76
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_1926.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,76 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: issue_1926.jsx | ||
--- | ||
# Input | ||
```jsx | ||
<> | ||
<Hello leftIcon={<>{provider?.icon}</>} /> | ||
{<>{provider?.icon}</>} | ||
<>{provider?.icon}</> | ||
</> | ||
|
||
``` | ||
# Diagnostics | ||
``` | ||
issue_1926.jsx:2:22 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
! Avoid using unnecessary Fragment. | ||
|
||
1 │ <> | ||
> 2 │ <Hello leftIcon={<>{provider?.icon}</>} /> | ||
│ ^^^^^^^^^^^^^^^^^^^^^ | ||
3 │ {<>{provider?.icon}</>} | ||
4 │ <>{provider?.icon}</> | ||
|
||
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 | ||
|
||
2 │ ····<Hello·leftIcon={<>{provider?.icon}</>}·/> | ||
│ --- ---- | ||
|
||
``` | ||
``` | ||
issue_1926.jsx:3:6 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
! Avoid using unnecessary Fragment. | ||
|
||
1 │ <> | ||
2 │ <Hello leftIcon={<>{provider?.icon}</>} /> | ||
> 3 │ {<>{provider?.icon}</>} | ||
│ ^^^^^^^^^^^^^^^^^^^^^ | ||
4 │ <>{provider?.icon}</> | ||
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 | ||
|
||
3 │ ····{<>{provider?.icon}</>} | ||
│ --- ---- | ||
|
||
``` | ||
``` | ||
issue_1926.jsx:4:5 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
! Avoid using unnecessary Fragment. | ||
|
||
2 │ <Hello leftIcon={<>{provider?.icon}</>} /> | ||
3 │ {<>{provider?.icon}</>} | ||
> 4 │ <>{provider?.icon}</> | ||
│ ^^^^^^^^^^^^^^^^^^^^^ | ||
5 │ </> | ||
6 │ | ||
|
||
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 | ||
|
||
4 │ ····<>{provider?.icon}</> | ||
│ -- --- | ||
|
||
``` |
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
1 change: 0 additions & 1 deletion
1
...me_js_analyze/tests/specs/complexity/noUselessFragments/withJsxExpressionChildInvalid.jsx
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
..._analyze/tests/specs/complexity/noUselessFragments/withJsxExpressionChildInvalid.jsx.snap
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...iome_js_analyze/tests/specs/complexity/noUselessFragments/withJsxExpressionChildValid.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,3 @@ | ||
function jsxExpressionChild() { | ||
return <>{foo}</> | ||
} |
11 changes: 11 additions & 0 deletions
11
...js_analyze/tests/specs/complexity/noUselessFragments/withJsxExpressionChildValid.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,11 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: withJsxExpressionChildValid.jsx | ||
--- | ||
# Input | ||
```jsx | ||
function jsxExpressionChild() { | ||
return <>{foo}</> | ||
} | ||
|
||
``` |
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