react/jsx-curly-brace-presence
eslint-plugin-react
Safe autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-curly-brace-presence": "error",
},
},
];Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes
<App>Hello world</App>;
<App prop='Hello world'>{'Hello world'}</App>;<App>{"Hello world"}</App>;
<App prop={"Hello world"}>{'Hello world'}</App>;<App>{'Hello world'}</App>;
<App prop={'Hello world'} attr={"foo"} />;<Color text={"\u00a0"} />
<App>{"Hello \u00b7 world"}</App>;
<style type="text/css">{'.main { margin-top: 0; }'}</style>;
/**
* there's no way to inject a whitespace into jsx without a container so this
* will always be allowed.
*/
<App>{' '}</App>
<App>{' '}</App>
<App>{/* comment */ <Bpp />}</App> // the comment makes the container necessaryExamples from the ESLint documentation.
react/jsx-curly-brace-presence
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-curly-brace-presence": "error",
},
},
];react/jsx-curly-brace-presence
react plugin · style
{
"plugins": [
"react"
],
"rules": {
"react/jsx-curly-brace-presence": "error"
}
}style/useConsistentCurlyBraces
style · since 1.8.2
{
"linter": {
"rules": {
"style": {
"useConsistentCurlyBraces": "error"
}
}
}
}Disallows JSX context provider values from taking values that will cause needless rerenders
Enforce that namespaces are not used in React elements
Disallow usage of shouldComponentUpdate when extending React.PureComponent
Disallow this from being used in stateless functional components
Enforce ES5 or ES6 class for React Components