Przejdź do głównej zawartości

noUselessFragments

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"linter": {
"rules": {
"complexity": {
"noUselessFragments": "error"
}
}
}
}

Disallow unnecessary fragments

<>
<>foo</>
<SomeComponent />
</>
code-block.jsx:2:5 lint/complexity/noUselessFragments  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This fragment is unnecessary.

1 │ <>
> 2 │ <>foo</>
^^^^^^^^
3 │ <SomeComponent />
4 │ </>

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.

Unsafe fix: Remove the Fragment

2 │ ····<>foo</>
-- ---
<></>
code-block.jsx:1:1 lint/complexity/noUselessFragments ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This fragment is unnecessary.

> 1 │ <></>
^^^^^
2 │

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.

<>
foo
</>
<React.Fragment>
foo
</React.Fragment>
<>
<Foo />
<Bar />
</>
<>foo {bar}</>