-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lint/noUselessFragments): trim trivia to avoid suggesting invalid…
… code fixes (#1553)
- Loading branch information
1 parent
7897935
commit 593da22
Showing
7 changed files
with
76 additions
and
14 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
8 changes: 8 additions & 0 deletions
8
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_1514.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,8 @@ | ||
// https://github.com/biomejs/biome/issues/1514 | ||
const SomeComponent = () => { | ||
return ( | ||
<React.Fragment> | ||
Your Data Dispute Request was sent to your current Employer | ||
</React.Fragment> | ||
); | ||
} |
49 changes: 49 additions & 0 deletions
49
crates/biome_js_analyze/tests/specs/complexity/noUselessFragments/issue_1514.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,49 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: issue_1514.jsx | ||
--- | ||
# Input | ||
```jsx | ||
// https://github.com/biomejs/biome/issues/1514 | ||
const SomeComponent = () => { | ||
return ( | ||
<React.Fragment> | ||
Your Data Dispute Request was sent to your current Employer | ||
</React.Fragment> | ||
); | ||
} | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
issue_1514.jsx:4:9 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Avoid using unnecessary Fragment. | ||
2 │ const SomeComponent = () => { | ||
3 │ return ( | ||
> 4 │ <React.Fragment> | ||
│ ^^^^^^^^^^^^^^^^ | ||
> 5 │ Your Data Dispute Request was sent to your current Employer | ||
> 6 │ </React.Fragment> | ||
│ ^^^^^^^^^^^^^^^^^ | ||
7 │ ); | ||
8 │ } | ||
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 2 │ const SomeComponent = () => { | ||
3 3 │ return ( | ||
4 │ - ········<React.Fragment> | ||
5 │ - ············Your·Data·Dispute·Request·was·sent·to·your·current·Employer | ||
6 │ - ········</React.Fragment> | ||
4 │ + ········"Your·Data·Dispute·Request·was·sent·to·your·current·Employer" | ||
7 5 │ ); | ||
8 6 │ } | ||
``` | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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