react/jsx-fragments
eslint-plugin-react
Safe autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-fragments": "error",
},
},
];<React.Fragment><Foo /></React.Fragment><><Foo /></><><Foo /></><React.Fragment key="key"><Foo /></React.Fragment><React.Fragment><Foo /></React.Fragment>Examples from the ESLint documentation.
react/jsx-fragments
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-fragments": "error",
},
},
];react/jsx-fragments
react plugin · style
{
"plugins": [
"react"
],
"rules": {
"react/jsx-fragments": "error"
}
}style/useFragmentSyntax
style · since 1.0.0
{
"linter": {
"rules": {
"style": {
"useFragmentSyntax": "error"
}
}
}
}Disallow .bind() or arrow functions in JSX props
Disallow file extensions that may contain JSX
Disallow usage of setState in componentDidUpdate
Disallow creating unstable components inside components
Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes