Rules
prefer-shorthand-fragment
Full Name in eslint-plugin-react-x
react-x/prefer-shorthand-fragment
Full Name in @eslint-react/eslint-plugin
@eslint-react/prefer-shorthand-fragment
Features
🔧
Description
Enforces shorthand syntax for fragments.
Examples
Failing
import React, { Fragment } from "react";
function MyComponent() {
return (
<Fragment>
<button />
<button />
</Fragment>
);
}
Passing
import React from "react";
function MyComponent() {
return (
<>
<button />
<button />
</>
);
}
Implementation
See Also
avoid-shorthand-boolean
Enforces the use of explicit boolean values for boolean attributes.avoid-shorthand-fragment
Enforces the use of explicit<Fragment>
or<React.Fragment>
components instead of the shorthand<>
or</>
syntax.prefer-shorthand-boolean
Enforces the use of shorthand syntax for boolean attributes.