-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hey there! I've dug around for a few days now, whenever I had a spare moment to dedicate to it, but I couldn't find a rule that would enforce curly braces for React elements as JSX props. I've tried using a combo of jsx-no-literals (which was mostly for strings) and curly-brace-presence but it didn't work (using --fix) for React element props. Here's some examples using jsx-curly-brace-presence with [1, "always"] as the value:
Initial input: <ExampleComponent text='Hello' component=<p>World!</p> />
Expected output: <ExampleComponent text={'Hello'} component={<p>World!</p>} />
Actual output: <ExampleComponent text={'Hello'} component=<p>World!</p> />
... The problem with not enclosing the JSX element props with curly braces is that it breaks certain parsers, for example the one esbuild happens to be using.
Libraries:
"babel-eslint": "10.1.0"
"eslint": "6.8.0"
"eslint-config-prettier": "6.10.0"
"eslint-config-recommended": "4.1.0"
"eslint-plugin-flowtype": "4.6.0"
"eslint-plugin-prettier": "3.1.2"
"eslint-plugin-react": "7.18.3"
Environment: