eslint-react icon indicating copy to clipboard operation
eslint-react copied to clipboard

[feat] config to allow <></> in no-useless-fragment

Open sbdchd opened this issue 3 months ago • 0 comments

Problem Description

Sometimes APIs will type their inputs as JSX.Element, in which case, you’ll need to pass in an empty fragment instead of null.

<Foo bar={<></>}/>

Or the return type of the component is typed as JSX.Element so you return <></> while loading

Alternative Solutions

Migrating away from <></> is too much work

Feature Details

allowEmptyFragment: boolean = false

Examples

allowEmptyFragment: true

And then you could use <></>

Evaluation Checklist

  • [x] I have had problems that this feature would solve
  • [x] I could not find a way to solve the problem with existing features or workarounds
  • [x] I have thought very hard about potential edge cases and downsides, and they are acceptable
  • [x] I think the feature is well-defined and would provide clear value to users

sbdchd avatar Oct 07 '25 22:10 sbdchd