jsx-eslint/eslint-plugin-react

jsx-wrap-multilines: option to exclude selfclosing components

Open

#1,279 opened on 2017年6月27日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)JavaScript (8,630 stars) (2,797 forks)batch import
enhancementhelp wanted

説明

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,
}],

コントリビューターガイド

jsx-wrap-multilines: option to exclude selfclosing components · jsx-eslint/eslint-plugin-react#1279 | Good First Issue