DocumentationRulesavoid-shorthand-fragment

avoid-shorthand-fragment

Full Name in eslint-plugin-react-x

react-x/avoid-shorthand-fragment

Full Name in @eslint-react/eslint-plugin

@eslint-react/avoid-shorthand-fragment

Features

🔍

What it does

Enforces the use of explicit <Fragment> or <React.Fragment> components instead of the shorthand <> or </> syntax.

Examples

Failing

import React from "react";
 
function Example() {
  return (
    <>
      <button />
      <button />
    </>
  );
}

Passing

import React, { Fragment } from "react";
 
function Example() {
  return (
    <Fragment>
      <button />
      <button />
    </Fragment>
  );
}