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

self-closing-comp warns on elements with whitespace children. #730

Closed
ljharb opened this issue Aug 2, 2016 · 3 comments
Closed

self-closing-comp warns on elements with whitespace children. #730

ljharb opened this issue Aug 2, 2016 · 3 comments
Labels

Comments

@ljharb
Copy link
Member

ljharb commented Aug 2, 2016

<div> </div> is NOT supposed to be self-closing - the whitespace is reduced to a single space, but it's definitely not zero spaces. Currently the rule recommends that this JSX be self-closed, but that would result in the removal of a space.

@ljharb ljharb added the bug label Aug 2, 2016
@petersendidit
Copy link
Contributor

Seems difficult for this rule to know when the space is intentional vs a result of some refactoring. The rule currently supports <div>{' '}</div> as valid. Which helps the rule know that the space is intentional. Seems like if we make the rule support <div> </div> it could miss the more likely case where it was a left over from refactoring.

Seems like it might be better to update the documentation for the rule to show that <div>{' '}</div> is valid.

@ljharb
Copy link
Member Author

ljharb commented Aug 6, 2016

The point of the rule is that I should be able to autofix the violations and not change the meaning of the JSX.

If I have <div> </div> the rule should be telling me to change it to <div>{' '}</div>, but NOT to change it to <div /> - and since it's "self-closing-comp", it should only be warning on things that changing to self-closing is 100% identical.

@ljharb
Copy link
Member Author

ljharb commented Feb 2, 2022

This, and #1717, were fixed by #2210.

@ljharb ljharb closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants