Index: pages/coding-style.html |
diff --git a/pages/coding-style.html b/pages/coding-style.html |
index 553402cd508a746e0587e41d989f54f1b2d588b0..3b734d771f8a84b1854ec58f792eb94cfce4c9b8 100644 |
--- a/pages/coding-style.html |
+++ b/pages/coding-style.html |
@@ -24,9 +24,16 @@ title=Coding Style |
<h2 id="javascript">{{s14 JavaScript}}</h2> |
<ul> |
<li>{{s15 Follow the Mozilla Coding Style's <a href="https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style#JavaScript_practices">JavaScript practices</a>.}}</li> |
- <li>{{s16 Opening braces of object literals in don't go on their own line when that would cause a syntax error.}}</li> |
- <li>{{s17 Use <code>bind()</code> to ensure the desired value of the <code>this</code> variable, don’t use temporary variables as a replacement.}}</li> |
+ <li>{{javascript-opening-braces Opening braces of object literals don't go on their own line when that would cause a syntax error.}}</li> |
kzar
2017/01/17 06:48:52
(I noticed an extra word "in" in this rule.)
|
<li>{{s18 In classes, prefix private functions with a single underscore to make them pseudo-private.}}</li> |
+ <li>{{javascript-block-scoping If supported, use <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/block">block-scoping</a> (<code><fix>let</fix></code>), except when sharing global variables between scripts cannot be avoided.}}</li> |
Sebastian Noack
2017/01/17 22:31:38
The MDN page linked here explains code blocks in g
kzar
2017/01/18 06:33:51
Done.
|
+ <li>{{javascript-arrow Use the <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow function</a> syntax when passing anonymous functions when the binding of <code><fix>this</fix></code> and <code><fix>arguments</fix></code> is not required.}}</li> |
Sebastian Noack
2017/01/17 22:31:38
Two times "when" reads quite weird too me. Also I
kzar
2017/01/18 06:33:51
Done.
|
+ <li>{{javascript-this When required (and when arrow functions cannot be used) use <code><fix>bind()</fix></code> to ensure the desired value of the <code><fix>this</fix></code> variable, don’t use temporary variables as a replacement.}}</li> |
saroyanm
2017/01/17 12:26:05
bind is not supported in IE8, websites does suppor
Sebastian Noack
2017/01/17 22:31:38
Note that this rule isn't new (see s17 above). It
kzar
2017/01/18 06:33:52
I agree let's just remove this rule, it's not real
|
+ <li>{{javascript-method Use the <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Method_definitions">method definition shorthand</a> syntax when defining methods on an object.}}</li> |
saroyanm
2017/01/17 12:26:05
I think this applies only to where it's supported.
Sebastian Noack
2017/01/17 22:31:38
Yeah, I think we should prefix all rules that requ
kzar
2017/01/18 06:33:52
Good point Manvel, I moved all the modern JavaScri
|
+ <li>{{javascript-strict Always use <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode">strict mode</a>.}}</li> |
Sebastian Noack
2017/01/17 22:31:38
This being a fundamental rule (not addressing a sp
kzar
2017/01/18 06:33:51
Yea good idea, I've done that but gone one better
|
+ <li>{{javascript-if-else-braces When an <code><fix>if</fix></code> statement, an <code><fix>else</fix></code> statement or a loop spans over more than one line always enclose it with braces. When an <code><fix>if</fix></code> or <code><fix>else</fix></code> statement uses braces the opposing block should do too.}}</li> |
+ <li>{{javascript-for-of If supported, use <code><fix>for..of</fix></code> when iterating over arrays in canonical order, rather than using <code><fix>for(;;)</fix></code> or the <code><fix>forEach()</fix></code> method. (Excepting when the loop index is required.)}}</li> |
Sebastian Noack
2017/01/17 22:31:38
How about addressing the loop index case together
kzar
2017/01/18 06:33:51
Done.
|
+ <li>{{javascript-object-proto Use the <code><fix>Map</fix></code> or <code><fix>Set</fix></code> data types rather than <code><fix>Object.create(null)</fix></code> when possible. (Never use <code><fix>{__proto__: null}</fix></code> and otherwise avoid the use of <code><fix>__proto__</fix></code>.)}}</li> |
Sebastian Noack
2017/01/17 22:31:38
As per MDN documentation the terminology is Map/Se
kzar
2017/01/18 06:33:52
I've split up the rule talking about `__proto__` f
|
</ul> |
<h2 id="html-css">{{html-css HTML and CSS}}</h2> |