jsx-one-expression-per-line should ignore inline elements
See original GitHub issueIt doesn’t seem to make sense to one-line inline elements.
For example, one-lining the em
element in the example below doesn’t make sense.
<Styled.PasswordInstructions errored={ !!formErrors.userPassword }>
Passwords must be at least 8 characters long and can't be
things like <em>password</em>, <em>123456</em> or <em>abcdef</em>.
</Styled.PasswordInstructions>
Here is the “fixed” version.
<Styled.PasswordInstructions errored={ !!formErrors.userPassword }>
Passwords must be at least 8 characters long and can't be
things like
<em>
password
</em>
,
<em>
123456
</em>
or
<em>
abcdef
</em>
.
</Styled.PasswordInstructions>
I could also see an option allowing the developer to choose which elements to ignore along with an ignoreInline
option.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:50
- Comments:21 (9 by maintainers)
Top Results From Across the Web
jsx-one-expression-per-line should ignore inline elements
It doesn't seem to make sense to one-line inline elements. For example, one-lining the em element in the example below doesn't make sense....
Read more >Eslint react/jsx-one-expression-per-line: allow variables and ...
javascript - Eslint react/jsx-one-expression-per-line: allow variables and JSX strings on the same line, but not elements - Stack Overflow. ...
Read more >Conditional Rendering - React
Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update the UI to...
Read more >node_modules/eslint-plugin-react ... - GitLab
If you installed ESLint globally, you have to install React plugin globally too. ... react/jsx-one-expression-per-line: Limit to one expression per line in ...
Read more >React, Part I: JSX Cheatsheet - Codecademy
A JSX expression that spans multiple lines must be wrapped in parentheses: ( and ) . In the example code, we see the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I recently had to disable
react/jsx-one-expression-per-line
because it made things like this much harder to read:Result:
What I want to prevent is someone trying to inline nested tags. I don’t care about people using
<span>ABC</span>
– that’s easy enough to read. I can understand why the lint rule current does what it does but it would be handy to have an option to ignore inlined non-tag expressions.See #1855; I think they’re related.