Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tolerate

  • Loading branch information...
commit a27d17cd4683a9f0cf6649f5977f72e8a55f3ecb 1 parent b4b188e
@douglascrockford authored
Showing with 154 additions and 166 deletions.
  1. +1 −10 init_ui.js
  2. +52 −62 jslint.html
  3. +72 −61 jslint.js
  4. +29 −33 lint.html
View
11 init_ui.js
@@ -1,5 +1,5 @@
// init_ui.js
-// 2011-05-31
+// 2011-06-08
// This is the web browser companion to fulljslint.js. It is an ADsafe
// lib file that implements a web ui by adding behavior to the widget's
@@ -22,7 +22,6 @@ ADSAFE.lib("init_ui", function (lib) {
return function (dom) {
var table = dom.q('#JSLINT_TABLE'),
boxes = table.q('span'),
- goodparts = boxes.q('.goodpart'),
indent = dom.q('#JSLINT_INDENT'),
input = dom.q('#JSLINT_INPUT'),
jslintstring = dom.q('#JSLINT_JSLINTSTRING'),
@@ -171,14 +170,6 @@ ADSAFE.lib("init_ui", function (lib) {
show_options();
});
- dom.q('#JSLINT_GOODPARTS').on('click', function () {
- goodparts.each(function (bunch) {
- ADSAFE.set(option, bunch.getTitle(), true);
- });
- option.indent = 4;
- show_options();
- });
-
table.on('click', update_box);
indent.on('change', update_number);
maxerr.on('change', update_number);
View
114 jslint.html
@@ -166,7 +166,6 @@
WARNING: JSLint can help you improve the quality of your programs.
</div>
</div>
-<p id="JSLINT_JSLINTSTRING"></p>
<pre id="JSLINT_TREE"></pre>
<p>
<input type="button" name="jslint" value="JSLint">
@@ -174,112 +173,102 @@
<input type="button" name="tree" value="Syntax Tree">
&nbsp; &nbsp;
<input type="button" name="clear" value="clear">
+ &nbsp; &nbsp;
+ <input type="button" id="JSLINT_CLEARALL" value="Clear All Options">
</p>
<p id="JSLINT_OPTIONS">
- <table id="JSLINT_TABLE" cols="6"><tbody>
+ <table id="JSLINT_TABLE" border="0">
<tr>
- <td><span title="white" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="white">Strict white space</td>
<td><span title="devel">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="devel">Assume&nbsp;<code>console</code>,&nbsp;<code>alert</code>,&nbsp;...</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="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>
</tr>
<tr>
- <td><span title="onevar" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="onevar">Allow one&nbsp;<tt>var</tt>&nbsp;statement per function</td>
<td><span title="browser">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="browser">Assume a browser</td>
- <td><span title="evil">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="evil">Tolerate&nbsp;<tt>eval</tt></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;missisng&nbsp;<code>'use&nbsp;strict'</code>&nbsp;pragma</td>
</tr>
<tr>
- <td><span title="undef" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="undef">Disallow undefined variables</td>
<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="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> <tt>in</tt></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>
</tr>
<tr>
- <td><span title="nomen" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="nomen">Disallow dangling&nbsp;<tt>_</tt>&nbsp;in identifiers</td>
<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="sub">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="sub">Tolerate inefficient subscripting</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="regexp" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="regexp">Disallow&nbsp;<tt>.</tt>&nbsp;and&nbsp;<tt>[^</tt>...<tt>]</tt>&nbsp;in&nbsp;/RegExp/</td>
<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="type">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="type">Tolerate&nbsp;type&nbsp;inconsistency</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="plusplus" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="plusplus">Disallow&nbsp;<tt>++</tt>&nbsp;and&nbsp;<tt>--</tt></td>
<td><span title="windows">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="windows">Assume Windows</td>
- <td><span title="continue">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="continue">Tolerate&nbsp;<tt>continue</tt></td>
- </tr>
- <tr>
- <td><span title="bitwise" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="bitwise">Disallow bitwise operators</td>
- <td><span title="passfail">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="passfail">Stop on first error</td>
- <td><span title="unparam">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="unparam">Tolerate unused parameters</td>
+ <td title="windows">Assume&nbsp;Windows</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></td>
- <td></td>
- <td></td>
- <td></td>
- <td><span title="es5">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="es5">Tolerate ES5 syntax</td>
+ <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></td>
- <td></td>
- <td></td>
- <td></td>
+ <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="css">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="css">Tolerate CSS workarounds</td>
+ <td title="css">Tolerate&nbsp;CSS&nbsp;workarounds</td>
</tr>
<tr>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
+ <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="cap">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="cap">Tolerate&nbsp;<tt>HTML</tt>&nbsp;case</td>
</tr>
<tr>
- <td><span title="newcap" class="goodpart">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="newcap">Require Initial Caps for constructors</td>
<td><span title="safe">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="safe">Safe Subset</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="on">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="on">Tolerate&nbsp;<tt>HTML</tt>&nbsp;event handlers</td>
</tr>
<tr>
- <td><span title="strict" class="box goodparts">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
- <td title="strict">Require&nbsp;<tt>'use strict';</tt></td>
<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="fragment">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td title="fragment">Tolerate&nbsp;<tt>HTML</tt>&nbsp;fragments</td>
</tr>
- </tbody></table>
- <br clear=all>
-<div class="leftcolumn">
- <input type="button" id="JSLINT_GOODPARTS" value="The Good Parts">
- <br><br>
- <input type="button" id="JSLINT_CLEARALL" value="Clear All Options">
-</div>
+ </table>
+ <p><br clear=all>
+ </p>
<div id=JSLINT_FIELDS>
<input id="JSLINT_INDENT" type="text" size="2" title="indent" value="" autocomplete=off> <label for="JSLINT_INDENT" title="indent">Indentation</label><br>
<input id="JSLINT_MAXLEN" type="text" size="2" title="maxlen" value="" autocomplete=off> <label for="JSLINT_MAXLEN" title="maxlen">Maximum line length</label><br>
@@ -287,6 +276,7 @@
<label title=predef for="JSLINT_PREDEF">Predefined&nbsp;<small>(&nbsp;<code>,</code>&nbsp;separated)</small></label>&nbsp;<input id="JSLINT_PREDEF" type="text" size="72" autocomplete=off title=predef>
</div>
</p>
+<p id="JSLINT_JSLINTSTRING"></p>
<p> Copyright 2002&nbsp;<a href="http://www.JSLint.com/lint.html">Douglas
Crockford.</a>&nbsp;<a target="_blank" href="http://www.crockford.com/">All
Rights Reserved Wrrrldwide and Beyond!</a> <br>
View
133 jslint.js
@@ -1,5 +1,5 @@
// jslint.js
-// 2011-06-07
+// 2011-06-08
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -156,7 +156,7 @@
// The current option set is
// adsafe true, if ADsafe rules should be enforced
-// bitwise true, if bitwise operators should not be allowed
+// bitwise true, if bitwise operators should be allowed
// browser true, if the standard browser globals should be predefined
// cap true, if upper case HTML should be allowed
// 'continue' true, if the continuation statement should be tolerated
@@ -170,29 +170,29 @@
// indent the indentation factor
// maxerr the maximum number of errors to allow
// maxlen the maximum length of a source line
-// newcap true, if constructor names must be capitalized
+// newcap true, if constructor names capitalization is ignored
// node true, if Node.js globals should be predefined
-// nomen true, if names should be checked
+// nomen true, if names may have dangling _
// on true, if HTML event handlers should be allowed
-// onevar true, if only one var statement per function should be allowed
// passfail true, if the scan should stop on first error
-// plusplus true, if increment/decrement should not be allowed
-// regexp true, if the . should not be allowed in regexp literals
+// plusplus true, if increment/decrement should be allowed
+// regexp true, if the . should be allowed in regexp literals
// rhino true, if the Rhino environment globals should be predefined
-// undef true, if variables should be declared before used
+// undef true, if variables can be declared out of order
// unparam true, if unused parameters should be tolerated
// safe true, if use of some browser features should be restricted
-// type true, if types can be used inconsistently
-// windows true, if MS Windows-specific globals should be predefined
-// strict true, require the 'use strict'; pragma
+// sloppy true, if the 'use strict'; pragma is optional
// sub true, if all forms of subscript notation are tolerated
-// white true, if strict whitespace rules apply
+// type true, if types can be used inconsistently
+// vars true, if multiple var statements per function should be allowed
+// white true, if sloppy whitespace is tolerated
// widget true if the Yahoo Widgets globals should be predefined
+// windows true, if MS Windows-specific globals should be predefined
// For example:
/*jslint
- evil: true, nomen: false, regexp: false, strict: true
+ evil: true, nomen: true, regexp: true
*/
// The properties directive declares an exclusive list of property names.
@@ -203,7 +203,7 @@
/*properties '\b', '\t', '\n', '\f', '\r', '!=', '!==', '"', '%',
'&', '\'', '(begin)', '(breakage)', '(complexity)', '(context)',
- '(error)', '(identifier)', '(line)', '(loopage)', '(name)', '(onevar)',
+ '(error)', '(identifier)', '(line)', '(loopage)', '(name)', '(vars)',
'(params)', '(scope)', '(statement)', '(token)', '(verb)', ')', '*',
'+', '-', '/', ';', '<', '<<', '<=', '==', '===', '>',
'>=', '>>', '>>>', ADSAFE, ActiveXObject, Array,
@@ -308,7 +308,7 @@
nested_comment, newcap, next, node, noframes, nomen, noscript, not,
not_a_constructor, not_a_defined, not_a_function, not_a_label,
not_a_scope, not_greater, nud, object, ol, oldlace, olive, olivedrab,
- on, onevar, opacity, open, openURL, opera, optgroup, option, orange,
+ on, vars, opacity, open, openURL, opera, optgroup, option, orange,
orangered, orchid, outer, outline, 'outline-color', 'outline-style',
'outline-width', output, overflow, 'overflow-x', 'overflow-y', p,
padding, 'padding-bottom', 'padding-left', 'padding-right',
@@ -327,8 +327,8 @@
savePreferences, scanned_a_b, screen, script, scrollbar, seagreen, seal,
search, seashell, second, section, select, serialize, sessionStorage,
setInterval, setTimeout, shift, showWidgetPreferences, sienna, silver,
- skyblue, slash_equal, slateblue, slategray, sleep, slice, small, snow,
- sort, source, span, spawn, speak, speech, split, springgreen, src,
+ skyblue, slash_equal, slateblue, slategray, sleep, slice, sloppy, small,
+ snow, sort, source, span, spawn, speak, speech, split, springgreen, src,
stack, statement_block, steelblue, stopping, strange_loop, strict,
strong, style, styleproperty, sub, subscript, substr, sup, supplant,
suppressUpdates, sync, system, t, table, 'table-layout', tag_a_in_b,
@@ -882,7 +882,7 @@ var JSLINT = (function () {
funct, // The current function, including the labels used
// in the function, as well as (verb), (context),
// (statement), (name), (params), (complexity),
- // (loopage), (breakage), (onevar)
+ // (loopage), (breakage), (vars)
functionicity = [
'closure', 'exception', 'global', 'label', 'outer', 'undef',
@@ -1032,8 +1032,8 @@ var JSLINT = (function () {
require : false,
setInterval : false,
setTimeout : false,
- __filename : false,
- __dirname : false
+ __dirname : false,
+ __filename : false
},
node_js,
numbery = {
@@ -1230,13 +1230,13 @@ var JSLINT = (function () {
// xmode is used to adapt to the exceptions in html parsing.
// It can have these states:
-// false .js script file
-// html
-// outer
-// script
-// style
-// scriptstring
-// styleproperty
+// '' .js script file
+// 'html'
+// 'outer'
+// 'script'
+// 'style'
+// 'scriptstring'
+// 'styleproperty'
xmode,
xquote,
@@ -1485,7 +1485,7 @@ var JSLINT = (function () {
}
function expected_at(at) {
- if (option.white && next_token.from !== at) {
+ if (!option.white && next_token.from !== at) {
warn('expected_a_at_b_c', next_token, next_token.value, at,
next_token.from);
}
@@ -1574,7 +1574,7 @@ var JSLINT = (function () {
the_token.identifier = true;
if (value === '__iterator__' || value === '__proto__') {
stop_at('reserved_a', line, from, value);
- } else if (option.nomen &&
+ } else if (!option.nomen &&
(value.charAt(0) === '_' ||
value.charAt(value.length - 1) === '_')) {
warn_at('dangling_a', line, from, value);
@@ -1997,7 +1997,7 @@ var JSLINT = (function () {
c = source_row.charAt(length);
if (c === '^') {
length += 1;
- if (option.regexp) {
+ if (!option.regexp) {
warn_at('insecure_a',
line, from + length, c);
} else if (source_row.charAt(length) === ']') {
@@ -2081,7 +2081,7 @@ klass: do {
} while (c);
break;
case '.':
- if (option.regexp) {
+ if (!option.regexp) {
warn_at('insecure_a', line,
from + length, c);
}
@@ -2304,7 +2304,7 @@ klass: do {
if (typeof funct[name] === 'string') {
if (funct[name] === 'undef') {
- if (option.undef) {
+ if (!option.undef) {
warn('used_before_a', token, name);
}
kind = 'var';
@@ -2478,16 +2478,16 @@ klass: do {
option.devel =
option.evil =
option.forin =
+ option.newcap =
+ option.nomen =
option.on =
option.rhino =
+ option.sloppy =
option.sub =
+ option.undef =
option.widget =
option.windows = false;
- option.newcap =
- option.nomen =
- option.strict =
- option.undef = true;
delete predefined.Date;
delete predefined['eval'];
@@ -2623,7 +2623,7 @@ klass: do {
warn('missing_space_a_b', next_token, token.value, next_token.value);
}
comments_off = true;
- option.white = false;
+ option.white = true;
if (lookahead.length > 0 || next_token.comments) {
warn('unexpected_a', this);
}
@@ -2712,7 +2712,7 @@ klass: do {
function one_space(left, right) {
left = left || token;
right = right || next_token;
- if (right.id !== '(end)' && option.white &&
+ if (right.id !== '(end)' && !option.white &&
(token.line !== right.line ||
token.thru + 1 !== right.from)) {
warn('expected_space_a_b', right, token.value, right.value);
@@ -2723,7 +2723,7 @@ klass: do {
left = left || token;
right = right || next_token;
if (right.id !== '(end)' && (left.line !== right.line ||
- (option.white && left.thru + 1 !== right.from))) {
+ (!option.white && left.thru + 1 !== right.from))) {
warn('expected_space_a_b', right, left.value, right.value);
}
}
@@ -2731,7 +2731,7 @@ klass: do {
function no_space(left, right) {
left = left || token;
right = right || next_token;
- if ((option.white || xmode === 'styleproperty' || xmode === 'style') &&
+ if ((!option.white || xmode === 'styleproperty' || xmode === 'style') &&
left.thru !== right.from && left.line === right.line) {
warn('unexpected_space_a_b', right, left.value, right.value);
}
@@ -2741,13 +2741,13 @@ klass: do {
left = left || token;
right = right || next_token;
if (right.id !== '(end)' && (left.line !== right.line ||
- (option.white && left.thru !== right.from))) {
+ (!option.white && left.thru !== right.from))) {
warn('unexpected_space_a_b', right, left.value, right.value);
}
}
function spaces(left, right) {
- if (option.white) {
+ if (!option.white) {
left = left || token;
right = right || next_token;
if (left.thru === right.from && left.line === right.line) {
@@ -2760,7 +2760,7 @@ klass: do {
if (next_token.id !== ',') {
warn_at('expected_a_b', token.line, token.thru, ',', next_token.value);
} else {
- if (option.white) {
+ if (!option.white) {
no_space_only();
}
advance(',');
@@ -2774,7 +2774,7 @@ klass: do {
if (next_token.id !== ';') {
warn_at('expected_a_b', token.line, token.thru, ';', next_token.value);
} else {
- if (option.white) {
+ if (!option.white) {
no_space_only();
}
advance(';');
@@ -2794,8 +2794,8 @@ klass: do {
advance();
semicolon();
strict_mode = true;
- option.newcap = true;
- option.undef = true;
+ option.newcap = false;
+ option.undef = false;
return true;
} else {
return false;
@@ -2988,7 +2988,7 @@ klass: do {
this.first = expression(150);
this.arity = 'prefix';
if (this.id === '++' || this.id === '--') {
- if (option.plusplus) {
+ if (!option.plusplus) {
warn('unexpected_a', this);
} else if ((!this.first.identifier || this.first.reserved) &&
this.first.id !== '.' && this.first.id !== '[') {
@@ -3078,7 +3078,7 @@ klass: do {
spaces(prev_token, token);
spaces();
}
- if (option.bitwise && this.bitwise) {
+ if (!option.bitwise && this.bitwise) {
warn('unexpected_a', this);
}
if (typeof f === 'function') {
@@ -3183,8 +3183,14 @@ klass: do {
var x = infix(s, 20, function (left, that) {
var l;
that.first = left;
- if (left.identifier && scope[left.value].writeable === false) {
- warn('read_only', left);
+ if (left.identifier) {
+ if (scope[left.value]) {
+ if (scope[left.value].writeable === false) {
+ warn('read_only', left);
+ }
+ } else {
+ stop('read_only');
+ }
} else if (option.safe) {
l = left;
do {
@@ -3246,7 +3252,7 @@ klass: do {
var x = symbol(s, 150);
x.led = function (left) {
no_space_only(prev_token, token);
- if (option.plusplus) {
+ if (!option.plusplus) {
warn('unexpected_a', this);
} else if ((!left.identifier || left.reserved) &&
left.id !== '.' && left.id !== '[') {
@@ -3415,7 +3421,7 @@ klass: do {
advance('{');
step_in();
if (!ordinary && !use_strict() && !old_strict_mode &&
- option.strict && funct['(context)'] === global_funct) {
+ !option.sloppy && funct['(context)'] === global_funct) {
warn('missing_use_strict');
}
array = statements();
@@ -3480,7 +3486,7 @@ klass: do {
// in the global scope, then we have an undefined variable error.
} else {
- if (option.undef) {
+ if (!option.undef) {
warn('used_before_a', token);
}
scope[name] = variable = {
@@ -3575,7 +3581,9 @@ klass: do {
// Build the syntax table by declaring the syntactic elements.
type('(color)', 'color');
+ type('(function)', 'function');
type('(number)', 'number', return_this);
+ type('(object)', 'object');
type('(string)', 'string', return_this);
type('(boolean)', 'boolean', return_this);
type('(range)', 'range');
@@ -3862,7 +3870,7 @@ klass: do {
prefix('~', function () {
no_space_only();
- if (option.bitwise) {
+ if (!option.bitwise) {
warn('unexpected_a', this);
}
expression(150);
@@ -3935,7 +3943,7 @@ klass: do {
default:
if (c.id !== 'function') {
v = c.value.substr(0, 1);
- if (option.newcap && (v < 'A' || v > 'Z')) {
+ if (!option.newcap && (v < 'A' || v > 'Z')) {
warn('constructor_name_a', token);
}
}
@@ -3965,6 +3973,7 @@ klass: do {
}
var p = [];
if (left) {
+ conform_type(syntax['(function)'], left);
if (left.identifier) {
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
if (left.value !== 'Number' && left.value !== 'String' &&
@@ -3973,7 +3982,7 @@ klass: do {
warn('not_a_function', left);
} else if (left.value === 'Object') {
warn('use_object', token);
- } else if (left.value === 'Array' || option.newcap) {
+ } else if (left.value === 'Array' || !option.newcap) {
warn('missing_a', left, 'new');
}
}
@@ -4481,10 +4490,10 @@ klass: do {
var assign, id, name;
- if (funct['(onevar)'] && option.onevar) {
+ if (funct['(vars)'] && !option.vars) {
warn('combine_var');
} else if (funct !== global_funct) {
- funct['(onevar)'] = true;
+ funct['(vars)'] = true;
}
this.arity = 'statement';
this.first = [];
@@ -4841,11 +4850,13 @@ klass: do {
default:
warn('bad_in_a', value);
}
+ conform_type(syntax['(string)'], value);
advance();
the_in = next_token;
advance('in');
the_in.first = value;
the_in.second = expression(20);
+ conform_type(syntax['(object)'], the_in.second);
step_out(')', paren);
discard();
this.first = the_in;
@@ -6258,7 +6269,7 @@ klass: do {
}
warn('bad_name_a');
}
- option.white = true;
+ option.white = false;
spaces();
attribute = next_token.value;
option.white = old_white;
@@ -6283,7 +6294,7 @@ klass: do {
}
xquote = quote;
wmode = option.white;
- option.white = false;
+ option.white = true;
advance(quote);
use_strict();
statements();
@@ -6801,7 +6812,7 @@ klass: do {
};
itself.jslint = itself;
- itself.edition = '2011-06-07';
+ itself.edition = '2011-06-08';
return itself;
View
62 lint.html
@@ -177,7 +177,7 @@ <h2 id=scope>Scope</h2>
be declared at the site of first use. But because JavaScript does not
have block scope, it is wiser to declare all of a function's variables
at the top of the function. It is recommended that a single <code>var</code>
- statement be used per function. This can be enforced with the <code>onevar</code>
+ statement be used per function. This can be declined with the <code>vars</code>
<a href="#options">option</a>.</p>
<h2 id=required>Required Blocks</h2>
@@ -308,15 +308,15 @@ <h2 id=inc><code>++</code> and <code>--</code></h2>
<p>The <code>++</code> <small>(increment)</small> and <code>--</code> <small>(decrement)</small>
operators have been known to contribute to bad code by encouraging excessive
trickiness. They are second only to faulty architecture in enabling to
- viruses and other security menaces. There is a <code>plusplus</code> <a href="#options">option</a>
- that prohibits the use of these operators.</p>
+ viruses and other security menaces. Also, preincrement/postincrement confusion can produce off-by-one errors that are extrenmely difficult to diagnose. There is a <code>plusplus</code> <a href="#options">option</a>
+ that allows the use of these operators.</p>
<h2 id=bitwise>Bitwise Operators</h2>
<p>JavaScript does not have an integer type, but it does have bitwise operators.
The bitwise operators convert their operands from floating point to integers
and back, so they are not as efficient as in C or other languages. They
are rarely useful in browser applications. The similarity to the logical
operators can mask some programming errors. The <code>bitwise</code> <a href="#options">option</a>
- prohibits the use of these operators: <code>&lt;&lt; &gt;&gt; &gt;&gt;&gt;
+ allows the use of these operators: <code>&lt;&lt; &gt;&gt; &gt;&gt;&gt;
~ &amp; |</code>.</p>
<h2 id=evil><code>eval</code> is evil</h2>
<p>The <code>eval</code> function (and its relatives, <code>Function</code>,
@@ -352,7 +352,7 @@ <h2 id=new>Constructors and <code>new</code></h2>
to see a function invocation with an initial uppercase name unless it
has the <code>new</code> prefix. <code>JSLint</code> does not expect to
see the <code>new</code> prefix used with functions whose names do not
- start with initial uppercase. This can be controlled with the <code>newcap</code>
+ start with initial uppercase. This can be disabled with the <code>newcap</code>
<a href="#options">option</a>.</p>
<p><code>JSLint</code> does not expect to see the wrapper forms <code>new Number</code>,
<code>new String</code>, <code>new Boolean</code>. </p>
@@ -423,11 +423,7 @@ <h2 id=css>CSS</h2>
<h2 id=options>Options</h2>
<p><code>JSLint</code> provides several options that control its operation and
its sensitivity. In the <a href="http://www.JSLint.com/">web edition</a>, the
- options are selected with several checkboxes and two fields. Clicking on
- the <a href="http://www.amazon.com/exec/obidos/ASIN/0596517742/wrrrldwideweb"
- target="_blank"><input type="button" value="Good Parts"></a> button will give
- you the ideal settings.
-</p>
+options are selected with several checkboxes and two fields. </p>
<p>It also provides assistance in constructing <code>/*jslint*/</code>
comments.
</p>
@@ -438,7 +434,7 @@ <h2 id=options>Options</h2>
<p>Options can also be specified within a script with a <code>/*jslint */</code>
directive:</p>
<pre>/*jslint nomen: true, debug: true,
- evil: false, onevar: true */</pre>
+ evil: false, vars: true */</pre>
<p>An option specification starts with <code>/*jslint</code>. Notice that
there is no space before the <code>j</code>. The specification contains
a sequence of name value pairs, where the names are <code>JSLint</code>
@@ -459,9 +455,9 @@ <h2 id=options>Options</h2>
rules should be enforced. See <a href="http://www.ADsafe.org/">http://www.ADsafe.org/</a>.</td>
</tr>
<tr>
- <td>Disallow bitwise operators </td>
+ <td>Tolerate bitwise operators </td>
<td><code>bitwise</code></td>
- <td><code>true</code> if bitwise operators should not be allowed. <a href="#bitwise"><small>(more)</small></a></td>
+ <td><code>true</code> if bitwise operators should be allowed. <a href="#bitwise"><small>(more)</small></a></td>
</tr>
<tr>
<td>Assume a browser </td>
@@ -533,10 +529,10 @@ <h2 id=options>Options</h2>
<td>The maximum number of characters in a line</td>
</tr>
<tr>
- <td>Require Initial Caps for constructors </td>
+ <td>Tolerate uncapitalized constructors</td>
<td><code>newcap</code></td>
- <td><code>true</code> if Initial Caps must be used with constructor
- functions. <a href="#new"><small>(more)</small></a></td>
+ <td><code>true</code> if Initial Caps with constructor
+ functions is optional. <a href="#new"><small>(more)</small></a></td>
</tr>
<tr>
<td>Assume Node.js</td>
@@ -544,9 +540,9 @@ <h2 id=options>Options</h2>
<td><code>true</code> if Node.js globals should be predefined <a href="#node"><small>(more)</small></a></td>
</tr>
<tr>
- <td>Disallow dangling _ in identifiers </td>
+ <td>Tolerate dangling _ in identifiers </td>
<td><code>nomen</code></td>
- <td><code>true</code> if names should be checked for initial or trailing underbars</td>
+ <td><code>true</code> if names should not be checked for initial or trailing underbars</td>
</tr>
<tr>
<td>Tolerate HTML event handlers </td>
@@ -554,9 +550,9 @@ <h2 id=options>Options</h2>
<td><code>true</code> if HTML event handlers should be allowed. <a href="#html"><small>(more)</small></a></td>
</tr>
<tr>
- <td>Allow one <code>var</code> statement per function</td>
- <td><code>onevar</code></td>
- <td><code>true</code> if only one <code>var</code> statement per function
+ <td>Tolerate many&nbsp;<tt>var</tt>&nbsp;statements per function</td>
+ <td><code>var</code></td>
+ <td><code>true</code> if multiple <code>var</code> statement per function
should be allowed. <a href="#scope"><small>(more)</small></a></td>
</tr>
<tr>
@@ -565,10 +561,10 @@ <h2 id=options>Options</h2>
<td><code>true</code> if the scan should stop on first error.</td>
</tr>
<tr>
- <td>Disallow <code>++</code> and <code>--</code> </td>
+ <td>Tolerate <code>++</code> and <code>--</code> </td>
<td><code>plusplus</code></td>
<td><code>true</code> if <code>++</code> and <code>--</code> should
- not be allowed. <a href="#inc"><small>(more)</small></a></td>
+ be allowed. <a href="#inc"><small>(more)</small></a></td>
</tr>
<tr>
<td>Predefined <small>( , separated)</small></td>
@@ -578,9 +574,9 @@ <h2 id=options>Options</h2>
statement to declare global variables in a script file.</td>
</tr>
<tr>
- <td>Disallow <code>.</code> and <code>[^</code>...<code>]</code>. in /RegExp/ </td>
+ <td>Tolerate <code>.</code> and <code>[^</code>...<code>]</code>. in /RegExp/ </td>
<td><code>regexp</code></td>
- <td><code>true</code> if <code>.</code> and <code>[^</code>...<code>]</code> should not be allowed in RegExp
+ <td><code>true</code> if <code>.</code> and <code>[^</code>...<code>]</code> should be allowed in RegExp
literals. They match more material than might be expected, allowing attackers to confuse applications. These forms should not be used when validating in secure applications. </td>
</tr>
<tr>
@@ -597,10 +593,10 @@ <h2 id=options>Options</h2>
the safe subset rules but not the widget structure rules.</td>
</tr>
<tr>
- <td>Require <code>&quot;use strict&quot;;</code> </td>
- <td><code>strict</code></td>
- <td><code>true</code> if the ES5 <code><a href="http://www.yuiblog.com/blog/2010/12/14/strict-mode-is-coming-to-town/">"use strict";</a></code> pragma
- is required. Do not use this option carelessly.</td>
+ <td> Tolerate missing&nbsp;<code>'use strict'</code>&nbsp;pragma </td>
+ <td><code>sloppy</code></td>
+ <td><code>true</code> if the ES5 <code><a href="http://www.yuiblog.com/blog/2010/12/14/strict-mode-is-coming-to-town/">'use strict';</a></code> pragma
+ is not required. Do not use this pragma unless you know what yo are doing.</td>
</tr>
<tr>
<td>Tolerate inefficient subscripting<br>
@@ -616,14 +612,14 @@ <h2 id=options>Options</h2>
<td><code>true</code> if variables are allowed to contain more than one type of value.</td>
</tr>
<tr>
- <td>Disallow undefined variables </td>
+ <td> Tolerate misordered definitions </td>
<td><code>undef</code></td>
- <td><code>true</code> if variables must be declared before used. <a href="#undefined"><small>(more)</small></a></td>
+ <td><code>true</code> if variables and functions need not be declared before used. <a href="#undefined"><small>(more)</small></a></td>
</tr>
<tr>
- <td>Strict white space </td>
+ <td> Tolerate messy white space</td>
<td><code>white</code></td>
- <td><code>true</code> if strict whitespace rules apply.</td>
+ <td><code>true</code> if strict whitespace rules should be ignored..</td>
</tr>
<tr>
<td>Assume a Yahoo Widget </td>

1 comment on commit a27d17c

@patrio

Uber, have silently been waiting for this change all the time :D

Please sign in to comment.
Something went wrong with that request. Please try again.