Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule for only one jsx react element per line? #1491

Closed
TSMMark opened this issue Oct 22, 2017 · 6 comments
Closed

Rule for only one jsx react element per line? #1491

TSMMark opened this issue Oct 22, 2017 · 6 comments

Comments

@TSMMark
Copy link
Contributor

TSMMark commented Oct 22, 2017

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.

@ljharb
Copy link
Member

ljharb commented Oct 23, 2017

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

<A />
<B />

?

@TSMMark
Copy link
Contributor Author

TSMMark commented Oct 23, 2017

@ljharb Yes indeed.

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

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

@ljharb
Copy link
Member

ljharb commented Oct 24, 2017

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

@TSMMark
Copy link
Contributor Author

TSMMark commented Oct 24, 2017

@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.

@TSMMark
Copy link
Contributor Author

TSMMark commented Oct 25, 2017

@ljharb Done in #1497

@TSMMark
Copy link
Contributor Author

TSMMark commented Oct 31, 2017

It's merged. Closing

@TSMMark TSMMark closed this as completed Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants