There are a few areas I wanted to share my opinion on but, more importantly, get the community opinion on:
Use of Semicolon
There was a question in a recent PR on github (#15823) regarding the use of semicolons in Javascript. The author pointed out that they are generally not required when terminating statements. While true, the bottom line is that they are needed but are injected by the compiler automatically when not present. The vast majority of the time the automatic placement will be correct, but it’s not 100% guaranteed. I believe—especially when code is being created and maintained by several authors—that if ever a particular element is needed for code to execute properly (in this case the semicolon, but another example would be curly braces) it should always be used.
The other argument I’d put forth is that the other scripting languages used in a project might inform the overall code style as well. For instance, here we have PHP and Javascript. PHP absolutely requires semicolons to terminate statements. So from a continuity standpoint, it’s less error prone to simply use them across the entire codebase. No need to switch gears everytime you’re coding in one language or the other.
- Yes, always use
- No, only when required
0 voters
Curly Braces
Again, as with the semicolon, these can be optional in certain circumstances (in both languages). I’d make the same argument here as above: Always use them to minimize mistakes. (Also IMO code just reads more nicely when the style is 100% consistent.)
- Yes, always use
- No, only when required
0 voters
Commas in Ext JS Config Objects
One thing that really drives me crazy is the placement of commas at the beginning of object properties, instead of at the end. I understand that this was somehow easier for the original author(s) when developing the Ext end of things, but it’s completely non-standard and doubtful to pass a linter. I want to strongly suggest that style is backed out of the entire codebase and standardized moving forward. I’ve continued writing this way for the core files so as to not introduce inconsistency, but please, let’s normalize the style here.
- Yes, always place commas at end of properties and method definitions
- No, keep commas at beginning
0 voters
That’s it. Thanks for reading and participating!