-
Task
-
Resolution: Unresolved
-
Minor
-
None
-
4.1
-
None
-
MOODLE_401_STABLE
Creating this as a placeholder to explore the creation of a new coding style for JavaScript.
At the moment we have a legacy policy, but it has been marked as deprecated because it is not very compatible with modern (ESM) JavaScript, and leads to what are now regarded as poor practices.
One example is that we mandate that all var are grouped together and comma-separated, for example:
var foo,
|
bar,
|
baz,
|
bum;
|
This example is not recommended because in ESM we use const and let which have different scoping, and we typically prefer the use of const wherever possible - which is difficult to do when it's a constant relying on a previous constant.
Another example is our naing for "CONSTANTS", which is all uppercase. I'd argue that this is something that is not typically seen in JS and we should probably stick with what others do and keep oru JS closer to common standards.
Rather than writing our own JS Coding Style, I'd suggest that we look to follow a style that we are already largely following - specifically the AirBNB style. It's widely used in the industry. https://github.com/airbnb/javascript