Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

incorrect "else" block warning #78

Open
GoogleCodeExporter opened this issue Jun 17, 2015 · 0 comments
Open

incorrect "else" block warning #78

GoogleCodeExporter opened this issue Jun 17, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant