-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
react/jsx-one-expression-per-line #1775
Comments
Indentation should be handled by the |
It looks like neither ESLint Rules:
Original code:
Result of
So while the |
Yes, that seems reasonable. We could perhaps add an option to jsx-indent that covered plain text? |
That sounds like a great idea to me! I would actually benefit from this option. I would do the honors, but unfortunately I do not feel comfortable submitting a PR as I have never done so, and I am not familiar with the procedure. |
Would it be easy to add an option to turn off this rule for plain text content? |
I don’t know if it would be easy, but i think the rule definitely needs two options - one for plain text content, and another for elements with only one child. |
Has anybody found a suitable fix for this in the meantime? |
The only fix, besides someone submitting a PR here, is disabling the rule for the time being. |
@ljharb I noticed this is the last (?) item blocking eslint 5 support in airbnb/javascript. I can take a break from my prop-types work and try to handle this. My understanding is that two options are necessary:
|
That sounds right, and that'd be great - I think that yes, |
<Text>{foo && <Bar />}</Text> A JSXExpressionContainer could contain a lot of different content. I was assuming a single JSXExpressionContainer to qualify for |
ok fair, maybe just "text or numbers" for the |
I think a single |
in that case, let's call the options |
Hmm let's say we <Text>foo
</Text> Should that still warn? Same for |
Yes, I think that the option should only take effect if the single child is on the same line as opening and closing tags. |
There's a bug with the
--fix
part of this rule when you have plain text inside of the jsx element.Original code:
Result of
eslint --fix
:Expected result:
The text was updated successfully, but these errors were encountered: