Proposal: Add exception option to `no-extra-parens` to allow parens around React components
See original GitHub issueThe rule no-extra-parens
currently flags parens around React components spanning multiple lines:
const component = (
<div>
<h1>Hello world</h1>
</div>
)
However, some believe that wrapping multiline React components is the preferred way to write them to increase readability.
Proposal
Introduce a new exception option to this rule, reactComponents
(or just react
for brevity) which, when set to false
, would not flag React components wrapped in parens as issues.
ESLint: 3.7.1
Parser: babel-eslint
no-extra-parens
configuration:
{ 'no-extra-parens': [1, 'all', {
nestedBinaryExpressions: false
}]
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Proposal: Add JSX-specific overrides to no-extra-parens #7444
The default setting will be to treat parens around JSX components just ... Proposal: Add exception option to no-extra-parens to allow parens ......
Read more >Error Boundaries - React
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI ......
Read more >Error Handling in React 16 – React Blog
As React 16 release is getting closer, we would like to announce a few changes to how React handles JavaScript errors inside components....
Read more >Passing Functions to Components - React
Pass event handlers and other functions as props to child components: ... You can use an arrow function to wrap around an event...
Read more >Rules of Hooks - React
Don't call Hooks from regular JavaScript functions. Instead, you can: ✓ Call Hooks from React function components. ✓ Call Hooks from custom Hooks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I can get behind JSX options (including multi-line vs single-line). JSX can at least be represented as a syntactical construct, rather than being React-specific.
Can someone draft a proposal (see Rule Change guidelines) and ping me when that’s done so I can try to get the team to review?
This would be great, as it’s blocking Airbnb’s config from enabling
no-extra-parens
- precisely because our guide requires that multiline JSX be paren-wrapped.However, it also allows single-line JSX to be paren-wrapped, which means
multiline
wouldn’t suffice for our use case (@platinumazure)