Permalink
Browse files

option.node

  • Loading branch information...
1 parent 0786d84 commit 706c48583a7d305083b14ad52fab0232285c0034 @douglascrockford committed Mar 22, 2011
Showing with 87 additions and 62 deletions.
  1. +2 −0 fulljslint.html
  2. +67 −54 fulljslint.js
  3. +18 −8 lint.html
View
@@ -206,6 +206,8 @@
<br>
<input type="checkbox" id="JSLINT_BROWSER" title="browser"><label for="JSLINT_BROWSER" title="browser">Assume a browser</label>
<br>
+ <input type="checkbox" id="JSLINT_NODE" title="node"><label for="JSLINT_NODE" title="node">Assume <a href="http://nodejs.org/">Node.js</a></label>
+ <br>
<input type="checkbox" id="JSLINT_DEVEL" title="devel"><label for="JSLINT_DEVEL" title="devel">Assume&nbsp;<code>console</code>,&nbsp;<code>alert</code>,&nbsp;...</label>
<br>
<input type="checkbox" id="JSLINT_RHINO" title="rhino"><label for="JSLINT_RHINO" title="rhino">Assume&nbsp;<a href="http://www.mozilla.org/rhino/">Rhino</a></label>
View
@@ -1,5 +1,5 @@
// jslint.js
-// 2011-03-18
+// 2011-03-21
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
//
@@ -175,6 +175,7 @@
// maxerr the maximum number of errors to allow
// maxlen the maximum length of a source line
// newcap true, if constructor names must be capitalized
+// node true, if Node.js globals should be predefined
// nomen true, if names should be checked
// on true, if HTML event handlers should be allowed
// onevar true, if only one var statement per function should be allowed
@@ -215,16 +216,16 @@
ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, "\\", a, a_function, a_label, a_not_allowed,
- a_not_defined, a_scope, abbr, acronym, activeborder, activecaption,
- address, adsafe, adsafe_a, adsafe_autocomplete, adsafe_bad_id,
- adsafe_div, adsafe_fragment, adsafe_go, adsafe_html, adsafe_id,
- adsafe_id_go, adsafe_lib, adsafe_lib_second, adsafe_missing_id,
- adsafe_name_a, adsafe_placement, adsafe_prefix_a, adsafe_script,
- adsafe_source, adsafe_subscript_a, adsafe_tag, alert, aliceblue, all,
- already_defined, and, animator, antiquewhite, appleScript, applet,
- apply, approved, appworkspace, aqua, aquamarine, area, arguments, arity,
- article, aside, assign, assign_exception,
+ XMLHttpRequest, "\\", __dirname, __filename, a, a_function, a_label,
+ a_not_allowed, a_not_defined, a_scope, abbr, acronym, activeborder,
+ activecaption, address, adsafe, adsafe_a, adsafe_autocomplete,
+ adsafe_bad_id, adsafe_div, adsafe_fragment, adsafe_go, adsafe_html,
+ adsafe_id, adsafe_id_go, adsafe_lib, adsafe_lib_second,
+ adsafe_missing_id, adsafe_name_a, adsafe_placement, adsafe_prefix_a,
+ adsafe_script, adsafe_source, adsafe_subscript_a, adsafe_tag, alert,
+ aliceblue, all, already_defined, and, animator, antiquewhite,
+ appleScript, applet, apply, approved, appworkspace, aqua, aquamarine,
+ area, arguments, arity, article, aside, assign, assign_exception,
assignment_function_expression, at, attribute_case_a, audio,
autocomplete, avoid_a, azure, b, background, "background-attachment",
"background-color", "background-image", "background-position",
@@ -302,48 +303,49 @@
midnightblue, "min-height", "min-width", mintcream, missing_a,
missing_a_after_b, missing_option, missing_property, missing_space_a_b,
missing_url, missing_use_strict, mistyrose, mixed, mm, moccasin, mode,
- move_invocation, move_var, name, name_function, nav, navajowhite,
- navigator, navy, nested_comment, newcap, next, 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, orangered, orchid, outer, outline, "outline-color",
- "outline-style", "outline-width", output, overflow, "overflow-x",
- "overflow-y", p, padding, "padding-bottom", "padding-left",
- "padding-right", "padding-top", "page-break-after", "page-break-before",
- palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
- param, parameter_a_get_b, parameter_set_a, paren, parent, parseFloat,
- parseInt, passfail, pc, peachpuff, peru, pink, play, plum, plusplus,
- pop, popupMenu, position, postscript, powderblue, pre, predef,
- preferenceGroups, preferences, prev, print, progress, projection,
- prompt, prototype, pt, purple, push, px, q, quit, quote, quotes, radix,
- random, range, raw, readFile, readUrl, read_only, reason, red,
- redefinition_a, regexp, reloadWidget, replace, report, reserved,
- reserved_a, resolvePath, resumeUpdates, rhino, right, rosybrown,
- royalblue, rp, rt, ruby, runCommand, runCommandInBg, saddlebrown, safe,
- salmon, samp, sandybrown, saveAs, savePreferences, scanned_a_b, screen,
- script, scrollbar, seagreen, seal, search, seashell, second, section,
- select, serialize, setInterval, setTimeout, shift,
- showWidgetPreferences, sienna, silver, skyblue, slash_equal, slateblue,
- slategray, sleep, slice, 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, table,
- "table-layout", tag_a_in_b, tan, tbody, td, teal, tellWidget, test,
- "text-align", "text-decoration", "text-indent", "text-shadow",
- "text-transform", textarea, tfoot, th, thead, third, thistle,
- threeddarkshadow, threedface, threedhighlight, threedlightshadow,
- threedshadow, thru, time, title, toLowerCase, toString, toUpperCase,
- toint32, token, tomato, too_long, too_many, top, tr, trailing_decimal_a,
- tree, tt, tty, turquoise, tv, type, u, ul, unclosed, unclosed_comment,
- unclosed_regexp, undef, unescape, unescaped_a, unexpected_a,
- unexpected_char_a_b, unexpected_comment, unexpected_member_a,
- unexpected_space_a_b, "unicode-bidi", unnecessary_initialize,
- unnecessary_use, unreachable_a_b, unrecognized_style_attribute_a,
- unrecognized_tag_a, unsafe, unused, unwatch, updateNow, url, urls,
- use_array, use_braces, use_object, used_before_a, value, valueOf, var,
- var_a_not, version, "vertical-align", video, violet, visibility, was,
- watch, weird_assignment, weird_condition, weird_new, weird_program,
+ module, move_invocation, move_var, name, name_function, nav,
+ navajowhite, navigator, navy, 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, orangered, orchid, outer, outline,
+ "outline-color", "outline-style", "outline-width", output, overflow,
+ "overflow-x", "overflow-y", p, padding, "padding-bottom",
+ "padding-left", "padding-right", "padding-top", "page-break-after",
+ "page-break-before", palegoldenrod, palegreen, paleturquoise,
+ palevioletred, papayawhip, param, parameter_a_get_b, parameter_set_a,
+ paren, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
+ pink, play, plum, plusplus, pop, popupMenu, position, postscript,
+ powderblue, pre, predef, preferenceGroups, preferences, prev, print,
+ process, progress, projection, prompt, prototype, pt, purple, push, px,
+ q, quit, quote, quotes, radix, random, range, raw, readFile, readUrl,
+ read_only, reason, red, redefinition_a, regexp, reloadWidget, replace,
+ report, require, reserved, reserved_a, resolvePath, resumeUpdates,
+ rhino, right, rosybrown, royalblue, rp, rt, ruby, runCommand,
+ runCommandInBg, saddlebrown, safe, salmon, samp, sandybrown, saveAs,
+ savePreferences, scanned_a_b, screen, script, scrollbar, seagreen, seal,
+ search, seashell, second, section, select, serialize, setInterval,
+ setTimeout, shift, showWidgetPreferences, sienna, silver, skyblue,
+ slash_equal, slateblue, slategray, sleep, slice, 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, table, "table-layout", tag_a_in_b, tan,
+ tbody, td, teal, tellWidget, test, "text-align", "text-decoration",
+ "text-indent", "text-shadow", "text-transform", textarea, tfoot, th,
+ thead, third, thistle, threeddarkshadow, threedface, threedhighlight,
+ threedlightshadow, threedshadow, thru, time, title, toLowerCase,
+ toString, toUpperCase, toint32, token, tomato, too_long, too_many, top,
+ tr, trailing_decimal_a, tree, tt, tty, turquoise, tv, type, u, ul,
+ unclosed, unclosed_comment, unclosed_regexp, undef, unescape,
+ unescaped_a, unexpected_a, unexpected_char_a_b, unexpected_comment,
+ unexpected_member_a, unexpected_space_a_b, "unicode-bidi",
+ unnecessary_initialize, unnecessary_use, unreachable_a_b,
+ unrecognized_style_attribute_a, unrecognized_tag_a, unsafe, unused,
+ unwatch, updateNow, url, urls, use_array, use_braces, use_object,
+ used_before_a, value, valueOf, var, var_a_not, version,
+ "vertical-align", video, violet, visibility, was, watch,
+ weird_assignment, weird_condition, weird_new, weird_program,
weird_relation, weird_ternary, wheat, white, "white-space", whitesmoke,
widget, width, window, windowframe, windows, windowtext, "word-spacing",
"word-wrap", wrap, wrap_immediate, wrap_regexp, write_is_wrong,
@@ -957,6 +959,14 @@ var JSLINT = (function () {
lines,
lookahead,
member,
+ node = {
+ global : true,
+ module : true,
+ process : true,
+ require : true,
+ __filename : true,
+ __dirname : true
+ },
properties,
next_token,
older_token,
@@ -1325,6 +1335,9 @@ var JSLINT = (function () {
if (option.windows) {
combine(predefined, windows);
}
+ if (option.node) {
+ combine(predefined, node);
+ }
if (option.widget) {
combine(predefined, widget);
}
@@ -6567,7 +6580,7 @@ loop: for (;;) {
};
itself.jslint = itself;
- itself.edition = '2011-03-18';
+ itself.edition = '2011-03-21';
return itself;
View
@@ -115,13 +115,18 @@ <h2 id=global>Global Variables</h2>
<p> The <code>browser</code> <a href="#options">option</a> does
not include the aliases of the global object, <code>window</code> and
<code>self</code> because the potential for misuse is so great. If you need access to <code>window</code>, you can write<code> var window; </code>or<code> /*global window*/</code>.</p>
-<p id=devel>Select the
- <label for="JSLINT_DEVEL" title="devel"><em>Assume console, alert, ...</em></label>
+<p id=devel>Select the
+ <label for="JSLINT_DEVEL" title="devel"><em>Assume console, alert, ...</em></label>
(<code>devel</code>) <a href="#options">option</a> to predefine globals that are useful in development but that should be avoided in production, such as <code>console</code> and <code>alert</code>. It has the same
effect as this comment:</p>
<pre>/*global alert: false, confirm: false, console: false, Debug: false, opera: false, prompt: false */</pre>
+<p id=node>Select the
+ <label for="JSLINT_DEVEL2" title="devel"><em>Assume Node.js</em></label>
+ (<code>node</code>) <a href="#options">option</a> to predefine globals that are used in the Node.js environment<code></code>. It has the same
+ effect as this comment:</p>
+<pre>/*global global: false, module: false, process: false, require: false, __filename: false, __dirname: false */</pre>
<p id=rhino>Select the <i>Assume Rhino</i> (<code>rhino</code>) <a href="#options">option</a>
- to predefine the global properties provided by the Rhino environment.
+ to predefine the global properties provided by the Rhino environment.
It has the same effect as this statement:</p>
<blockquote>
<code>/*global defineClass: false, deserialize: false, gc: false, help: false, load: false, loadClass: false, print: false, quit: false, readFile: false, readUrl: false, runCommand: false, seal: false, serialize: false, spawn: false, sync: false, toint32: false, version: false */ </code>
@@ -534,17 +539,22 @@ <h2 id=options>Options</h2>
<td>The maximum number of characters in a line</td>
</tr>
<tr>
- <td>Disallow dangling _ in identifiers </td>
- <td><code>nomen</code></td>
- <td><code>true</code> if names should be checked for initial or trailing underbars</td>
- </tr>
- <tr>
<td>Require Initial Caps for 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>
</tr>
<tr>
+ <td>Assume Node.js</td>
+ <td><code>node</code></td>
+ <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><code>nomen</code></td>
+ <td><code>true</code> if names should be checked for initial or trailing underbars</td>
+ </tr>
+ <tr>
<td>Tolerate HTML event handlers </td>
<td><code>on</code></td>
<td><code>true</code> if HTML event handlers should be allowed. <a href="#html"><small>(more)</small></a></td>

0 comments on commit 706c485

Please sign in to comment.