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

react/jsx-curly-brace-presence deleting {' '} #2434

Closed
mankittens opened this issue Oct 2, 2019 · 8 comments
Closed

react/jsx-curly-brace-presence deleting {' '} #2434

mankittens opened this issue Oct 2, 2019 · 8 comments

Comments

@mankittens
Copy link

The latest update to eslint-plugin-react says that {' '} violates react/jsx-curly-brace-presence. Running --fix will delete all instances of {' '}.

I don't believe this is appropriate, because in some cases, this is the only way to retain a regular space character between elements. Sure there is &nbsp; and <span> </span>, but those aren't quite the same.

Thoughts?

@ljharb
Copy link
Member

ljharb commented Oct 2, 2019

I believe this is fixed by #2431.

@mankittens
Copy link
Author

Oh, awesome! I'll close this.

@uniqname
Copy link

uniqname commented Oct 2, 2019

I'm not sure #2431 does fix this. I've be wrestling with it most of the day with this and #2431 doesn't seem to address the following use-case:

<>
  foo{' '}
  <span>bar</span>
</>

#2437 attempts to address the above.

@daltones
Copy link
Contributor

daltones commented Oct 6, 2019

Unfortunately, even #2437 didn't fix all cases that used to be correct before v7.15.0.

<>
  {'foo '}
  <span>bar</span>
</>
warning  Curly braces are unnecessary here  react/jsx-curly-brace-presence

(it can be trailling whitespaces on both sides)

@ljharb
Copy link
Member

ljharb commented Oct 6, 2019

@daltones why do you need that case? this:

<>
  foo
  <span>bar</span>
</>

is the same, because all whitespace including newlines collapses in HTML down to one space.

@daltones
Copy link
Contributor

daltones commented Oct 6, 2019

@ljharb yes, in HTML it would, not in JSX.

Your example results in foobar, not foo bar.

@ljharb
Copy link
Member

ljharb commented Oct 6, 2019

in that case, please file a new issue for that and we'll get it fixed.

@taion
Copy link
Contributor

taion commented Oct 9, 2019

ref #2454

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants