jsx-eslint/eslint-plugin-react

jsx-wrap-multilines: option to exclude selfclosing components

Open

#1.279 geöffnet am 27. Juni 2017

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide