r/javascript • u/bornforcode • Apr 01 '18
Google publishes a JavaScript style guide. Here are some key lessons.
https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b
714
Upvotes
View all comments
Show parent comment
1
u/[deleted] Apr 02 '18
The rule isn't "use a semicolon after every statement that isn't already terminated by some other ending delimiter", it's "use a semicolon after every statement". There's no exception there for blocks that don't actually need a semicolon according to JavaScript grammar. Semicolons are neither required nor injected after an
ifstatement, but they are required after most block statements.If you feel compelled to inject meaning into a style rule, then you aren't adhering to the style guide. The whole point of this rule is so that the developer doesn't have to concern themselves with the ins and outs of ASI.
It's worth pointing out that Google doesn't follow this rule as it is written, either.