jslint_on_rails 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  // jslint.js
2
- // 2010-04-06
2
+ // 2010-11-27
3
3
 
4
4
  /*
5
5
  Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -33,7 +33,7 @@ SOFTWARE.
33
33
  The first parameter is either a string or an array of strings. If it is a
34
34
  string, it will be split on '\n' or '\r'. If it is an array of strings, it
35
35
  is assumed that each string represents one line. The source can be a
36
- JavaScript text, or HTML text, or a Konfabulator text.
36
+ JavaScript text, or HTML text, or a JSON text, or a CSS text.
37
37
 
38
38
  The second parameter is an optional object of options which control the
39
39
  operation of JSLINT. Most of the options are booleans: They are all are
@@ -144,110 +144,115 @@ SOFTWARE.
144
144
  evil: true, nomen: false, onevar: false, regexp: false, strict: true
145
145
  */
146
146
 
147
- /*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
148
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
149
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
150
- "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
151
- "<", "<=", "==", "===", ">", ">=", ADSAFE, ActiveXObject,
152
- Array, Boolean, COM, CScript, Canvas, CustomAnimation, Date, Debug, E,
153
- Enumerator, Error, EvalError, FadeAnimation, Flash, FormField, Frame,
154
- Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE,
155
- MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number,
156
- Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle,
157
- ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
158
- SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
159
- Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
160
- XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address,
161
- adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet,
162
- apply, approved, aqua, aquamarine, area, arguments, arity, article,
163
- aside, audio, autocomplete, azure, b, background,
164
- "background-attachment", "background-color", "background-image",
165
- "background-position", "background-repeat", base, bdo, beep, beige, big,
166
- bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
167
- blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
168
- "border-bottom-style", "border-bottom-width", "border-collapse",
169
- "border-color", "border-left", "border-left-color", "border-left-style",
170
- "border-left-width", "border-right", "border-right-color",
171
- "border-right-style", "border-right-width", "border-spacing",
172
- "border-style", "border-top", "border-top-color", "border-top-style",
173
- "border-top-width", "border-width", bottom, br, brown, browser,
174
- burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
175
- canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
176
- character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
177
- cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
178
- closed, closure, cm, code, col, colgroup, color, command, comment,
179
- condition, confirm, console, constructor, content, convertPathToHFS,
180
- convertPathToPlatform, coral, cornflowerblue, cornsilk,
181
- "counter-increment", "counter-reset", create, crimson, css, cursor,
182
- cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
183
- darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
184
- darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
185
- darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
186
- deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
187
- details, devel, dfn, dialog, dimension, dimgray, dir, direction,
188
- display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
189
- empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
190
- errors, es5, escape, eval, event, evidence, evil, ex, exception, exec, exps,
191
- fieldset, figure, filesystem, firebrick, first, float, floor,
192
- floralwhite, focus, focusWidget, font, "font-face", "font-family",
193
- "font-size", "font-size-adjust", "font-stretch", "font-style",
194
- "font-variant", "font-weight", footer, forestgreen, forin, form,
195
- fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
196
- funct, function, functions, g, gainsboro, gc, getComputedStyle,
197
- ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
198
- h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
199
- hgroup, history, honeydew, hotpink, hr, html, i, iTunes, id, identifier,
200
- iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
201
- indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
202
- isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
203
- konfabulatorVersion, label, labelled, lang, last, lavender,
204
- lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
205
- lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
206
- lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
207
- lightseagreen, lightskyblue, lightslategray, lightsteelblue,
208
- lightyellow, lime, limegreen, line, "line-height", linen, link,
209
- "list-style", "list-style-image", "list-style-position",
210
- "list-style-type", load, loadClass, location, log, m, magenta, map,
211
- margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
212
- mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
213
- maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
214
- mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
215
- mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
216
- midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
217
- moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
218
- newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
219
- olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
220
- onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
221
- option, orange, orangered, orchid, outer, outline, "outline-color",
222
- "outline-style", "outline-width", output, overflow, "overflow-x",
223
- "overflow-y", p, padding, "padding-bottom", "padding-left",
224
- "padding-right", "padding-top", page, "page-break-after",
225
- "page-break-before", palegoldenrod, palegreen, paleturquoise,
226
- palevioletred, papayawhip, param, parent, parseFloat, parseInt,
227
- passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
228
- popupMenu, position, powderblue, pre, predef, preferenceGroups,
229
- preferences, print, progress, prompt, prototype, pt, purple, push, px,
230
- q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
231
- red, regexp, reloadWidget, removeEventListener, replace, report,
232
- reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
233
- rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
234
- saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
235
- screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
236
- seashell, section, select, serialize, setInterval, setTimeout, shift,
237
- showWidgetPreferences, sienna, silver, skyblue, slateblue, slategray,
238
- sleep, slice, small, snow, sort, source, span, spawn, speak, split,
239
- springgreen, src, stack, status, steelblue, strict, strong, style,
240
- styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
241
- system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
242
- "text-align", "text-decoration", "text-indent", "text-shadow",
243
- "text-transform", textarea, tfoot, th, thead, thistle, time, title,
244
- toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
245
- turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
246
- unwatch, updateNow, urls, value, valueOf, var, version,
247
- "vertical-align", video, violet, visibility, watch, wheat, white,
248
- "white-space", whitesmoke, widget, width, windows, "word-spacing",
249
- "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow,
250
- yellowgreen, "z-index"
147
+ /*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
148
+ "(begin)", "(breakage)", "(context)", "(error)", "(global)",
149
+ "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
150
+ "(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
151
+ "--", "\/", "<", "<=", "==", "===", ">", ">=", ADSAFE,
152
+ ActiveXObject, Array, Boolean, COM, CScript, Canvas, CustomAnimation,
153
+ Date, Debug, E, Enumerator, Error, EvalError, FadeAnimation, Flash,
154
+ FormField, Frame, Function, HotKey, Image, JSON, LN10, LN2, LOG10E,
155
+ LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem, MoveAnimation,
156
+ NEGATIVE_INFINITY, Number, Object, Option, PI, POSITIVE_INFINITY, Point,
157
+ RangeError, Rectangle, ReferenceError, RegExp, ResizeAnimation,
158
+ RotateAnimation, SQRT1_2, SQRT2, ScrollBar, String, Style, SyntaxError,
159
+ System, Text, TextArea, Timer, TypeError, URIError, URL, VBArray,
160
+ WScript, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
161
+ activeborder, activecaption, addEventListener, address, adsafe, alert,
162
+ aliceblue, all, animator, antiquewhite, appleScript, applet, apply,
163
+ approved, appworkspace, aqua, aquamarine, area, arguments, arity,
164
+ article, aside, audio, autocomplete, azure, b, background,
165
+ "background-attachment", "background-color", "background-image",
166
+ "background-position", "background-repeat", base, bdo, beep, beige, big,
167
+ bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
168
+ blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
169
+ "border-bottom-style", "border-bottom-width", "border-collapse",
170
+ "border-color", "border-left", "border-left-color", "border-left-style",
171
+ "border-left-width", "border-right", "border-right-color",
172
+ "border-right-style", "border-right-width", "border-spacing",
173
+ "border-style", "border-top", "border-top-color", "border-top-style",
174
+ "border-top-width", "border-width", bottom, br, braille, brown, browser,
175
+ burlywood, button, buttonface, buttonhighlight, buttonshadow,
176
+ buttontext, bytesToUIString, c, cadetblue, call, callee, caller, canvas,
177
+ cap, caption, "caption-side", captiontext, cases, center, charAt,
178
+ charCodeAt, character, chartreuse, chocolate, chooseColor, chooseFile,
179
+ chooseFolder, cite, clear, clearInterval, clearTimeout, clip, close,
180
+ closeWidget, closed, closure, cm, code, col, colgroup, color, command,
181
+ comment, condition, confirm, console, constructor, content,
182
+ convertPathToHFS, convertPathToPlatform, coral, cornflowerblue,
183
+ cornsilk, "counter-increment", "counter-reset", create, crimson, css,
184
+ cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
185
+ darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
186
+ darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
187
+ darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
188
+ deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
189
+ details, devel, dfn, dialog, dimension, dimgray, dir, direction,
190
+ display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
191
+ embossed, empty, "empty-cells", encodeURI, encodeURIComponent,
192
+ entityify, eqeqeq, errors, es5, escape, eval, event, evidence, evil, ex,
193
+ exception, exec, exps, fieldset, figure, filesystem, firebrick, first,
194
+ float, floor, floralwhite, focus, focusWidget, font, "font-family",
195
+ "font-size", "font-size-adjust", "font-stretch", "font-style",
196
+ "font-variant", "font-weight", footer, forestgreen, forin, form,
197
+ fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
198
+ funct, function, functions, g, gainsboro, gc, getComputedStyle,
199
+ ghostwhite, global, globals, gold, goldenrod, gray, graytext, green,
200
+ greenyellow, h1, h2, h3, h4, h5, h6, handheld, hasOwnProperty, head,
201
+ header, height, help, hgroup, highlight, highlighttext, history,
202
+ honeydew, hotpink, hr, "hta:application", html, i, iTunes, id,
203
+ identifier, iframe, img, immed, implieds, in, inactiveborder,
204
+ inactivecaption, inactivecaptiontext, include, indent, indexOf,
205
+ indianred, indigo, infobackground, infotext, init, input, ins, isAlpha,
206
+ isApplicationRunning, isDigit, isFinite, isNaN, ivory, join, jslint,
207
+ json, kbd, keygen, khaki, konfabulatorVersion, label, labelled, lang,
208
+ last, lavender, lavenderblush, lawngreen, laxbreak, lbp, led, left,
209
+ legend, lemonchiffon, length, "letter-spacing", li, lib, lightblue,
210
+ lightcoral, lightcyan, lightgoldenrodyellow, lightgreen, lightpink,
211
+ lightsalmon, lightseagreen, lightskyblue, lightslategray,
212
+ lightsteelblue, lightyellow, lime, limegreen, line, "line-height",
213
+ linen, link, "list-style", "list-style-image", "list-style-position",
214
+ "list-style-type", load, loadClass, location, log, m, magenta, map,
215
+ margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
216
+ mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
217
+ maxlen, md5, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
218
+ mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
219
+ mediumvioletred, member, menu, menutext, message, meta, meter,
220
+ midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
221
+ moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
222
+ newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
223
+ olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
224
+ onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
225
+ option, orange, orangered, orchid, outer, outline, "outline-color",
226
+ "outline-style", "outline-width", output, overflow, "overflow-x",
227
+ "overflow-y", p, padding, "padding-bottom", "padding-left",
228
+ "padding-right", "padding-top", "page-break-after", "page-break-before",
229
+ palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
230
+ param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
231
+ pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre,
232
+ predef, preferenceGroups, preferences, print, progress, projection,
233
+ prompt, prototype, pt, purple, push, px, q, quit, quotes, random, range,
234
+ raw, reach, readFile, readUrl, reason, red, regexp, reloadWidget,
235
+ removeEventListener, replace, report, reserved, resizeBy, resizeTo,
236
+ resolvePath, resumeUpdates, rhino, right, rosybrown, royalblue, rp, rt,
237
+ ruby, runCommand, runCommandInBg, saddlebrown, safe, salmon, samp,
238
+ sandybrown, saveAs, savePreferences, screen, script, scroll, scrollBy,
239
+ scrollTo, scrollbar, seagreen, seal, search, seashell, section, select,
240
+ serialize, setInterval, setTimeout, shift, showWidgetPreferences,
241
+ sienna, silver, skyblue, slateblue, slategray, sleep, slice, small,
242
+ snow, sort, source, span, spawn, speak, speech, split, springgreen, src,
243
+ stack, status, steelblue, strict, strong, style, styleproperty, sub,
244
+ substr, sup, supplant, suppressUpdates, sync, system, table,
245
+ "table-layout", tan, tbody, td, teal, tellWidget, test, "text-align",
246
+ "text-decoration", "text-indent", "text-shadow", "text-transform",
247
+ textarea, tfoot, th, thead, thistle, threeddarkshadow, threedface,
248
+ threedhighlight, threedlightshadow, threedshadow, time, title,
249
+ toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
250
+ tty, turquoise, tv, type, u, ul, undef, unescape, "unicode-bidi",
251
+ unused, unwatch, updateNow, urls, value, valueOf, var, version,
252
+ "vertical-align", video, violet, visibility, watch, wheat, white,
253
+ "white-space", whitesmoke, widget, width, window, windowframe, windows,
254
+ windowtext, "word-spacing", "word-wrap", yahooCheckLogin, yahooLogin,
255
+ yahooLogout, yellow, yellowgreen, "z-index"
251
256
  */
252
257
 
253
258
  // We build the application inside a function so that we produce only a single
@@ -263,12 +268,6 @@ var JSLINT = (function () {
263
268
  anonname, // The guessed name for anonymous functions.
264
269
  approved, // ADsafe approved urls.
265
270
 
266
- atrule = {
267
- media : true,
268
- 'font-face': true,
269
- page : true
270
- },
271
-
272
271
  // These are operators that should not be used with the ! operator.
273
272
 
274
273
  bang = {
@@ -534,7 +533,36 @@ var JSLINT = (function () {
534
533
  "white" : true,
535
534
  "whitesmoke" : true,
536
535
  "yellow" : true,
537
- "yellowgreen" : true
536
+ "yellowgreen" : true,
537
+
538
+ "activeborder" : true,
539
+ "activecaption" : true,
540
+ "appworkspace" : true,
541
+ "background" : true,
542
+ "buttonface" : true,
543
+ "buttonhighlight" : true,
544
+ "buttonshadow" : true,
545
+ "buttontext" : true,
546
+ "captiontext" : true,
547
+ "graytext" : true,
548
+ "highlight" : true,
549
+ "highlighttext" : true,
550
+ "inactiveborder" : true,
551
+ "inactivecaption" : true,
552
+ "inactivecaptiontext" : true,
553
+ "infobackground" : true,
554
+ "infotext" : true,
555
+ "menu" : true,
556
+ "menutext" : true,
557
+ "scrollbar" : true,
558
+ "threeddarkshadow" : true,
559
+ "threedface" : true,
560
+ "threedhighlight" : true,
561
+ "threedlightshadow" : true,
562
+ "threedshadow" : true,
563
+ "window" : true,
564
+ "windowframe" : true,
565
+ "windowtext" : true
538
566
  },
539
567
 
540
568
  cssBorderStyle,
@@ -552,6 +580,7 @@ var JSLINT = (function () {
552
580
  'px': true
553
581
  },
554
582
 
583
+ cssMedia,
555
584
  cssOverflow,
556
585
 
557
586
  devel = {
@@ -638,8 +667,10 @@ var JSLINT = (function () {
638
667
  head: {parent: ' html '},
639
668
  header: {},
640
669
  hgroup: {},
641
- html: {parent: '*'},
642
670
  hr: {empty: true},
671
+ 'hta:application':
672
+ {empty: true, parent: ' head '},
673
+ html: {parent: '*'},
643
674
  i: {},
644
675
  iframe: {},
645
676
  img: {empty: true},
@@ -737,17 +768,6 @@ var JSLINT = (function () {
737
768
  },
738
769
 
739
770
  scope, // The current scope
740
-
741
- windows = {
742
- ActiveXObject: false,
743
- CScript : false,
744
- Debug : false,
745
- Enumerator : false,
746
- System : false,
747
- VBArray : false,
748
- WScript : false
749
- },
750
-
751
771
  src,
752
772
  stack,
753
773
 
@@ -790,13 +810,13 @@ var JSLINT = (function () {
790
810
  LN10 : true,
791
811
  LOG2E : true,
792
812
  LOG10E : true,
793
- PI : true,
794
- SQRT1_2 : true,
795
- SQRT2 : true,
796
813
  MAX_VALUE : true,
797
814
  MIN_VALUE : true,
798
815
  NEGATIVE_INFINITY : true,
799
- POSITIVE_INFINITY : true
816
+ PI : true,
817
+ POSITIVE_INFINITY : true,
818
+ SQRT1_2 : true,
819
+ SQRT2 : true
800
820
  },
801
821
 
802
822
  strict_mode,
@@ -886,6 +906,16 @@ var JSLINT = (function () {
886
906
  yahooLogout : true
887
907
  },
888
908
 
909
+ windows = {
910
+ ActiveXObject: false,
911
+ CScript : false,
912
+ Debug : false,
913
+ Enumerator : false,
914
+ System : false,
915
+ VBArray : false,
916
+ WScript : false
917
+ },
918
+
889
919
  // xmode is used to adapt to the exceptions in html parsing.
890
920
  // It can have these states:
891
921
  // false .js script file
@@ -899,15 +929,16 @@ var JSLINT = (function () {
899
929
  xmode,
900
930
  xquote,
901
931
 
932
+ // Regular expressions. Some of these are ridiculously long.
933
+
902
934
  // unsafe comment or string
903
- ax = /@cc|<\/?|script|\]*s\]|<\s*!|&lt/i,
935
+ ax = /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i,
904
936
  // unsafe characters that are silently deleted by one or more browsers
905
937
  cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
906
938
  // token
907
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+[+=]?|-[\-=]?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
939
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
908
940
  // html token
909
- //////// hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--|.)/,
910
- hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--)/,
941
+ hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
911
942
  // characters in strings that need escapement
912
943
  nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
913
944
  nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -961,10 +992,10 @@ var JSLINT = (function () {
961
992
  }
962
993
 
963
994
  String.prototype.entityify = function () {
964
- return this.
965
- replace(/&/g, '&amp;').
966
- replace(/</g, '&lt;').
967
- replace(/>/g, '&gt;');
995
+ return this
996
+ .replace(/&/g, '&amp;')
997
+ .replace(/</g, '&lt;')
998
+ .replace(/>/g, '&gt;');
968
999
  };
969
1000
 
970
1001
  String.prototype.isAlpha = function () {
@@ -1128,7 +1159,7 @@ var JSLINT = (function () {
1128
1159
 
1129
1160
  function it(type, value) {
1130
1161
  var i, t;
1131
- if (type === '(color)') {
1162
+ if (type === '(color)' || type === '(range)') {
1132
1163
  t = {type: type};
1133
1164
  } else if (type === '(punctuator)' ||
1134
1165
  (type === '(identifier)' && is_own(syntax, value))) {
@@ -1172,10 +1203,10 @@ var JSLINT = (function () {
1172
1203
  return {
1173
1204
  init: function (source) {
1174
1205
  if (typeof source === 'string') {
1175
- lines = source.
1176
- replace(/\r\n/g, '\n').
1177
- replace(/\r/g, '\n').
1178
- split('\n');
1206
+ lines = source
1207
+ .replace(/\r\n/g, '\n')
1208
+ .replace(/\r/g, '\n')
1209
+ .split('\n');
1179
1210
  } else {
1180
1211
  lines = source;
1181
1212
  }
@@ -1608,6 +1639,9 @@ var JSLINT = (function () {
1608
1639
  if (option.regexp) {
1609
1640
  warningAt("Insecure '{a}'.",
1610
1641
  line, from + l, c);
1642
+ } else if (s.charAt(l) === ']') {
1643
+ errorAt("Unescaped '{a}'.",
1644
+ line, from + l, '^');
1611
1645
  }
1612
1646
  }
1613
1647
  q = false;
@@ -1790,7 +1824,7 @@ klass: do {
1790
1824
  line, character + l);
1791
1825
  }
1792
1826
  character += i;
1793
- if (s[i + 2] !== '>') {
1827
+ if (s.charAt(i + 2) !== '>') {
1794
1828
  errorAt("Expected -->.", line, character);
1795
1829
  }
1796
1830
  character += 3;
@@ -2123,6 +2157,14 @@ loop: for (;;) {
2123
2157
  }
2124
2158
  }
2125
2159
 
2160
+ function nobreak(left, right) {
2161
+ left = left || token;
2162
+ right = right || nexttoken;
2163
+ if (left.character !== right.from || left.line !== right.line) {
2164
+ warning("Unexpected space before '{a}'.", right, right.value);
2165
+ }
2166
+ }
2167
+
2126
2168
  function nospace(left, right) {
2127
2169
  left = left || token;
2128
2170
  right = right || nexttoken;
@@ -2275,13 +2317,8 @@ loop: for (;;) {
2275
2317
 
2276
2318
  function reservevar(s, v) {
2277
2319
  return reserve(s, function () {
2278
- if (this.id === 'this' || this.id === 'arguments' ||
2279
- this.id === 'eval') {
2280
- if (strict_mode && funct['(global)']) {
2281
- warning("Strict violation.", this);
2282
- } else if (option.safe) {
2283
- warning("ADsafe violation.", this);
2284
- }
2320
+ if (typeof v === 'function') {
2321
+ v(this);
2285
2322
  }
2286
2323
  return this;
2287
2324
  });
@@ -2336,7 +2373,7 @@ loop: for (;;) {
2336
2373
  function isPoorRelation(node) {
2337
2374
  return node &&
2338
2375
  ((node.type === '(number)' && +node.value === 0) ||
2339
- (node.type === '(string)' && node.value === ' ') ||
2376
+ (node.type === '(string)' && node.value === '') ||
2340
2377
  node.type === 'true' ||
2341
2378
  node.type === 'false' ||
2342
2379
  node.type === 'undefined' ||
@@ -2351,7 +2388,9 @@ loop: for (;;) {
2351
2388
  that.left = left;
2352
2389
  if (predefined[left.value] === false &&
2353
2390
  scope[left.value]['(global)'] === true) {
2354
- warning('Read only.', left);
2391
+ warning("Read only.", left);
2392
+ } else if (left['function']) {
2393
+ warning("'{a}' is a function.", left, left.value);
2355
2394
  }
2356
2395
  if (option.safe) {
2357
2396
  l = left;
@@ -2386,6 +2425,7 @@ loop: for (;;) {
2386
2425
  }, 20);
2387
2426
  }
2388
2427
 
2428
+
2389
2429
  function bitwise(s, f, p) {
2390
2430
  var x = symbol(s, p);
2391
2431
  reserveName(x);
@@ -2400,6 +2440,7 @@ loop: for (;;) {
2400
2440
  return x;
2401
2441
  }
2402
2442
 
2443
+
2403
2444
  function bitwiseassignop(s) {
2404
2445
  symbol(s, 20).exps = true;
2405
2446
  return infix(s, function (left, that) {
@@ -2450,7 +2491,7 @@ loop: for (;;) {
2450
2491
  } else if (token.reserved && !option.es5) {
2451
2492
  warning("Expected an identifier and instead saw '{a}' (a reserved word).",
2452
2493
  token, token.id);
2453
- }
2494
+ }
2454
2495
  return token.value;
2455
2496
  }
2456
2497
  }
@@ -2469,6 +2510,7 @@ loop: for (;;) {
2469
2510
  }
2470
2511
  }
2471
2512
 
2513
+
2472
2514
  function reachable(s) {
2473
2515
  var i = 0, t;
2474
2516
  if (nexttoken.id !== ';' || noreach) {
@@ -2541,7 +2583,7 @@ loop: for (;;) {
2541
2583
  warning("Do not use 'new' for side effects.");
2542
2584
  }
2543
2585
  if (nexttoken.id !== ';') {
2544
- if (!(nexttoken.id == '}' && option.lastsemic)) {
2586
+ if (!(nexttoken.id == '}' && option.lastsemic && nexttoken.line == token.line)) {
2545
2587
  warningAt("Missing semicolon.", token.line,
2546
2588
  token.from + token.value.length);
2547
2589
  }
@@ -2565,6 +2607,8 @@ loop: for (;;) {
2565
2607
  advance();
2566
2608
  advance(';');
2567
2609
  strict_mode = true;
2610
+ option.newcap = true;
2611
+ option.undef = true;
2568
2612
  return true;
2569
2613
  } else {
2570
2614
  return false;
@@ -2678,17 +2722,13 @@ loop: for (;;) {
2678
2722
  funct['(verb)'] = null;
2679
2723
  scope = s;
2680
2724
  inblock = b;
2725
+ if (f && (!a || a.length === 0)) {
2726
+ warning("Empty block.");
2727
+ }
2681
2728
  return a;
2682
2729
  }
2683
2730
 
2684
2731
 
2685
- // An identity function, used by string and number tokens.
2686
-
2687
- function idValue() {
2688
- return this;
2689
- }
2690
-
2691
-
2692
2732
  function countMember(m) {
2693
2733
  if (membersOnly && typeof membersOnly[m] !== 'boolean') {
2694
2734
  warning("Unexpected /*member '{a}'.", token, m);
@@ -2714,6 +2754,7 @@ loop: for (;;) {
2714
2754
  }
2715
2755
  }
2716
2756
 
2757
+
2717
2758
  // CSS parsing.
2718
2759
 
2719
2760
 
@@ -2724,6 +2765,7 @@ loop: for (;;) {
2724
2765
  }
2725
2766
  }
2726
2767
 
2768
+
2727
2769
  function cssNumber() {
2728
2770
  if (nexttoken.id === '-') {
2729
2771
  advance('-');
@@ -2736,6 +2778,7 @@ loop: for (;;) {
2736
2778
  }
2737
2779
  }
2738
2780
 
2781
+
2739
2782
  function cssString() {
2740
2783
  if (nexttoken.type === '(string)') {
2741
2784
  advance();
@@ -2743,6 +2786,7 @@ loop: for (;;) {
2743
2786
  }
2744
2787
  }
2745
2788
 
2789
+
2746
2790
  function cssColor() {
2747
2791
  var i, number, value;
2748
2792
  if (nexttoken.identifier) {
@@ -2801,6 +2845,7 @@ loop: for (;;) {
2801
2845
  return false;
2802
2846
  }
2803
2847
 
2848
+
2804
2849
  function cssLength() {
2805
2850
  if (nexttoken.id === '-') {
2806
2851
  advance('-');
@@ -2822,6 +2867,7 @@ loop: for (;;) {
2822
2867
  return false;
2823
2868
  }
2824
2869
 
2870
+
2825
2871
  function cssLineHeight() {
2826
2872
  if (nexttoken.id === '-') {
2827
2873
  advance('-');
@@ -2839,6 +2885,7 @@ loop: for (;;) {
2839
2885
  return false;
2840
2886
  }
2841
2887
 
2888
+
2842
2889
  function cssWidth() {
2843
2890
  if (nexttoken.identifier) {
2844
2891
  switch (nexttoken.value) {
@@ -2853,6 +2900,7 @@ loop: for (;;) {
2853
2900
  }
2854
2901
  }
2855
2902
 
2903
+
2856
2904
  function cssMargin() {
2857
2905
  if (nexttoken.identifier) {
2858
2906
  if (nexttoken.value === 'auto') {
@@ -2879,6 +2927,7 @@ loop: for (;;) {
2879
2927
  return false;
2880
2928
  }
2881
2929
 
2930
+
2882
2931
  function cssCommaList() {
2883
2932
  while (nexttoken.id !== ';') {
2884
2933
  if (!cssName() && !cssString()) {
@@ -2892,12 +2941,11 @@ loop: for (;;) {
2892
2941
  }
2893
2942
  }
2894
2943
 
2944
+
2895
2945
  function cssCounter() {
2896
2946
  if (nexttoken.identifier && nexttoken.value === 'counter') {
2897
2947
  advance();
2898
2948
  advance('(');
2899
- if (!nexttoken.identifier) {
2900
- }
2901
2949
  advance();
2902
2950
  if (nexttoken.id === ',') {
2903
2951
  comma();
@@ -2959,6 +3007,7 @@ loop: for (;;) {
2959
3007
  return false;
2960
3008
  }
2961
3009
 
3010
+
2962
3011
  function cssUrl() {
2963
3012
  var c, url;
2964
3013
  if (nexttoken.identifier && nexttoken.value === 'url') {
@@ -2988,6 +3037,7 @@ loop: for (;;) {
2988
3037
  return false;
2989
3038
  }
2990
3039
 
3040
+
2991
3041
  cssAny = [cssUrl, function () {
2992
3042
  for (;;) {
2993
3043
  if (nexttoken.identifier) {
@@ -3013,15 +3063,29 @@ loop: for (;;) {
3013
3063
  }
3014
3064
  }];
3015
3065
 
3066
+
3016
3067
  cssBorderStyle = [
3017
- 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'ridge',
3018
- 'inset', 'outset'
3068
+ 'none', 'dashed', 'dotted', 'double', 'groove',
3069
+ 'hidden', 'inset', 'outset', 'ridge', 'solid'
3019
3070
  ];
3020
3071
 
3021
3072
  cssBreak = [
3022
3073
  'auto', 'always', 'avoid', 'left', 'right'
3023
3074
  ];
3024
3075
 
3076
+ cssMedia = {
3077
+ 'all': true,
3078
+ 'braille': true,
3079
+ 'embossed': true,
3080
+ 'handheld': true,
3081
+ 'print': true,
3082
+ 'projection': true,
3083
+ 'screen': true,
3084
+ 'speech': true,
3085
+ 'tty': true,
3086
+ 'tv': true
3087
+ };
3088
+
3025
3089
  cssOverflow = [
3026
3090
  'auto', 'hidden', 'scroll', 'visible'
3027
3091
  ];
@@ -3238,6 +3302,7 @@ loop: for (;;) {
3238
3302
  }
3239
3303
  }
3240
3304
 
3305
+
3241
3306
  function styleValue(v) {
3242
3307
  var i = 0,
3243
3308
  n,
@@ -3373,7 +3438,8 @@ loop: for (;;) {
3373
3438
 
3374
3439
  function styleSelector() {
3375
3440
  if (nexttoken.identifier) {
3376
- if (!is_own(htmltag, nexttoken.value)) {
3441
+ if (!is_own(htmltag, option.cap ?
3442
+ nexttoken.value.toLowerCase() : nexttoken.value)) {
3377
3443
  warning("Expected a tagName, and instead saw {a}.",
3378
3444
  nexttoken, nexttoken.value);
3379
3445
  }
@@ -3401,6 +3467,7 @@ loop: for (;;) {
3401
3467
  case 'first-of-type':
3402
3468
  case 'focus':
3403
3469
  case 'hover':
3470
+ case 'last-child':
3404
3471
  case 'last-of-type':
3405
3472
  case 'link':
3406
3473
  case 'only-of-type':
@@ -3489,18 +3556,9 @@ loop: for (;;) {
3489
3556
  }
3490
3557
 
3491
3558
  function stylePattern() {
3492
- var name;
3493
3559
  if (nexttoken.id === '{') {
3494
3560
  warning("Expected a style pattern, and instead saw '{a}'.", nexttoken,
3495
3561
  nexttoken.id);
3496
- } else if (nexttoken.id === '@') {
3497
- advance('@');
3498
- name = nexttoken.value;
3499
- if (nexttoken.identifier && atrule[name] === true) {
3500
- advance();
3501
- return name;
3502
- }
3503
- warning("Expected an at-rule, and instead saw @{a}.", nexttoken, name);
3504
3562
  }
3505
3563
  for (;;) {
3506
3564
  styleSelector();
@@ -3514,23 +3572,7 @@ loop: for (;;) {
3514
3572
  }
3515
3573
  }
3516
3574
 
3517
- function styles() {
3518
- var i;
3519
- while (nexttoken.id === '@') {
3520
- i = peek();
3521
- if (i.identifier && i.value === 'import') {
3522
- advance('@');
3523
- advance();
3524
- if (!cssUrl()) {
3525
- warning("Expected '{a}' and instead saw '{b}'.", nexttoken,
3526
- 'url', nexttoken.value);
3527
- advance();
3528
- }
3529
- advance(';');
3530
- } else {
3531
- break;
3532
- }
3533
- }
3575
+ function stylelist() {
3534
3576
  while (nexttoken.id !== '</' && nexttoken.id !== '(end)') {
3535
3577
  stylePattern();
3536
3578
  xmode = 'styleproperty';
@@ -3545,6 +3587,50 @@ loop: for (;;) {
3545
3587
  }
3546
3588
  }
3547
3589
 
3590
+ function styles() {
3591
+ var i;
3592
+ while (nexttoken.id === '@') {
3593
+ i = peek();
3594
+ advance('@');
3595
+ if (nexttoken.identifier) {
3596
+ switch (nexttoken.value) {
3597
+ case 'import':
3598
+ advance();
3599
+ if (!cssUrl()) {
3600
+ warning("Expected '{a}' and instead saw '{b}'.",
3601
+ nexttoken, 'url', nexttoken.value);
3602
+ advance();
3603
+ }
3604
+ advance(';');
3605
+ break;
3606
+ case 'media':
3607
+ advance();
3608
+ for (;;) {
3609
+ if (!nexttoken.identifier || cssMedia[nexttoken.value] === true) {
3610
+ error("Expected a CSS media type, and instead saw '{a}'.", nexttoken, nexttoken.id);
3611
+ }
3612
+ advance();
3613
+ if (nexttoken.id !== ',') {
3614
+ break;
3615
+ }
3616
+ advance(',');
3617
+ }
3618
+ advance('{');
3619
+ stylelist();
3620
+ advance('}');
3621
+ break;
3622
+ default:
3623
+ warning("Expected an at-rule, and instead saw @{a}.",
3624
+ nexttoken, nexttoken.value);
3625
+ }
3626
+ } else {
3627
+ warning("Expected an at-rule, and instead saw '{a}'.",
3628
+ nexttoken, nexttoken.value);
3629
+ }
3630
+ }
3631
+ stylelist();
3632
+ }
3633
+
3548
3634
 
3549
3635
  // HTML parsing.
3550
3636
 
@@ -3928,13 +4014,13 @@ loop: for (;;) {
3928
4014
  break;
3929
4015
  }
3930
4016
  if (nexttoken.value.indexOf('--') >= 0) {
3931
- warning("Unexpected --.");
4017
+ error("Unexpected --.");
3932
4018
  }
3933
4019
  if (nexttoken.value.indexOf('<') >= 0) {
3934
- warning("Unexpected <.");
4020
+ error("Unexpected <.");
3935
4021
  }
3936
4022
  if (nexttoken.value.indexOf('>') >= 0) {
3937
- warning("Unexpected >.");
4023
+ error("Unexpected >.");
3938
4024
  }
3939
4025
  }
3940
4026
  xmode = 'outer';
@@ -3963,8 +4049,12 @@ loop: for (;;) {
3963
4049
 
3964
4050
  // Build the syntax table by declaring the syntactic elements of the language.
3965
4051
 
3966
- type('(number)', idValue);
3967
- type('(string)', idValue);
4052
+ type('(number)', function () {
4053
+ return this;
4054
+ });
4055
+ type('(string)', function () {
4056
+ return this;
4057
+ });
3968
4058
 
3969
4059
  syntax['(identifier)'] = {
3970
4060
  type: '(identifier)',
@@ -3975,6 +4065,9 @@ loop: for (;;) {
3975
4065
  s = scope[v],
3976
4066
  f;
3977
4067
  if (typeof s === 'function') {
4068
+
4069
+ // Protection against accidental inheritance.
4070
+
3978
4071
  s = undefined;
3979
4072
  } else if (typeof s === 'boolean') {
3980
4073
  f = funct;
@@ -3994,6 +4087,13 @@ loop: for (;;) {
3994
4087
  case 'unused':
3995
4088
  funct[v] = 'var';
3996
4089
  break;
4090
+ case 'unction':
4091
+ funct[v] = 'function';
4092
+ this['function'] = true;
4093
+ break;
4094
+ case 'function':
4095
+ this['function'] = true;
4096
+ break;
3997
4097
  case 'label':
3998
4098
  warning("'{a}' is a statement label.", token, v);
3999
4099
  break;
@@ -4003,7 +4103,7 @@ loop: for (;;) {
4003
4103
  // then we have an undefined variable.
4004
4104
 
4005
4105
  } else if (funct['(global)']) {
4006
- if (option.undef && predefined[v] !== 'boolean') {
4106
+ if (option.undef && typeof predefined[v] !== 'boolean') {
4007
4107
  warning("'{a}' is not defined.", token, v);
4008
4108
  }
4009
4109
  note_implied(token);
@@ -4045,6 +4145,11 @@ loop: for (;;) {
4045
4145
  } else {
4046
4146
  switch (s[v]) {
4047
4147
  case 'function':
4148
+ case 'unction':
4149
+ this['function'] = true;
4150
+ s[v] = 'closure';
4151
+ funct[v] = s['(global)'] ? 'global' : 'outer';
4152
+ break;
4048
4153
  case 'var':
4049
4154
  case 'unused':
4050
4155
  s[v] = 'closure';
@@ -4064,7 +4169,7 @@ loop: for (;;) {
4064
4169
  },
4065
4170
  led: function () {
4066
4171
  error("Expected an operator and instead saw '{a}'.",
4067
- nexttoken, nexttoken.value);
4172
+ nexttoken, nexttoken.value);
4068
4173
  }
4069
4174
  };
4070
4175
 
@@ -4098,13 +4203,30 @@ loop: for (;;) {
4098
4203
  reserve('catch');
4099
4204
  reserve('default').reach = true;
4100
4205
  reserve('finally');
4101
- reservevar('arguments');
4102
- reservevar('eval');
4206
+ reservevar('arguments', function (x) {
4207
+ if (strict_mode && funct['(global)']) {
4208
+ warning("Strict violation.", x);
4209
+ } else if (option.safe) {
4210
+ warning("ADsafe violation.", x);
4211
+ }
4212
+ });
4213
+ reservevar('eval', function (x) {
4214
+ if (option.safe) {
4215
+ warning("ADsafe violation.", x);
4216
+ }
4217
+ });
4103
4218
  reservevar('false');
4104
4219
  reservevar('Infinity');
4105
4220
  reservevar('NaN');
4106
4221
  reservevar('null');
4107
- reservevar('this');
4222
+ reservevar('this', function (x) {
4223
+ if (strict_mode && ((funct['(statement)'] &&
4224
+ funct['(name)'].charAt(0) > 'Z') || funct['(global)'])) {
4225
+ warning("Strict violation.", x);
4226
+ } else if (option.safe) {
4227
+ warning("ADsafe violation.", x);
4228
+ }
4229
+ });
4108
4230
  reservevar('true');
4109
4231
  reservevar('undefined');
4110
4232
  assignop('=', 'assign', 20);
@@ -4205,8 +4327,32 @@ loop: for (;;) {
4205
4327
  return that;
4206
4328
  }, 130);
4207
4329
  prefix('+', 'num');
4330
+ prefix('+++', function () {
4331
+ warning("Confusing pluses.");
4332
+ this.right = parse(150);
4333
+ this.arity = 'unary';
4334
+ return this;
4335
+ });
4336
+ infix('+++', function (left) {
4337
+ warning("Confusing pluses.");
4338
+ this.left = left;
4339
+ this.right = parse(130);
4340
+ return this;
4341
+ }, 130);
4208
4342
  infix('-', 'sub', 130);
4209
4343
  prefix('-', 'neg');
4344
+ prefix('---', function () {
4345
+ warning("Confusing minuses.");
4346
+ this.right = parse(150);
4347
+ this.arity = 'unary';
4348
+ return this;
4349
+ });
4350
+ infix('---', function (left) {
4351
+ warning("Confusing minuses.");
4352
+ this.left = left;
4353
+ this.right = parse(130);
4354
+ return this;
4355
+ }, 130);
4210
4356
  infix('*', 'mult', 140);
4211
4357
  infix('/', 'div', 140);
4212
4358
  infix('%', 'mod', 140);
@@ -4221,8 +4367,7 @@ loop: for (;;) {
4221
4367
  prefix('delete', function () {
4222
4368
  var p = parse(0);
4223
4369
  if (!p || (p.id !== '.' && p.id !== '[')) {
4224
- warning("Expected '{a}' and instead saw '{b}'.",
4225
- nexttoken, '.', nexttoken.value);
4370
+ warning("Variables should not be deleted.");
4226
4371
  }
4227
4372
  this.first = p;
4228
4373
  return this;
@@ -4325,13 +4470,17 @@ loop: for (;;) {
4325
4470
 
4326
4471
  infix('.', function (left, that) {
4327
4472
  adjacent(prevtoken, token);
4473
+ nobreak();
4328
4474
  var m = identifier();
4329
4475
  if (typeof m === 'string') {
4330
4476
  countMember(m);
4331
4477
  }
4332
4478
  that.left = left;
4333
4479
  that.right = m;
4334
- if (!option.evil && left && left.value === 'document' &&
4480
+ if (left && left.value === 'arguments' &&
4481
+ (m === 'callee' || m === 'caller')) {
4482
+ warning("Avoid arguments.{a}.", left, m);
4483
+ } else if (!option.evil && left && left.value === 'document' &&
4335
4484
  (m === 'write' || m === 'writeln')) {
4336
4485
  warning("document.write can be a form of eval.", left);
4337
4486
  } else if (option.adsafe) {
@@ -4387,8 +4536,15 @@ loop: for (;;) {
4387
4536
  }, 160, true);
4388
4537
 
4389
4538
  infix('(', function (left, that) {
4390
- adjacent(prevtoken, token);
4539
+ if (prevtoken.id !== '}' && prevtoken.id !== ')') {
4540
+ nobreak(prevtoken, token);
4541
+ }
4391
4542
  nospace();
4543
+ if (option.immed && !left.immed && left.id === 'function') {
4544
+ warning("Wrap an immediate function invocation in parentheses " +
4545
+ "to assist the reader in understanding that the expression " +
4546
+ "is the result of a function, and not the function itself.");
4547
+ }
4392
4548
  var n = 0,
4393
4549
  p = [];
4394
4550
  if (left) {
@@ -4423,10 +4579,6 @@ loop: for (;;) {
4423
4579
  }
4424
4580
  }
4425
4581
  advance(')');
4426
- if (option.immed && left.id === 'function' && nexttoken.id !== ')') {
4427
- warning("Wrap the entire immediate function invocation in parens.",
4428
- that);
4429
- }
4430
4582
  nospace(prevtoken, token);
4431
4583
  if (typeof left === 'object') {
4432
4584
  if (left.value === 'parseInt' && n === 1) {
@@ -4455,6 +4607,9 @@ loop: for (;;) {
4455
4607
 
4456
4608
  prefix('(', function () {
4457
4609
  nospace();
4610
+ if (nexttoken.id === 'function') {
4611
+ nexttoken.immed = true;
4612
+ }
4458
4613
  var v = parse(0);
4459
4614
  advance(')', this);
4460
4615
  nospace(prevtoken, token);
@@ -4472,6 +4627,7 @@ loop: for (;;) {
4472
4627
  });
4473
4628
 
4474
4629
  infix('[', function (left, that) {
4630
+ nobreak(prevtoken, token);
4475
4631
  nospace();
4476
4632
  var e = parse(0), s;
4477
4633
  if (e && e.type === '(string)') {
@@ -4542,22 +4698,28 @@ loop: for (;;) {
4542
4698
  advance(']', this);
4543
4699
  return this;
4544
4700
  }, 160);
4545
-
4546
-
4701
+
4702
+
4547
4703
  function property_name() {
4548
- var i = optionalidentifier(true);
4549
- if (!i) {
4704
+ var id = optionalidentifier(true);
4705
+ if (!id) {
4550
4706
  if (nexttoken.id === '(string)') {
4551
- i = nexttoken.value;
4707
+ id = nexttoken.value;
4708
+ if (option.adsafe &&
4709
+ (id.charAt(0) === '_' ||
4710
+ id.charAt(id.length - 1) === '_')) {
4711
+ warning("Unexpected {a} in '{b}'.", token,
4712
+ "dangling '_'", id);
4713
+ }
4552
4714
  advance();
4553
4715
  } else if (nexttoken.id === '(number)') {
4554
- i = nexttoken.value.toString();
4716
+ id = nexttoken.value.toString();
4555
4717
  advance();
4556
4718
  }
4557
4719
  }
4558
- return i;
4720
+ return id;
4559
4721
  }
4560
-
4722
+
4561
4723
 
4562
4724
  function functionparams() {
4563
4725
  var i, t = nexttoken, p = [];
@@ -4581,18 +4743,19 @@ loop: for (;;) {
4581
4743
  }
4582
4744
  }
4583
4745
  }
4584
-
4585
4746
 
4586
- function doFunction(i) {
4747
+
4748
+ function doFunction(i, statement) {
4587
4749
  var f, s = scope;
4588
4750
  scope = Object.create(s);
4589
4751
  funct = {
4590
- '(name)' : i || '"' + anonname + '"',
4591
- '(line)' : nexttoken.line,
4592
- '(context)' : funct,
4593
- '(breakage)': 0,
4594
- '(loopage)' : 0,
4595
- '(scope)' : scope
4752
+ '(name)' : i || '"' + anonname + '"',
4753
+ '(line)' : nexttoken.line,
4754
+ '(context)' : funct,
4755
+ '(breakage)' : 0,
4756
+ '(loopage)' : 0,
4757
+ '(scope)' : scope,
4758
+ '(statement)': statement
4596
4759
  };
4597
4760
  f = funct;
4598
4761
  token.funct = funct;
@@ -4609,7 +4772,7 @@ loop: for (;;) {
4609
4772
  return f;
4610
4773
  }
4611
4774
 
4612
-
4775
+
4613
4776
  (function (x) {
4614
4777
  x.nud = function () {
4615
4778
  var b, f, i, j, p, seen = {}, t;
@@ -4637,7 +4800,7 @@ loop: for (;;) {
4637
4800
  error("Missing property name.");
4638
4801
  }
4639
4802
  t = nexttoken;
4640
- adjacent(token, nexttoken);
4803
+ adjacent(token, nexttoken);
4641
4804
  f = doFunction(i);
4642
4805
  if (funct['(loopage)']) {
4643
4806
  warning("Don't make functions within a loop.", t);
@@ -4646,7 +4809,7 @@ loop: for (;;) {
4646
4809
  if (p) {
4647
4810
  warning("Unexpected parameter '{a}' in get {b} function.", t, p[0], i);
4648
4811
  }
4649
- adjacent(token, nexttoken);
4812
+ adjacent(token, nexttoken);
4650
4813
  advance(',');
4651
4814
  indentation();
4652
4815
  advance('set');
@@ -4655,7 +4818,7 @@ loop: for (;;) {
4655
4818
  error("Expected {a} and instead saw {b}.", token, i, j);
4656
4819
  }
4657
4820
  t = nexttoken;
4658
- adjacent(token, nexttoken);
4821
+ adjacent(token, nexttoken);
4659
4822
  f = doFunction(i);
4660
4823
  p = f['(params)'];
4661
4824
  if (!p || p.length !== 1 || p[0] !== 'value') {
@@ -4699,7 +4862,7 @@ loop: for (;;) {
4699
4862
  }(delim('{')));
4700
4863
 
4701
4864
 
4702
- function varstatement(prefix) {
4865
+ var varstatement = function varstatement(prefix) {
4703
4866
 
4704
4867
  // JavaScript does not have block scope. It only has function scope. So,
4705
4868
  // declaring a variable in a block can have unexpected consequences.
@@ -4744,7 +4907,7 @@ loop: for (;;) {
4744
4907
  comma();
4745
4908
  }
4746
4909
  return this;
4747
- }
4910
+ };
4748
4911
 
4749
4912
 
4750
4913
  stmt('var', varstatement).exps = true;
@@ -4758,8 +4921,8 @@ loop: for (;;) {
4758
4921
  }
4759
4922
  var i = identifier();
4760
4923
  adjacent(token, nexttoken);
4761
- addlabel(i, 'unused');
4762
- doFunction(i);
4924
+ addlabel(i, 'unction');
4925
+ doFunction(i, true);
4763
4926
  if (nexttoken.id === '(' && nexttoken.line === token.line) {
4764
4927
  error(
4765
4928
  "Function statements are not invocable. Wrap the whole function invocation in parens.");
@@ -5276,27 +5439,30 @@ loop: for (;;) {
5276
5439
  o.safe = true;
5277
5440
  }
5278
5441
  if (o.safe) {
5279
- o.browser = false;
5280
- o.css = false;
5281
- o.debug = false;
5282
- o.devel = false;
5283
- o.eqeqeq = true;
5284
- o.evil = false;
5285
- o.forin = false;
5286
- o.nomen = true;
5287
- o.on = false;
5288
- o.rhino = false;
5289
- o.safe = true;
5290
- o.windows = false;
5291
- o.strict = true;
5292
- o.sub = false;
5293
- o.undef = true;
5442
+ o.browser =
5443
+ o.css =
5444
+ o.debug =
5445
+ o.devel =
5446
+ o.evil =
5447
+ o.forin =
5448
+ o.on =
5449
+ o.rhino =
5450
+ o.windows =
5451
+ o.sub =
5294
5452
  o.widget = false;
5295
- predefined.Date = null;
5296
- predefined['eval'] = null;
5297
- predefined.Function = null;
5453
+
5454
+ o.eqeqeq =
5455
+ o.nomen =
5456
+ o.safe =
5457
+ o.strict =
5458
+ o.undef = true;
5459
+
5460
+ predefined.Date =
5461
+ predefined['eval'] =
5462
+ predefined.Function =
5298
5463
  predefined.Object = null;
5299
- predefined.ADSAFE = false;
5464
+
5465
+ predefined.ADSAFE =
5300
5466
  predefined.lib = false;
5301
5467
  }
5302
5468
  option = o;
@@ -5375,12 +5541,12 @@ loop: for (;;) {
5375
5541
  if (token.id !== '@' || !nexttoken.identifier ||
5376
5542
  nexttoken.value !== 'charset' || token.line !== 1 ||
5377
5543
  token.from !== 1) {
5378
- error('A css file should begin with @charset "UTF-8";');
5544
+ error("A css file should begin with @charset 'UTF-8';");
5379
5545
  }
5380
5546
  advance();
5381
5547
  if (nexttoken.type !== '(string)' &&
5382
5548
  nexttoken.value !== 'UTF-8') {
5383
- error('A css file should begin with @charset "UTF-8";');
5549
+ error("A css file should begin with @charset 'UTF-8';");
5384
5550
  }
5385
5551
  advance();
5386
5552
  advance(';');
@@ -5467,6 +5633,9 @@ loop: for (;;) {
5467
5633
  for (n in f) {
5468
5634
  if (is_own(f, n) && n.charAt(0) !== '(') {
5469
5635
  v = f[n];
5636
+ if (v === 'unction') {
5637
+ v = 'unused';
5638
+ }
5470
5639
  if (is_array(fu[v])) {
5471
5640
  fu[v].push(n);
5472
5641
  if (v === 'unused') {
@@ -5636,7 +5805,7 @@ loop: for (;;) {
5636
5805
  };
5637
5806
  itself.jslint = itself;
5638
5807
 
5639
- itself.edition = '2010-04-06';
5808
+ itself.edition = '2010-11-27';
5640
5809
 
5641
5810
  return itself;
5642
5811