r/javascript • • Sep 12 '16

JavaScript Standard Style Guide

https://github.com/feross/standard
0 Upvotes

29 comments sorted by

View all comments

14

u/PolarZoe Sep 12 '16

"Don't use ;", noped the fuck out.

1

u/kasperpeulen Sep 12 '16

0

u/g_b Sep 13 '16

Automatic semicolon insertion may lead to subtle bugs. Always use semi-colons ffs.

http://stackoverflow.com/questions/12745743/automatic-semicolon-insertion-return-statements

3

u/Klathmon Sep 13 '16

You can't turn off ASI just by using semicolons. Your linked bug will still happen regardless of if you use semicolons or not.

ASI is there, it's ALWAYS going to insert semicolons when they aren't there, so not using them doesn't change anything besides have less typing.

There are exactly 3 places where you need a semicolon. if a line starts with [, (, or ` and in those cases you can just prepend the line with a semicolon like so:

;['one', 'two', 'three'].forEach((thing) => console.log(thing))