Permalink
Browse files

Cleanups with Johan's input.

  • Loading branch information...
1 parent caae445 commit 43968a1a45a2b6b2e8cb0002dc4448c3f55d0a21 @arantius arantius committed Jun 2, 2010
Showing with 3 additions and 4 deletions.
  1. +1 −3 contrib.html
  2. +2 −1 style.html
View
@@ -21,9 +21,7 @@ <h2>Git</h2>
<h2>Change One Thing</h2>
-<p>When proposing a change to the source code, change exactly one thing. Do not refactor some existing code, and add new code for a new feature at the same time. Do not mix </p>
-
-<p>
+<p>When proposing a change to the source code, change exactly one thing. Do not refactor some existing code, and add new code for a new feature at the same time.</p>
<h2>Be Inclusive</h2>
View
@@ -91,6 +91,7 @@ <h2>Function and variable naming</h2>
<li>Event handler functions should be prefixed with the word on, in particular try to use the names onLoad, onDialogAccept, onDialogCancel, etc., where this is unambiguous.</li>
<li>Function names, local variables, and object members have no prefix.</li>
<li>Try to declare local variables as near to their use as possible; initialize every variable.</li>
+<li>Only declare a variable once in each scope.</li>
</ul>
<h2>JavaScript Features</h2>
<ul>
@@ -109,7 +110,7 @@ <h2>JavaScript Features</h2>
<h2>Suggestions</h2>
<p>These guidelines are not hard and fast rules, but almost always a good idea. Please try to follow them.</p>
<ul>
-<li>Be very careful about assignments that are also used in a boolean context, e.g. <pre>while (node = node.parentNode) { /* ... */ }</pre> Try to avoid such usage, or carefully comment that testing the result of an assignment as a boolean is actually intended. (Common exception: iterating over an array with <code>for</code>.)</li>
+<li>Be very careful about assignments that are also used in a boolean context, e.g. <pre>while (node = node.parentNode) { /* ... */ }</pre> or <pre>for (var i=0, item; item=array[i]; i++) { /* ... */ }</pre>This can be a common source of subtle bugs.</li>
<li>When a <code>switch</code> statement's <code>case</code> contains a body, and intentionally falls through to the next (with no <code>break</code>), add a comment like <code>// fall-through</code> to make it clear that this is intended.</li>
<li>Don't use <code>eval()</code> or equivalents if there is any other possible way to accomplish the goal.</li>
<li>Don't use <code>setTimeout()</code> or equivalents with string parameters, only function references. Generally avoid <code>setTimeout()</code> if at all possible &mdash; if not, comment why it was used.</li>

0 comments on commit 43968a1

Please sign in to comment.