Skip to content

Commit ab72e48

Browse files
karlhorkyljharb
authored andcommitted
[Docs] jsx-no-useless-fragment: add more examples of correct code
1 parent 7302a2a commit ab72e48

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2222
* [Refactor] [`jsx-indent-props`]: improved readability of the checkNodesIndent function ([#3315][] @caroline223)
2323
* [Tests] [`jsx-indent`], [`jsx-one-expression-per-line`]: add passing test cases ([#3314][] @ROSSROSALES)
2424
* [Refactor] `boolean-prop-naming`, `jsx-indent`: avoid assigning to arguments ([#3316][] @caroline223)
25-
* [Docs] `sort-comp`: add class component examples ([#3339][] @maurer2)
25+
* [Docs] [`sort-comp`]: add class component examples ([#3339][] @maurer2)
26+
* [Docs] [`jsx-no-useless-fragment`]: add more examples of correct code ([#3349][] @karlhorky)
2627

2728
[#3350]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3350
29+
[#3349]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3349
2830
[#3339]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3339
2931
[#3335]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3335
3032
[#3331]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3331

docs/rules/jsx-no-useless-fragment.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ Examples of **incorrect** code for this rule:
2727
<div />
2828
</>
2929
</section>
30+
31+
{showFullName ? <>{fullName}</> : <>{firstName}</>}
3032
```
3133

3234
Examples of **correct** code for this rule:
3335

3436
```jsx
37+
{foo}
38+
39+
<Foo />
40+
3541
<>
3642
<Foo />
3743
<Bar />
@@ -51,6 +57,8 @@ const cat = <>meow</>
5157
</SomeComponent>
5258

5359
<Fragment key={item.id}>{item.value}</Fragment>
60+
61+
{showFullName ? fullName : firstName}
5462
```
5563

5664
### `allowExpressions`

0 commit comments

Comments
 (0)