The same way that people who write with semicolons avoid lots of bugs: linters and transpilers and tests.
That said there is only one rule to remember when not writing semicolons, the easy to remember "winky frown" rule: all frowns must wink if they start a line/statement. ;( ;[ ;`
;(The last two are quite rare in my experience.)
It's not that tough of a rule to remember.
;['foo', 'bar'].forEach(function (f) {
it(`has an ${f} field`, function () {
expect(......)
})
}
That said, we tend to use that construct extremely rarely, such as in a few test cases where we are doing the same kinds of things on two groups of items that need different descriptions. ;(thing as Type).methodINeed()
If it weren't for these I mostly wouldn't need semicolons at all, sometimes I refactor to: const thingType = thing as Type
thingType.methodINeed()Who says they don't?
Some people prefer to have sex with children. How do they not get jailed?
Who I can blame is the original parent of this post who was quite confidently stating that omitting semicolons never causes any issues in his code (which is either a statement bounded by scale at which it works for him or it is not error-prone only in specific situations); and then just edited it so that it did not contain that specific line.
That's what you get for having backward compatibility I guess. If the standards committee would break my old code I would probably quit and start a sect. I would call it "ReactReduxReduce" (RRR).
> The point is my students will forget the semicolon in some code that is not properly checked, and it will work. Most of the time. Until it doesn't.
Some people prefer writing JavaScript without semicolons. How do they not have bugs all over the place ? :P