5 ms·
Everything will be fine if you don't use semicolons. My team and I haven't, for years now. It's really, really, truly honestly ok. I promise. (Only exception is
by draw_down 11y ago
Everything will be fine if you don't use semicolons. My team and I haven't, for years now. It's really, really, truly honestly ok. I promise. (Only exception is for-loops)
- Zecc 11y agolet sql = `delete from order_lines` ` where order_id = ${orderId}`; Without a lint complaining about a missing semicolon you wouldn't notice this bug. This has happened to me with a rather more complex query.
- recursive 11y agoAccording to the link, you have resort to this kind of weirdness in order to reliably omit semicolons. ;[1, 2, 3].forEach(bar) To my eye, having that in my code looks far worse than just using "standard" (ha ha) semicolons. You mention a for loop exception as well. I don't understand what that exception is, but the general message seems to be "Trust me, you can totally omit semicolons! Everything is ok! Except for all these weird edge cases, but you can just hack kludges around them!"
- emodendroket 11y agoI assume it's that you have to separate the three parts of the for loop arguments with semicolons
- draw_down 11y ago(Apologies for the delay, I had to wait to respond since the lovely people in this discussion have downvoted me) Yes, people like to bring up these goofball edge cases that don't actually happen in real life. Tell me, when was the last time you mapped over an array literal? I'm serious, it has been years now, it is ok not to use semicolons in Javascript. People just need to... unclench. It is ok not to use them. I don't know what hellfire and brimstone people expect to happen when they stop using semicolons but it isn't going to happen. The for-loop thing is that semicolons are required to delimit the initialization, condition, and increment of a for-loop. So you use them there. See, this is the thing - not using semicolons to terminate statements is nicer than using them (pure opinion of course), and it doesn't cause problems in practice. But it would be ridiculous to take some hard-line stance of "absolute zero semicolons ever". The point is not that we hate the semicolon glyph or something, the point is that you don't need them to terminate statements, so we don't.
- recursive 11y agoI do this... pretty damn frequently. They totally happen in my real life. (function(a1, a2) { // something })(arg1, arg2);