jsx-eslint/eslint-plugin-react
View on GitHubjsx-wrap-multilines: option to exclude selfclosing components
Open
#1,279 opened on Jun 27, 2017
enhancementhelp wanted
Description
Hi! We have a lot of selfclosing components that can be assigned to variables and have line break between attributes, like
const comp = <Component prop1='prop1' prop2='prop2' prop3='prop3'/
prop4='prop4' prop5='prop5'/>;
I don't want to wrap such components in parens, but want to wrap multiline components that have children
const comp = (
<Component prop1='prop1' prop2='prop2' prop3='prop3'/
prop4='prop4' prop5='prop5'>
<ChildrenComp/>
<ChildrenComp/>
<ChildrenComp/>
</Component>
);
Today jsx-wrap-multilines just enforce parens on any multiline components, would be great to have option to ignore selfclosing ones. And maybe each current option (declaration, assignment, return, arrow) should have such option, because, for instance, I might want to wrap returned multiline component into parens anyway
return (
<Component prop1='prop1' prop2='prop2' prop3='prop3'/
prop4='prop4' prop5='prop5'/>
);
So maybe config could look like
'react/jsx-wrap-multilines': [2, {
'declaration': {ignoreSelfClosing: true},
'assignment': {ignoreSelfClosing: true},
'return': true,
'arrow': true,
}],