jsx-no-useless-fragment
NOTE: this rule is included the following rule sets:
recommended
react
jsx
fresh
Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["recommended"] // ...or "react", "jsx", "fresh" } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended # or ... deno lint --rules-tags=react # or ... deno lint --rules-tags=jsx # or ... deno lint --rules-tags=fresh
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["jsx-no-useless-fragment"], "exclude": ["jsx-no-useless-fragment"] } } }
Fragments are only necessary at the top of a JSX "block" and only when there are multiple children. Fragments are not needed in other scenarios.
Invalid:
<></>
<><div /></>
<><App /></>
<p>foo <>bar</></p>
Valid:
<>{foo}</>
<><div /><div /></>
<>foo <div /></>
<p>foo bar</p>