Warn if <If> or <Else> or <For> are empty
texttechne opened this issue · 3 comments
In the next release an empty control statement, i.e. without child element, will not throw an error. However, a warning makes sense in these cases.
I'm not actually sure if it makes sense to warn in such cases. It would be like if function(){}
warned in javascript. Obviously that is a suspicious expression, but it's a perfectly valid/legitimate one.
I argue that it's really easy to see that the <if></if>
block is empty, so the warning isn't helping the user catch a subtle mistake. And it's also not detrimental to the application (ie. a memory leak is detrimental), so I'm not sure there is any benefit to emitting a warning in this situation.
Convinced.
The warning level can be controlled by setting jsx-if-single-child
value to 1
(for warning) or 2
(for error).
As for allowing empty <If></If>
, blocks, I'm open to adding a setting/option.