-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Why self-closing-comp
allows empty divs?
#572
Comments
Seems like a bug to me. That should be |
@ljharb I'd be sure it is, if there wasn't this in the doc: |
That doesn't make much sense to me - but if it's documented, then it's not a bug. However, I'd love to see an option added to this rule that requires self-closing tags for every kind of tag, including HTML tags. @yannickcr? |
This is the intended behavior. This rule only enforce empty React Components to be self-closed, and HTML tags are not concerned. I think we could modify this rule to check all type of tags by default, then add some options to filter by type (components and/or HTML tags) if needed. It seems to be the more logical behavior to me, but it will be a breaking change. |
Airbnb's React styleguide requires every empty element to be self-closed. Alternatively, we could add an option in a minor version, and then flip the default behavior later, in a major? |
Have the same issue. Is anybody already working on it? If not I'll prepare a pull request, which will add the option suggested by @ljharb and @yannickcr to the rule. |
Just wanted to leave my comment in here for future developers reaching this page. It is always better practice to use As a note, I realize this is ooooold world HTML but it's still very valid today. Cheers! |
jsx isn’t quite html. |
No arguments there, I just figure underlying it may be trying to generate a real DOM |
lol, React generates proper HTML, that's not something anyone needs to worry about :-) |
I noticed that self-closing-comp doesn't report empty divs (eg
<div></div>
). Is there any particular reason that it allows empty html tags? Or it's valid b/c it's valid html?The text was updated successfully, but these errors were encountered: