Eslint-plugin-react: Rule for only one jsx react element per line?

Created on 22 Oct 2017  路  6Comments  路  Source: yannickcr/eslint-plugin-react

I would like to disallow multiple elements/components being opened on one line:

<Outer><Inner/></Outer>

and fix to:

<Outer>
  <Inner/>
</Outer>

I searched all over and could not find something like this. Thank you.

help wanted new rule

All 6 comments

Would this rule also warn on <A /><B /> and fix to:

<A />
<B />

?

@ljharb Yes indeed.

However, maybe it could be configurable to conditionally support either of the following variants:

<A>{whatever()}</A>
<A>
  {whatever()}
</A>

Sounds great; want to make a PR? :-D

@ljharb I would be happy to when I get the chance. Never worked in this codebase before, but I assume jsx-max-props-per-line.js is probably a good starting reference point.

@ljharb Done in #1497

It's merged. Closing

Was this page helpful?
0 / 5 - 0 ratings