gtap-dev / javascript

JavaScript Style Guide
MIT License
0 stars 0 forks source link

21.1 - no semicolons? #7

Closed mjomble closed 2 years ago

mjomble commented 3 years ago

As decided, we won't be leaving semicolons yet, but will open the idea for discussion. Here's a summary of arguments:


CON: "ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues."

Counter-arguments:

We use TypeScript which catches nearly all of these cases. The rest can be caught with ESLint's no-unexpected-multiline rule, which is automatically included in most projects via eslint:recommended.


PRO: Writing, editing and navigating in code becomes simpler and faster, especially with the Estonian layout where typing a semicolon requires pressing two keys.


PRO: (possibly subjective) Code looks and feels cleaner. More pleasant to work with. Life is good again 😍


CON: Hurts consistency across languages. We use a lot of CSS and PHP where semicolons are required. Switching between coding with and without semicolons can be unpleasant.

Counter-arguments: Andres has used semicolon-less JS/TS for years alongside projects where JS/TS has semicolons, as well as CSS and some PHP. It has never been much of an issue for him. Copying code across projects has resulted in errors, but generally both have ESLint enabled and the entire file can be converted in one quick editor action. The few minor inconveniences have so far not outweighed the benefits.