You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prettier has a option to toggle semicolons, which should nearly always be set to "have semi colons".
The now defunct "Standard JS" lint style espoused not having them for conciseness but unfortunately they aren't truly optional. The way most engines figure out if a semi colon is needed is by throwing an exception, seeing if a semi colon put in the exception location fixes it, then carrying on.
As you might imagine this can lead to slower compiles and some truly devilish bugs.
The text was updated successfully, but these errors were encountered:
What kind of bugs are you imagining? I've built JS apps without semicolons for over two years and literally never had an issue.
Also
The way most engines figure out if a semi colon is needed is by throwing an exception, seeing if a semi colon put in the exception location fixes it, then carrying on.
Source? As a lapsed compiler geek this sounds unlikely, but maybe I'm underestimating the complexity of JS 😅
Also, semicolons get inserted during minification so this shouldn't matter anyway.
That was an interesting talk 👍 Luckily ambiguous syntax can be avoided with an eslint rule: https://eslint.org/docs/rules/semi#options – and prettier will respect using semicolons in those (extremely rare) situations too. So it's completely safe to not use semicolons 🎉 yay, tooling!
Prettier has a option to toggle semicolons, which should nearly always be set to "have semi colons".
The now defunct "Standard JS" lint style espoused not having them for conciseness but unfortunately they aren't truly optional. The way most engines figure out if a semi colon is needed is by throwing an exception, seeing if a semi colon put in the exception location fixes it, then carrying on.
As you might imagine this can lead to slower compiles and some truly devilish bugs.
The text was updated successfully, but these errors were encountered: