“Automatic Semicolon Insertion (ASI) is a syntactic error correction procedure. If you start to code as if it were a universal significant-newline rule, you will get into trouble.” — @BrendanEich
https://brendaneich.com/2012/04/the-infernal-semicolon/ …
-
-
{ cat script.js | perl -pe "s|^(\s*)\(|\1;(|; s|^(\s*)\[|\1;[|" } solves this problem easy. Prepends { ; } before { ( } or { [ } if its starts from this char. So { var abc\n[1, 2, 3] } become { var abc\n;[1, 2, 3] }
-
That script will break valid code (which means that it does not trigger ASI), e.g., `long_arraylike_expr\n[index] = value`. Need a full parser.
- 2 more replies
New conversation -
-
This Tweet is unavailable.
-
-
He’s fake news
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.