You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forgive me if this information isn't meant to be included in the documentation, I opened it here because it's more of a question than a problem and I think others would benefit.
In VSCode the rule description is as follows:
JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
That sentence is missing from the online docs, but it's pretty assertive that self-closing tags are always good and there is never a difference. If that's the case, why is the fix marked unsafe?
Expectations
In situations like this, I'd like to understand why the fix is unsafe, so that I can decide whether or not to apply it.
Sometimes it's obvious, such as the lint that prefers ? over ! in nonnull assertions, but seems to me that self-closing tags are semantically identical to empty tags, so I'm unsure here.
If it's marked unsafe not because of the semantics but rather because the fix implementation isn't completely reliable, that makes sense to me, but I think it'd be useful to clarify that in the documentation. I might even take that a step further and propose adding a new category alongside "safe" and "unsafe" - "safe in theory, but might not be perfect yet so make sure to double check it".
Cheers!
Code of Conduct
I agree to follow Biome's Code of Conduct
The text was updated successfully, but these errors were encountered:
The fix is really unsafe because it could break somebody's code due to the nature of JavaScript.
Sometimes, we (maintainers) aren't confident about the stability of the code fix because it might miss some use cases.
Generally, if a code fix is unsafe due to 2., then we aim to make it safe with time by adding more cases. And we might forget about it! It can happen
Regarding this particular rule, this was one of the first rules that was created and I believe we eventually forgot to update it. In fact, the documentation is very poor and the message is incorrect (what's SelfClosingElement anyway??). I think we forgot to follow up and make the rule fix safe :)
Thank you for bringing it up, I will open an issue
Documentation URL
https://biomejs.dev/linter/rules/use-self-closing-elements/
Description
Forgive me if this information isn't meant to be included in the documentation, I opened it here because it's more of a question than a problem and I think others would benefit.
In VSCode the rule description is as follows:
That sentence is missing from the online docs, but it's pretty assertive that self-closing tags are always good and there is never a difference. If that's the case, why is the fix marked unsafe?
Expectations
In situations like this, I'd like to understand why the fix is unsafe, so that I can decide whether or not to apply it.
Sometimes it's obvious, such as the lint that prefers
?
over!
in nonnull assertions, but seems to me that self-closing tags are semantically identical to empty tags, so I'm unsure here.If it's marked unsafe not because of the semantics but rather because the fix implementation isn't completely reliable, that makes sense to me, but I think it'd be useful to clarify that in the documentation. I might even take that a step further and propose adding a new category alongside "safe" and "unsafe" - "safe in theory, but might not be perfect yet so make sure to double check it".
Cheers!
Code of Conduct
The text was updated successfully, but these errors were encountered: