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
Thanks for the report. If you enable JSHint's curly option, then you will receive warnings about the use of a "brace-less" if statements. That will catch the type of programming mistakes that your example describes. Does that work for you?
Sure, that would catch this mistake, but sometimes I want to use a braceless if statement so I'll just work without enabling that option. It took me a few minutes to spot the semi-colon. I debugged and couldn't believe my eyes when the condition evaluated to false and my if-block still executed. I guess this is legal JavaScript: a braceless if-statement followed by a block statement. It just seemed to me like this was a perfect spot for jshint to give a warning like "Did you intend to write a braceless if-statement followed by an unlabelled block-statement or is the semi-colon after the if-condition a mistake?" Maybe it is such an edge case though that it's not worth implementing but I just thought I'd pass it along in case. It's my reflex of adding semi-colons at the end of lines that bit me. Thanks for the quick response and congrats on the great tool!
if (false);
{
alert('this will execute. The semi-colon after the if-condition is likely a mistake but no warning is given');
}
The text was updated successfully, but these errors were encountered: