Skip to content

Rule proposal: detect unnecessary use of fragments #2042

Closed
@moretti

Description

@moretti

The idea behind fragments is to group a list of children without adding extra nodes to the DOM.
Fragments are completely redundant when wrapping a single child, so the rule should detect examples like:

<>
  <div />
</>
<Fragment>
  <div />
</Fragment>

and flag them as a warning/error.

Example of valid usage of fragments:

<>
  <div />
  <div />
</>

(any case where children.length > 1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions