question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react/jsx-one-expression-per-line

See original GitHub issue

There’s a bug with the --fix part of this rule when you have plain text inside of the jsx element.

Original code:

const something = () => (
  <Text>Plain text</Text>
)

Result of eslint --fix:

const something = () => (
  <Text>
Plain text
  </Text>
)

Expected result:

const something = () => (
  <Text>
    Plain text
  </Text>
)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

9reactions
temowemocommented, May 7, 2018

It looks like neither indent nor react/jsx-indent can perform the proper indentation in this case unless you wrap “Plain Text” in brackets and quotes like so:

ESLint Rules:

"react/jsx-one-expression-per-line": "error",
"react/jsx-indent": ["error", 2]

Original code:

const something = () => (
  <Text>{"Plain text"}</Text>
)

Result of eslint --fix:

const something = () => (
  <Text>
    {"Plain text"}
  </Text>
)

So while the react/jsx-one-expression-per-line rule should definitely not be expected to perform indentation, maybe react/jsx-indent should handle this indentation problem?

6reactions
ljharbcommented, Jul 6, 2018

The only fix, besides someone submitting a PR here, is disabling the rule for the time being.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-react/jsx-one-expression-per-line.md at master
This option limits every line in JSX to one expression each. Note: The fixer will insert line breaks between any expression that are...
Read more >
Eslint react/jsx-one-expression-per-line: allow variables and ...
Eslint react/jsx-one-expression-per-line: allow variables and JSX strings on the same line, but not elements · Subscribe to RSS.
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 >
https://docs.roguewave.com/en/klocwork/current/js....
No information is available for this page.
Read more >
eslint-plugin-react/README.md - UNPKG
The CDN for eslint-plugin-react. ... 215, | | | [react/jsx-one-expression-per-line](docs/rules/jsx-one-expression-per-line.md) | Limit to one expression ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found