Earlier quoted context omitted.
Relevant: https://standardjs.com/rules.html#semicolons (hint: no semi-colons!)
Which also recommends ;(function () { window.alert('ok') }()) Which, just, eww. Just use semicolons. Everywhere, always. Then you can treat JS's parsing rules as the same as every other language, and not normally like every other language except when a line begins with one of a select set of magical charaters that need to be prepended with `;` for unclear reasons. Just end lines with `;`.
But that's not always the solution, you still need to know when ASI kicks in and when it doesn't.
"just end lines with ;" isn't true in multi-line arrays, in multi-line objects, and a ton of other situations where a semi at the end of the line is a syntax error. And while i'm sure you know that and didn't actually mean "every" line, it just goes to show that you already have the knowledge of when to add them and when not to. But that knowledge is learned, and it isn't a simple rule by any means.
For example, the following code is probably not going to do what many beginners think it will do:
return
[
1,
2,
3,
];
Because the JS engine will insert a semicolon right after the return, and you will basically get `return undefined;` as the result.Semicolons at the end of lines or not, you still need to understand when they are inserted and when they aren't. The real solution is to use a linter which will check these cases for you. I don't care if you use them or don't, just make sure something else enforces it.