threeapples307 / closure-linter

Automatically exported from code.google.com/p/closure-linter
Apache License 2.0
0 stars 0 forks source link

incorrect "else" block warning #78

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sometimes I write code formatted like this:
----------
if (condA) {
    console.log('A');
} else // <- ?
if (condB) {
    console.log('B');
} else {
    console.log('else')
}
----------
(I do this when condA and condB are symmetrical and could be swapped without 
side-effects).

In this case linter complains "Missing semicolon at end of line" (line 3).
I.e it seems to believe I should add a semicolon directly at "else;".
This is clearly am incorrect warning.
(If I do add a ";" it luckily catches that and reports as an error).

---------

A second note is that linter doesn't seem to enforce any particular style for 
the last "else" though. I can write all combos of else and braces without 
complaint. 
----
} else {
 ..
}

---
} else
{
..
}
--- 
}
else
{
..
}
------

To me this kindof indicates I could be allowed to format middle "else" to my 
liking too? (I don't find anything about this if-else in the Google code style 
guide either. Although I'm aware that writing "else if" on same line is more 
common).

Regards
/ Fredrik Blomqvist

Original issue reported on code.google.com by fblomqvist@gmail.com on 18 Oct 2013 at 8:38