But unfortunately there are edge cases where that won’t happen and your code will break. Hard.
So people who are against typing semicolons usually just say: “well you just have to remember the edge cases where you have to put them, and all is well”. But is that really a good thing? I can see a lot of disadvantages by not putting semicolons into your code:
- you end up with the worst of both worlds; for the most part no semicolons, but then every once in a while, a semicolon
- you have to keep the edge cases in your head all the time while coding, and that takes precious brain resources away from you
- what happens when you concatenate files and you don’t have control over what’s on top & bottom of your code? Uh, right, you start & end your file with a semicolon just to make sure you haven’t started off from an edge case, or setup a new one for the code under you
Same goes for putting curly brackets on a new line.
Now, isn’t it easier to just put semicolons everywhere (and always put the opening curly bracket on the same line) and forget about it? The only thing you have to do is put a semicolon at the start of a file if you are working in a “hostile” environment. But seeing how you’re already using them everywhere else it won’t look as out of place.