Permalink
Browse files

eqeq

  • Loading branch information...
douglascrockford committed Jun 12, 2011
1 parent 5a1064b commit ba257de67667a1acfd7c8d1b112d16289d00a77f
Showing with 41 additions and 36 deletions.
  1. +26 −26 jslint.html
  2. +8 −7 jslint.js
  3. +7 −3 lint.html
View
@@ -183,86 +183,86 @@
<td title="devel">Assume&nbsp;<code>console</code>,&nbsp;<code>alert</code>,&nbsp;...</td>
<td><span title="bitwise">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="bitwise">Tolerate bitwise operators</td>
- <td><span title="unparam">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="unparam">Tolerate&nbsp;unused&nbsp;parameters</td>
+ <td><span title="undef">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="undef">Tolerate&nbsp;misordered&nbsp;definitions</td>
</tr>
<tr>
<td><span title="browser">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="browser">Assume a browser</td>
<td><span title="continue">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="continue">Tolerate&nbsp;<tt>continue</tt></td>
- <td><span title="sloppy">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="sloppy">Tolerate&nbsp;missing&nbsp;<code>'use&nbsp;strict'</code>&nbsp;pragma</td>
+ <td><span title="unparam">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="unparam">Tolerate&nbsp;unused&nbsp;parameters</td>
</tr>
<tr>
<td><span title="node">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="node">Assume&nbsp;<a href="http://nodejs.org/">Node.js</a></td>
<td><span title="debug">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="debug">Tolerate&nbsp;<tt>debugger</tt>&nbsp;statements</td>
- <td><span title="sub">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="sub">Tolerate&nbsp;inefficient&nbsp;subscripting</td>
+ <td><span title="sloppy">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="sloppy">Tolerate&nbsp;missing&nbsp;<code>'use&nbsp;strict'</code>&nbsp;pragma</td>
</tr>
<tr>
<td><span title="rhino">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="rhino">Assume&nbsp;<a href="http://www.mozilla.org/rhino/">Rhino</a></td>
+ <td><span title="eqeq">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="eqeq">Tolerate <code>==</code> and <code>!=</code></td>
+ <td><span title="sub">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="sub">Tolerate&nbsp;inefficient&nbsp;subscripting</td>
+ </tr>
+ <tr>
+ <td><span title="widget">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="widget">Assume a&nbsp;<a href="http://widgets.yahoo.com/tools/">Yahoo Widget</a></td>
<td><span title="es5">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="es5">Tolerate&nbsp;ES5&nbsp;syntax</td>
<td><span title="type">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="type">Tolerate&nbsp;type&nbsp;inconsistency</td>
</tr>
<tr>
- <td><span title="widget">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="widget">Assume a&nbsp;<a href="http://widgets.yahoo.com/tools/">Yahoo Widget</a></td>
+ <td><span title="windows">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="windows">Assume&nbsp;Windows</td>
<td><span title="evil">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="evil">Tolerate&nbsp;<tt>eval</tt></td>
<td><span title="vars">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="vars">Tolerate many&nbsp;<tt>var</tt>&nbsp;statements per function</td>
</tr>
<tr>
- <td><span title="windows">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="windows">Assume&nbsp;Windows</td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
<td><span title="forin">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="forin">Tolerate&nbsp;<a href="http://yuiblog.com/blog/2006/09/26/for-in-intrigue/">unfiltered</a>&nbsp;<tt>for</tt>&nbsp;<tt>in</tt></td>
<td><span title="white">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="white">Tolerate&nbsp;messy&nbsp;white space</td>
</tr>
- <tr>
- <td>&nbsp;</td>
- <td>&nbsp;</td>
- <td><span title="newcap">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="newcap">Tolerate uncapitalized constructors</td>
- <td>&nbsp;</td>
- <td title="sloppy">&nbsp;</td>
- </tr>
<tr>
<td><span title="passfail">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="passfail">Stop&nbsp;on&nbsp;first&nbsp;error</td>
- <td><span title="nomen">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="nomen">Tolerate dangling&nbsp;<tt>_</tt>&nbsp;in identifiers</td>
+ <td><span title="newcap">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="newcap">Tolerate uncapitalized constructors</td>
<td><span title="css">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="css">Tolerate&nbsp;CSS&nbsp;workarounds</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
- <td><span title="plusplus">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="plusplus">Tolerate&nbsp;<tt>++</tt>&nbsp;and&nbsp;<tt>--</tt></td>
+ <td><span title="nomen">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="nomen">Tolerate dangling&nbsp;<tt>_</tt>&nbsp;in identifiers</td>
<td><span title="cap">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="cap">Tolerate&nbsp;<tt>HTML</tt>&nbsp;case</td>
</tr>
<tr>
<td><span title="safe">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="safe">Safe&nbsp;Subset</td>
- <td><span title="regexp">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="regexp">Tolerate&nbsp;<tt>.</tt>&nbsp;and&nbsp;<tt>[^</tt>...<tt>]</tt>&nbsp;in&nbsp;/RegExp/</td>
+ <td><span title="plusplus">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="plusplus">Tolerate&nbsp;<tt>++</tt>&nbsp;and&nbsp;<tt>--</tt></td>
<td><span title="on">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="on">Tolerate&nbsp;<tt>HTML</tt>&nbsp;event handlers</td>
</tr>
<tr>
<td><span title="adsafe">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="adsafe">Verify&nbsp;<a href="http://www.ADsafe.org">ADsafe</a></td>
- <td><span title="undef">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="undef">Tolerate&nbsp;misordered&nbsp;definitions</td>
+ <td><span title="regexp">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td title="regexp">Tolerate&nbsp;<tt>.</tt>&nbsp;and&nbsp;<tt>[^</tt>...<tt>]</tt>&nbsp;in&nbsp;/RegExp/</td>
<td><span title="fragment">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="fragment">Tolerate&nbsp;<tt>HTML</tt>&nbsp;fragments</td>
</tr>
View
@@ -1,5 +1,5 @@
// jslint.js
-// 2011-06-08
+// 2011-06-10
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -163,6 +163,7 @@
// css true, if CSS workarounds should be tolerated
// debug true, if debugger statements should be allowed
// devel true, if logging should be allowed (console, alert, etc.)
+// eqeq true, if == should be allowed
// es5 true, if ES5 syntax should be allowed
// evil true, if eval should be allowed
// forin true, if for in statements need not filter
@@ -202,9 +203,9 @@
// For example:
/*properties '\b', '\t', '\n', '\f', '\r', '!=', '!==', '"', '%',
- '&', '\'', '(begin)', '(breakage)', '(complexity)', '(context)',
- '(error)', '(function)', '(identifier)', '(line)', '(loopage)',
- '(name)', '(object)', '(params)', '(scope)', '(statement)', '(string)',
+ '&', '\'', '(array)', '(begin)', '(breakage)', '(complexity)', '(context)',
+ '(error)', '(function)', '(identifier)', '(line)', '(loopage)', '(name)',
+ '(number)', '(object)', '(params)', '(scope)', '(statement)', '(string)',
'(token)', '(vars)', '(verb)', ')', '*', '+', '-', '/', ';', '<',
'<<', '<=', '==', '===', '>', '>=', '>>',
'>>>', ADSAFE, ActiveXObject, Array, Boolean, Buffer, COM,
@@ -259,7 +260,7 @@
devel, dfn, dialog, dimgray, dir, direction, display, disrupt, div, dl,
document, dodgerblue, dt, duplicate_a, edge, edition, else, em, embed,
embossed, empty, 'empty-cells', empty_block, empty_case, empty_class,
- encodeURI, encodeURIComponent, entityify, errors, es5, escape, eval,
+ encodeURI, encodeURIComponent, entityify, eqeq, errors, es5, escape, eval,
event, evidence, evil, ex, exception, exec, expected_a,
expected_a_at_b_c, expected_a_b, expected_a_b_from_c_d, expected_at_a,
expected_attribute_a, expected_attribute_value_a, expected_class_a,
@@ -3176,7 +3177,7 @@ klass: do {
function relation(s, eqeq) {
return infix(s, 100, function (left, that) {
check_relation(left);
- if (eqeq) {
+ if (eqeq && !option.eqeq) {
warn('expected_a_b', that, eqeq, that.id);
}
var right = expression(100);
@@ -6847,7 +6848,7 @@ klass: do {
};
itself.jslint = itself;
- itself.edition = '2011-06-08';
+ itself.edition = '2011-06-10';
return itself;
View
@@ -270,10 +270,10 @@ <h2 id=assignment>=</h2>
}</pre>
<p>It is difficult to write correct programs while using idioms that are
hard to distinguish from obvious errors.</p>
-<h2 id=equal>== and !=</h2>
+<h2 id=eqeq>== and !=</h2>
<p>The <code>==</code> and <code>!=</code> operators do type coercion before
comparing. This is bad because it causes <code>' \t\r\n' == 0</code> to
- be <code>true</code>. This can mask type errors.</p>
+ be <code>true</code>. This can mask type errors. JSLint cannot reliably determine if == is being used correctly, to it is best to not use <code>==</code> and != and use the more reliable the <code>===</code> and <code>!==</code> operators instead. </p>
<p align="left">If you only care that a value is <i>truthy</i> or <i>falsy</i>,
then use the short form. Instead of </p>
<pre align="left">(foo != 0)</pre>
@@ -283,7 +283,7 @@ <h2 id=equal>== and !=</h2>
<pre align="left">(foo == 0)</pre>
<p align="left"> say</p>
<pre align="left">(!foo)</pre>
-<p>Always use the <code>===</code> and <code>!==</code> operators. </p>
+<p>There is an <code>eqeq</code> <a href="#options">option</a> that allows the use of <code>==</code> and <code>!=</code>.</p>
<h2 id=labels>Labels</h2>
<p>JavaScript allows any statement to have a label, and labels have a
separate name space. <code>JSLint</code> is more strict.</p>
@@ -492,6 +492,10 @@ <h2 id=options>Options</h2>
<td><code>true</code> if browser globals that are useful in development should be
predefined. (<a href="#devel">more</a>)</td>
</tr>
+ <tr>
+ <td>Tolerate <code>==</code> and <code>!=</code></td>
+ <td><code>eqeq</code></td>
+ <td><code>true</code> if the <code>==</code> and <code>!=</code> operators should be tolerated. (<a href="#eqeq">more</a>).</td>
<tr>
<td>Tolerate ES5 syntax</td>
<td><code>es5</code></td>

0 comments on commit ba257de

Please sign in to comment.