jsx-one-expression-per-line fix option inserts blank lines
See original GitHub issueeslint-plugin-react 7.9.1
If the content of a tag contains only text, extra blank lines are inserted after the text (and the indentation is not correct). If the interior is a jsx expression, the output is correct.
<div>
<MyComponent>a</MyComponent>
<MyOther>{a}</MyOther>
</div>
results in:
<div>
<MyComponent>
a
</MyComponent>
<MyOther>
{a}
</MyOther>
</div>
.eslintrc:
{
"parser": "babel-eslint",
"plugins": [
"react",
"babel"
],
"rules": {
"indent": [1, "tab"],
"react/jsx-one-expression-per-line": 1
}
}
Note: If you leave out indent
it does not insert the extra spaces following the string content but does not indent any of the fixed code.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:10 (5 by maintainers)
Top Results From Across the Web
jsx-one-expression-per-line fix option inserts blank lines #1835
If the content of a tag contains only text, extra blank lines are inserted after the text (and the indentation is not correct)....
Read more >Get the free jsx-one-expression-per-line fix option inserts blank lines
Get the free jsx-one-expression-per-line fix option inserts blank lines ... Fill Online. Quickly fill your document. Save, download, print and share.
Read more >Best practice when adding whitespace in JSX - Stack Overflow
To add a space via JSX, simply put a string consisting of one space character in a JSX expression. The simplest way to...
Read more >Rationale - Prettier
Prettier collapses multiple blank lines into a single blank line. Empty lines at the start and end of blocks (and whole files) are...
Read more >JS.REACT.JSX.ONE.EXPRESSION.PER.LINE
This option limits every line in JSX to one expression each. This rule is automatically fixable using the --fix flag on the command...
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 had the same issue using prettier and prettier-eslint. Every time I saved, it created several new lines between the component and text. Adding following line to my .eslintrc file fixed it for me.
"extends": ["prettier", "prettier/react"]
Below is my package.json since I’m not sure which package messed this up.
Further note: using
"react/jsx-indent": [1, "tab"],
also results in the extra blank lines being inserted.