Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: pages/coding-style.html

Issue 29371951: Noissue - Add some more JavaScript coding guidlines (Closed)
Patch Set: Created Jan. 16, 2017, 7:04 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pages/coding-style.html
diff --git a/pages/coding-style.html b/pages/coding-style.html
index 553402cd508a746e0587e41d989f54f1b2d588b0..5429e2809fffbaa042804fc9e4b403bd581836cf 100644
--- a/pages/coding-style.html
+++ b/pages/coding-style.html
@@ -25,8 +25,15 @@ title=Coding Style
<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-this Use <code>bind()</code> (or arrow functions) to ensure the desired value of the <code>this</code> variable, don’t use temporary variables as a replacement.}}</li>
Sebastian Noack 2017/01/16 17:07:14 For code snippets please also use the <fix> tag, s
Sebastian Noack 2017/01/16 17:07:14 I think this should go below the rule for arrow fu
kzar 2017/01/17 06:48:51 Done.
kzar 2017/01/17 06:48:51 Done.
<li>{{s18 In classes, prefix private functions with a single underscore to make them pseudo-private.}}</li>
+ <li>{{javascript-let Use <code>let</code> or better yet <code>const</code> for variable definitions where possible instead of <code>var</code>.}}</li>
Sebastian Noack 2017/01/16 17:07:14 I find this rule a little too vague. How about:
kzar 2017/01/17 06:48:51 Done.
+ <li>{{javascript-arrow Use the <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow function</a> syntax for anonymous functions when the binding of <code>this</code> and <code>arguments</code> is not required.}}</li>
Sebastian Noack 2017/01/16 17:07:14 Arrow functions automatically bind "this". So it s
kzar 2017/01/17 06:48:51 Well I think arrow functions simply close over the
+ <li>{{javascript-method Use the <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Method_definitions">method definition</a> syntax where possible, even in preference to arrow functions.}}</li>
Sebastian Noack 2017/01/16 17:07:14 I don't like how we overrule another rule here (i.
Sebastian Noack 2017/01/16 17:07:14 "method definition" is ambiguous as the old syntax
kzar 2017/01/17 06:48:51 Done.
kzar 2017/01/17 06:48:51 Done.
kzar 2017/01/17 06:48:51 Done.
+ <li>{{javascript-strict Where possible always use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode">strict mode</a>.}}</li>
Sebastian Noack 2017/01/16 17:07:14 Why the "where possible" restriction? Is there any
kzar 2017/01/17 06:48:51 Done.
+ <li>{{javascript-if-else-braces When an <code>if</code>, <code>else</code> or <code>loop</code> statement spans over more than one line always enclose it with braces. When an <code>if</code> or <code>else</code> statement uses braces the other half should do too.}}</li>
Sebastian Noack 2017/01/16 17:07:14 "other half" doesn't sound too technically accurra
Sebastian Noack 2017/01/16 17:07:14 "loop" isn't a literal code snippet, so it shouldn
kzar 2017/01/17 06:48:51 Done.
kzar 2017/01/17 06:48:52 Done.
+ <li>{{javascript-for-of When iterating through Arrays and similar prefer <code>for (let item of array)</code> loops to traditional <code>for (let i=0; i < array.length; i++)</code> or even <code>array.forEach(...)</code> unless there is a good reason to do otherwise.}}</li>
Sebastian Noack 2017/01/16 17:07:14 I think we are really only talking about arrays he
kzar 2017/01/17 06:48:51 Done.
+ <li>{{javascript-object-proto Use <code>Object.create(null)</code> instead of <code>{__proto__: null}</code> and otherwise avoid the use of <code>__proto__</code>.}}</li>
Sebastian Noack 2017/01/16 17:07:14 Well, by now, you should rather use Map or Set obj
kzar 2017/01/17 06:48:52 Done.
</ul>
<h2 id="html-css">{{html-css HTML and CSS}}</h2>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld