jslint-source 2012.01.13 → 2012.08.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/vendor/jslint/jslint.js +487 -928
  2. metadata +10 -5
@@ -1,5 +1,5 @@
1
1
  // jslint.js
2
- // 2012-01-13
2
+ // 2012-08-11
3
3
 
4
4
  // Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
5
5
 
@@ -63,15 +63,6 @@
63
63
  // enough to continue. It does not necessarily mean that the error was
64
64
  // especially heinous.
65
65
 
66
- // You can request a Function Report, which shows all of the functions
67
- // and the parameters and vars that they use. This can be used to find
68
- // implied global variables and other problems. The report is in HTML and
69
- // can be inserted in an HTML <body>.
70
-
71
- // var myReport = JSLINT.report(errors_only);
72
-
73
- // If errors_only is true, then the report will be limited to only errors.
74
-
75
66
  // You can request a data structure that contains JSLint's results.
76
67
 
77
68
  // var myData = JSLINT.data();
@@ -137,8 +128,25 @@
137
128
 
138
129
  // Empty arrays will not be included.
139
130
 
131
+ // You can request a Function Report, which shows all of the functions
132
+ // and the parameters and vars that they use. This can be used to find
133
+ // implied global variables and other problems. The report is in HTML and
134
+ // can be inserted in an HTML <body>. It should be given the result of the
135
+ // JSLINT.data function.
136
+
137
+ // var myReport = JSLINT.report(data);
138
+
139
+ // You can request an HTML error report.
140
+
141
+ // var myErrorReport = JSLINT.error_report(data);
142
+
143
+ // You can request a properties report, which produces a list of the program's
144
+ // properties in the form of a /*properties*/ declaration.
145
+
146
+ // var myPropertyReport = JSLINT.properties_report(JSLINT.property);
147
+
140
148
  // You can obtain the parse tree that JSLint constructed while parsing. The
141
- // latest tree is kept in JSLINT.tree. A nice stringication can be produced
149
+ // latest tree is kept in JSLINT.tree. A nice stringification can be produced
142
150
  // with
143
151
 
144
152
  // JSON.stringify(JSLINT.tree, [
@@ -153,13 +161,18 @@
153
161
  // These directives respect function scope.
154
162
 
155
163
  // The jslint directive is a special comment that can set one or more options.
164
+ // For example:
165
+
166
+ /*jslint
167
+ evil: true, nomen: true, regexp: true, todo: true
168
+ */
169
+
156
170
  // The current option set is
157
171
 
158
172
  // anon true, if the space may be omitted in anonymous function declarations
159
173
  // bitwise true, if bitwise operators should be allowed
160
174
  // browser true, if the standard browser globals should be predefined
161
175
  // cap true, if upper case HTML should be allowed
162
- // confusion true, if types can be used inconsistently
163
176
  // 'continue' true, if the continuation statement should be tolerated
164
177
  // css true, if CSS workarounds should be tolerated
165
178
  // debug true, if debugger statements should be allowed
@@ -184,18 +197,13 @@
184
197
  // undef true, if variables can be declared out of order
185
198
  // unparam true, if unused parameters should be tolerated
186
199
  // sloppy true, if the 'use strict'; pragma is optional
200
+ // stupid true, if really stupid practices are tolerated
187
201
  // sub true, if all forms of subscript notation are tolerated
202
+ // todo true, if TODO comments are tolerated
188
203
  // vars true, if multiple var statements per function should be allowed
189
204
  // white true, if sloppy whitespace is tolerated
190
- // widget true if the Yahoo Widgets globals should be predefined
191
205
  // windows true, if MS Windows-specific globals should be predefined
192
206
 
193
- // For example:
194
-
195
- /*jslint
196
- evil: true, nomen: true, regexp: true
197
- */
198
-
199
207
  // The properties directive declares an exclusive list of property names.
200
208
  // Any properties named in the program that are not in the list will
201
209
  // produce a warning.
@@ -203,199 +211,102 @@
203
211
  // For example:
204
212
 
205
213
  /*properties
206
- '\b': string, '\t': string, '\n': string, '\f': string, '\r': string,
207
- '!=': boolean, '!==': boolean, '"': string, '%': boolean, '\'': string,
208
- '(begin)', '(breakage)': number, '(confusion)': boolean,
209
- '(context)': object, '(error)', '(identifier)', '(line)': number,
210
- '(loopage)': number, '(name)', '(old_property_type)', '(params)',
211
- '(scope)': object, '(token)', '(vars)', '(verb)', '*': boolean,
212
- '+': boolean, '-': boolean, '/': *, '<': boolean, '<=': boolean,
213
- '==': boolean, '===': boolean, '>': boolean, '>=': boolean,
214
- ADSAFE: boolean, Array, Date, E: string, Function, LN10: string,
215
- LN2: string, LOG10E: string, LOG2E: string, MAX_VALUE: string,
216
- MIN_VALUE: string, NEGATIVE_INFINITY: string, Object, PI: string,
217
- POSITIVE_INFINITY: string, SQRT1_2: string, SQRT2: string, '\\': string,
218
- a: object, a_label: string, a_not_allowed: string, a_not_defined: string,
219
- a_scope: string, abbr: object, acronym: object, address: object, adsafe,
220
- adsafe_a: string, adsafe_autocomplete: string, adsafe_bad_id: string,
221
- adsafe_div: string, adsafe_fragment: string, adsafe_go: string,
222
- adsafe_html: string, adsafe_id: string, adsafe_id_go: string,
223
- adsafe_lib: string, adsafe_lib_second: string, adsafe_missing_id: string,
224
- adsafe_name_a: string, adsafe_placement: string, adsafe_prefix_a: string,
225
- adsafe_script: string, adsafe_source: string, adsafe_subscript_a: string,
226
- adsafe_tag: string, all: boolean, already_defined: string, and: string,
227
- anon, applet: object, apply: string, approved: array, area: object,
228
- arity: string, article: object, aside: object, assign: boolean,
229
- assign_exception: string, assignment_function_expression: string,
230
- at: number, attribute_case_a: string, audio: object, autocomplete: string,
231
- avoid_a: string, b: *, background: array, 'background-attachment': array,
232
- 'background-color': array, 'background-image': array,
233
- 'background-position': array, 'background-repeat': array,
234
- bad_assignment: string, bad_color_a: string, bad_constructor: string,
235
- bad_entity: string, bad_html: string, bad_id_a: string, bad_in_a: string,
236
- bad_invocation: string, bad_name_a: string, bad_new: string,
237
- bad_number: string, bad_operand: string, bad_style: string,
238
- bad_type: string, bad_url_a: string, bad_wrap: string, base: object,
239
- bdo: object, big: object, bind: string, bitwise: boolean, block: array,
240
- blockquote: object, body: object, border: array, 'border-bottom': array,
241
- 'border-bottom-color', 'border-bottom-left-radius',
242
- 'border-bottom-right-radius', 'border-bottom-style': array,
243
- 'border-bottom-width', 'border-collapse': array, 'border-color': array,
244
- 'border-left': array, 'border-left-color', 'border-left-style': array,
245
- 'border-left-width', 'border-radius', 'border-right': array,
246
- 'border-right-color', 'border-right-style': array, 'border-right-width',
247
- 'border-spacing': array, 'border-style': array, 'border-top': array,
248
- 'border-top-color', 'border-top-left-radius', 'border-top-right-radius',
249
- 'border-top-style': array, 'border-top-width', 'border-width': array,
250
- bottom: array, br: object, braille: boolean, browser: boolean,
251
- button: object, c, call: string, canvas: object, cap, caption: object,
252
- 'caption-side': array, ceil: string, center: object, charAt: *,
253
- charCodeAt: *, character, cite: object, clear: array, clip: array, closure,
254
- cm: boolean, code: object, col: object, colgroup: object, color,
255
- combine_var: string, command: object, concat: string,
256
- conditional_assignment: string, confusing_a: string,
257
- confusing_regexp: string, confusion: boolean, constructor: string,
258
- constructor_name_a: string, content: array, continue, control_a: string,
259
- 'counter-increment': array, 'counter-reset': array, create: *, css: string,
260
- cursor: array, d, dangerous_comment: string, dangling_a: string,
261
- data: function object, datalist: object, dd: object, debug,
262
- defineProperties: string, defineProperty: string, del: object,
263
- deleted: string, details: object, devel: boolean, dfn: object,
264
- dialog: object, dir: object, direction: array, display: array,
265
- disrupt: boolean, div: object, dl: object, dt: object, duplicate_a: string,
266
- edge: string, edition: string, else, em: *, embed: object,
267
- embossed: boolean, empty: boolean, 'empty-cells': array,
268
- empty_block: string, empty_case: string, empty_class: string,
269
- entityify: function, eqeq, errors: array, es5: string, eval, every: string,
270
- evidence, evil: string, ex: boolean, exception, exec: *,
271
- expected_a: string, expected_a_at_b_c: string, expected_a_b: string,
272
- expected_a_b_from_c_d: string, expected_at_a: string,
273
- expected_attribute_a: string, expected_attribute_value_a: string,
274
- expected_class_a: string, expected_fraction_a: string,
275
- expected_id_a: string, expected_identifier_a: string,
276
- expected_identifier_a_reserved: string, expected_lang_a: string,
277
- expected_linear_a: string, expected_media_a: string,
278
- expected_name_a: string, expected_nonstandard_style_attribute: string,
279
- expected_number_a: string, expected_operator_a: string,
280
- expected_percent_a: string, expected_positive_a: string,
281
- expected_pseudo_a: string, expected_selector_a: string,
282
- expected_small_a: string, expected_space_a_b: string,
283
- expected_string_a: string, expected_style_attribute: string,
284
- expected_style_pattern: string, expected_tagname_a: string,
285
- expected_type_a: string, f: string, fieldset: object, figure: object,
286
- filter: *, first: *, flag, float: array, floor: *, font: *, 'font-family',
287
- 'font-size': array, 'font-size-adjust': array, 'font-stretch': array,
288
- 'font-style': array, 'font-variant': array, 'font-weight': array,
289
- footer: object, for, forEach: *, for_if: string, forin, form: object,
290
- fragment, frame: object, frameset: object, freeze: string, from: number,
291
- fromCharCode: function, fud: function, funct: object, function,
292
- function_block: string, function_eval: string, function_loop: string,
293
- function_statement: string, function_strict: string, functions: array,
294
- getDate: string, getDay: string, getFullYear: string, getHours: string,
295
- getMilliseconds: string, getMinutes: string, getMonth: string,
296
- getOwnPropertyDescriptor: string, getOwnPropertyNames: string,
297
- getPrototypeOf: string, getSeconds: string, getTime: string,
298
- getTimezoneOffset: string, getUTCDate: string, getUTCDay: string,
299
- getUTCFullYear: string, getUTCHours: string, getUTCMilliseconds: string,
300
- getUTCMinutes: string, getUTCMonth: string, getUTCSeconds: string,
301
- getYear: string, global, globals, h1: object, h2: object, h3: object,
302
- h4: object, h5: object, h6: object, handheld: boolean, hasOwnProperty: *,
303
- head: object, header: object, height: array, hgroup: object, hr: object,
304
- 'hta:application': object, html: *, html_confusion_a: string,
305
- html_handlers: string, i: object, id: string, identifier: boolean,
306
- identifier_function: string, iframe: object, img: object, immed: boolean,
307
- implied_evil: string, in, indent: number, indexOf: *, infix_in: string,
308
- init: function, input: object, ins: object, insecure_a: string,
309
- isAlpha: function, isArray: function boolean, isDigit: function,
310
- isExtensible: string, isFrozen: string, isNaN: string,
311
- isPrototypeOf: string, isSealed: string, join: *, jslint: function boolean,
312
- json: boolean, kbd: object, keygen: object, keys: *, label: object,
313
- label_a_b: string, labeled: boolean, lang: string, lastIndex: string,
314
- lastIndexOf: *, lbp: number, leading_decimal_a: string, led: function,
315
- left: array, legend: object, length: *, 'letter-spacing': array,
316
- li: object, lib: boolean, line: number, 'line-height': array, link: object,
317
- 'list-style': array, 'list-style-image': array,
318
- 'list-style-position': array, 'list-style-type': array, map: *,
319
- margin: array, 'margin-bottom', 'margin-left', 'margin-right',
320
- 'margin-top', mark: object, 'marker-offset': array, match: function,
321
- 'max-height': array, 'max-width': array, maxerr: number,
322
- maxlen: number, member: object, menu: object, message, meta: object,
323
- meter: object, 'min-height': function, 'min-width': function,
324
- missing_a: string, missing_a_after_b: string, missing_option: string,
325
- missing_property: string, missing_space_a_b: string, missing_url: string,
326
- missing_use_strict: string, mixed: string, mm: boolean, mode: string,
327
- move_invocation: string, move_var: string, n: string, name: string,
328
- name_function: string, nav: object, nested_comment: string,
329
- newcap: boolean, node: boolean, noframes: object, nomen, noscript: object,
330
- not: string, not_a_constructor: string, not_a_defined: string,
331
- not_a_function: string, not_a_label: string, not_a_scope: string,
332
- not_greater: string, now: string, nud: function, number: number,
333
- object: object, ol: object, on, opacity, open: boolean, optgroup: object,
334
- option: object, outer: regexp, outline: array, 'outline-color': array,
335
- 'outline-style': array, 'outline-width', output: object, overflow: array,
336
- 'overflow-x': array, 'overflow-y': array, p: object, padding: array,
337
- 'padding-bottom': function, 'padding-left': function,
338
- 'padding-right': function, 'padding-top': function,
339
- 'page-break-after': array, 'page-break-before': array, param: object,
340
- parameter_a_get_b: string, parameter_set_a: string, params: array,
341
- paren: boolean, parent: string, parse: string, passfail, pc: boolean,
342
- plusplus, pop: *, position: array, postscript: boolean, pre: object,
343
- predef, preventExtensions: string, print: boolean, progress: object,
344
- projection: boolean, properties: boolean, propertyIsEnumerable: string,
345
- prototype: string, pt: boolean, push: *, px: boolean, q: object, quote,
346
- quotes: array, r: string, radix: string, range: function, raw,
347
- read_only: string, reason, redefinition_a: string, reduce: string,
348
- reduceRight: string, regexp, replace: function, report: function,
349
- reserved: boolean, reserved_a: string, reverse: string, rhino: boolean,
350
- right: array, rp: object, rt: object, ruby: object, safe: boolean,
351
- samp: object, scanned_a_b: string, screen: boolean, script: object,
352
- seal: string, search: function, second: *, section: object, select: object,
353
- setDate: string, setDay: string, setFullYear: string, setHours: string,
354
- setMilliseconds: string, setMinutes: string, setMonth: string,
355
- setSeconds: string, setTime: string, setTimezoneOffset: string,
356
- setUTCDate: string, setUTCDay: string, setUTCFullYear: string,
357
- setUTCHours: string, setUTCMilliseconds: string, setUTCMinutes: string,
358
- setUTCMonth: string, setUTCSeconds: string, setYear: string, shift: *,
359
- slash_equal: string, slice: string, sloppy, small: object, some: string,
360
- sort: *, source: object, span: object, speech: boolean, splice: string,
361
- split: function, src, statement_block: string, stopping: string,
362
- strange_loop: string, strict: string, string: string, stringify: string,
363
- strong: object, style: *, styleproperty: regexp, sub: object,
364
- subscript: string, substr: *, substring: string, sup: object,
365
- supplant: function, t: string, table: object, 'table-layout': array,
366
- tag_a_in_b: string, tbody: object, td: object, test: *,
367
- 'text-align': array, 'text-decoration': array, 'text-indent': function,
368
- 'text-shadow': array, 'text-transform': array, textarea: object,
369
- tfoot: object, th: object, thead: object, third: array, thru: number,
370
- time: object, title: object, toDateString: string, toExponential: string,
371
- toFixed: string, toISOString: string, toJSON: string,
372
- toLocaleDateString: string, toLocaleLowerCase: string,
373
- toLocaleString: string, toLocaleTimeString: string,
374
- toLocaleUpperCase: string, toLowerCase: *, toPrecision: string,
375
- toString: function, toTimeString: string, toUTCString: string,
376
- toUpperCase: *, token: function, too_long: string, too_many: string,
377
- top: array, tr: object, trailing_decimal_a: string, tree: string,
378
- trim: string, tt: object, tty: boolean, tv: boolean, type: string,
379
- type_confusion_a_b: string, u: object, ul: object, unclosed: string,
380
- unclosed_comment: string, unclosed_regexp: string, undef: boolean,
381
- undefined, unescaped_a: string, unexpected_a: string,
382
- unexpected_char_a_b: string, unexpected_comment: string,
383
- unexpected_property_a: string, unexpected_space_a_b: string,
384
- 'unicode-bidi': array, unnecessary_initialize: string,
385
- unnecessary_use: string, unparam, unreachable_a_b: string,
386
- unrecognized_style_attribute_a: string, unrecognized_tag_a: string,
387
- unsafe: string, unshift: string, unused: array, url: string, urls: array,
388
- use_array: string, use_braces: string, use_charAt: string,
389
- use_object: string, use_or: string, use_param: string,
390
- used_before_a: string, valueOf: string, var: object, var_a_not: string,
391
- vars, 'vertical-align': array, video: object, visibility: array,
392
- warn: boolean, was: object, weird_assignment: string,
393
- weird_condition: string, weird_new: string, weird_program: string,
394
- weird_relation: string, weird_ternary: string, white: boolean,
395
- 'white-space': array, widget: boolean, width: array, windows: boolean,
396
- 'word-spacing': array, 'word-wrap': array, wrap: boolean,
397
- wrap_immediate: string, wrap_regexp: string, write_is_wrong: string,
398
- writeable: boolean, 'z-index': array
214
+ '\b', '\t', '\n', '\f', '\r', '!', '!=', '!==', '"', '%', '\'',
215
+ '(arguments)', '(begin)', '(breakage)', '(context)', '(error)',
216
+ '(identifier)', '(line)', '(loopage)', '(name)', '(params)', '(scope)',
217
+ '(token)', '(vars)', '(verb)', '*', '+', '-', '/', '<', '<=', '==', '===',
218
+ '>', '>=', ADSAFE, Array, Date, Function, Object, '\\', a, a_label,
219
+ a_not_allowed, a_not_defined, a_scope, abbr, acronym, address, adsafe,
220
+ adsafe_a, adsafe_autocomplete, adsafe_bad_id, adsafe_div, adsafe_fragment,
221
+ adsafe_go, adsafe_html, adsafe_id, adsafe_id_go, adsafe_lib,
222
+ adsafe_lib_second, adsafe_missing_id, adsafe_name_a, adsafe_placement,
223
+ adsafe_prefix_a, adsafe_script, adsafe_source, adsafe_subscript_a,
224
+ adsafe_tag, all, already_defined, and, anon, applet, apply, approved, area,
225
+ arity, article, aside, assign, assign_exception,
226
+ assignment_function_expression, at, attribute_case_a, audio, autocomplete,
227
+ avoid_a, b, background, 'background-attachment', 'background-color',
228
+ 'background-image', 'background-position', 'background-repeat',
229
+ bad_assignment, bad_color_a, bad_constructor, bad_entity, bad_html, bad_id_a,
230
+ bad_in_a, bad_invocation, bad_name_a, bad_new, bad_number, bad_operand,
231
+ bad_style, bad_type, bad_url_a, bad_wrap, base, bdo, big, bitwise, block,
232
+ blockquote, body, border, 'border-bottom', 'border-bottom-color',
233
+ 'border-bottom-left-radius', 'border-bottom-right-radius',
234
+ 'border-bottom-style', 'border-bottom-width', 'border-collapse',
235
+ 'border-color', 'border-left', 'border-left-color', 'border-left-style',
236
+ 'border-left-width', 'border-radius', 'border-right', 'border-right-color',
237
+ 'border-right-style', 'border-right-width', 'border-spacing', 'border-style',
238
+ 'border-top', 'border-top-color', 'border-top-left-radius',
239
+ 'border-top-right-radius', 'border-top-style', 'border-top-width',
240
+ 'border-width', bottom, 'box-shadow', br, braille, browser, button, c, call,
241
+ canvas, cap, caption, 'caption-side', center, charAt, charCodeAt, character,
242
+ cite, clear, clip, closure, cm, code, col, colgroup, color, combine_var,
243
+ command, conditional_assignment, confusing_a, confusing_regexp,
244
+ constructor_name_a, content, continue, control_a, 'counter-increment',
245
+ 'counter-reset', create, css, cursor, d, dangerous_comment, dangling_a, data,
246
+ datalist, dd, debug, del, deleted, details, devel, dfn, dialog, dir,
247
+ direction, display, disrupt, div, dl, dt, duplicate_a, edge, edition, else,
248
+ em, embed, embossed, empty, 'empty-cells', empty_block, empty_case,
249
+ empty_class, entityify, eqeq, error_report, errors, es5, eval, evidence,
250
+ evil, ex, exception, exec, expected_a, expected_a_at_b_c, expected_a_b,
251
+ expected_a_b_from_c_d, expected_at_a, expected_attribute_a,
252
+ expected_attribute_value_a, expected_class_a, expected_fraction_a,
253
+ expected_id_a, expected_identifier_a, expected_identifier_a_reserved,
254
+ expected_lang_a, expected_linear_a, expected_media_a, expected_name_a,
255
+ expected_nonstandard_style_attribute, expected_number_a, expected_operator_a,
256
+ expected_percent_a, expected_positive_a, expected_pseudo_a,
257
+ expected_selector_a, expected_small_a, expected_space_a_b, expected_string_a,
258
+ expected_style_attribute, expected_style_pattern, expected_tagname_a,
259
+ expected_type_a, f, fieldset, figure, filter, first, flag, float, floor,
260
+ font, 'font-family', 'font-size', 'font-size-adjust', 'font-stretch',
261
+ 'font-style', 'font-variant', 'font-weight', footer, forEach, for_if, forin,
262
+ form, fragment, frame, frameset, from, fromCharCode, fud, funct, function,
263
+ function_block, function_eval, function_loop, function_statement,
264
+ function_strict, functions, global, globals, h1, h2, h3, h4, h5, h6,
265
+ handheld, hasOwnProperty, head, header, height, hgroup, hr,
266
+ 'hta:application', html, html_confusion_a, html_handlers, i, id, identifier,
267
+ identifier_function, iframe, img, immed, implied_evil, in, indent, indexOf,
268
+ infix_in, init, input, ins, insecure_a, isAlpha, isArray, isDigit, isNaN,
269
+ join, jslint, json, kbd, keygen, keys, label, labeled, lang, lbp,
270
+ leading_decimal_a, led, left, legend, length, 'letter-spacing', li, lib,
271
+ line, 'line-height', link, 'list-style', 'list-style-image',
272
+ 'list-style-position', 'list-style-type', map, margin, 'margin-bottom',
273
+ 'margin-left', 'margin-right', 'margin-top', mark, 'marker-offset', match,
274
+ 'max-height', 'max-width', maxerr, maxlen, menu, message, meta, meter,
275
+ 'min-height', 'min-width', missing_a, missing_a_after_b, missing_option,
276
+ missing_property, missing_space_a_b, missing_url, missing_use_strict, mixed,
277
+ mm, mode, move_invocation, move_var, n, name, name_function, nav,
278
+ nested_comment, newcap, node, noframes, nomen, noscript, not,
279
+ not_a_constructor, not_a_defined, not_a_function, not_a_label, not_a_scope,
280
+ not_greater, nud, number, object, octal_a, ol, on, opacity, open, optgroup,
281
+ option, outer, outline, 'outline-color', 'outline-style', 'outline-width',
282
+ output, overflow, 'overflow-x', 'overflow-y', p, padding, 'padding-bottom',
283
+ 'padding-left', 'padding-right', 'padding-top', 'page-break-after',
284
+ 'page-break-before', param, parameter_a_get_b, parameter_arguments_a,
285
+ parameter_set_a, params, paren, parent, passfail, pc, plusplus, pop,
286
+ position, postscript, pre, predef, print, progress, projection, properties,
287
+ properties_report, property, prototype, pt, push, px, q, quote, quotes, r,
288
+ radix, range, raw, read_only, reason, redefinition_a, regexp, replace,
289
+ report, reserved, reserved_a, rhino, right, rp, rt, ruby, safe, samp,
290
+ scanned_a_b, screen, script, search, second, section, select, shift,
291
+ slash_equal, slice, sloppy, small, sort, source, span, speech, split, src,
292
+ statement_block, stopping, strange_loop, strict, string, strong, stupid,
293
+ style, styleproperty, sub, subscript, substr, sup, supplant, sync_a, t,
294
+ table, 'table-layout', tag_a_in_b, tbody, td, test, 'text-align',
295
+ 'text-decoration', 'text-indent', 'text-shadow', 'text-transform', textarea,
296
+ tfoot, th, thead, third, thru, time, title, todo, todo_comment, toLowerCase,
297
+ toString, toUpperCase, token, too_long, too_many, top, tr,
298
+ trailing_decimal_a, tree, tt, tty, tv, type, u, ul, unclosed,
299
+ unclosed_comment, unclosed_regexp, undef, undefined, unescaped_a,
300
+ unexpected_a, unexpected_char_a_b, unexpected_comment, unexpected_else,
301
+ unexpected_label_a, unexpected_property_a, unexpected_space_a_b,
302
+ unexpected_typeof_a, 'unicode-bidi', unnecessary_initialize,
303
+ unnecessary_use, unparam, unreachable_a_b, unrecognized_style_attribute_a,
304
+ unrecognized_tag_a, unsafe, unused, url, urls, use_array, use_braces,
305
+ use_charAt, use_object, use_or, use_param, used_before_a, var, var_a_not,
306
+ vars, 'vertical-align', video, visibility, was, weird_assignment,
307
+ weird_condition, weird_new, weird_program, weird_relation, weird_ternary,
308
+ white, 'white-space', width, windows, 'word-spacing', 'word-wrap', wrap,
309
+ wrap_immediate, wrap_regexp, write_is_wrong, writeable, 'z-index'
399
310
  */
400
311
 
401
312
  // The global directive is used to declare global variables that can
@@ -431,7 +342,6 @@ var JSLINT = (function () {
431
342
  bitwise : true,
432
343
  browser : true,
433
344
  cap : true,
434
- confusion : true,
435
345
  'continue': true,
436
346
  css : true,
437
347
  debug : true,
@@ -456,10 +366,11 @@ var JSLINT = (function () {
456
366
  undef : true,
457
367
  unparam : true,
458
368
  sloppy : true,
369
+ stupid : true,
459
370
  sub : true,
371
+ todo : true,
460
372
  vars : true,
461
373
  white : true,
462
- widget : true,
463
374
  windows : true
464
375
  },
465
376
  anonname, // The guessed name for anonymous functions.
@@ -495,10 +406,10 @@ var JSLINT = (function () {
495
406
  // web browser environment.
496
407
 
497
408
  browser = array_to_object([
498
- 'clearInterval', 'clearTimeout', 'document', 'event', 'frames',
499
- 'history', 'Image', 'localStorage', 'location', 'name', 'navigator',
500
- 'Option', 'parent', 'screen', 'sessionStorage', 'setInterval',
501
- 'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
409
+ 'clearInterval', 'clearTimeout', 'document', 'event', 'FormData',
410
+ 'frames', 'history', 'Image', 'localStorage', 'location', 'name',
411
+ 'navigator', 'Option', 'parent', 'screen', 'sessionStorage',
412
+ 'setInterval', 'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
502
413
  ], false),
503
414
 
504
415
  // bundle contains the text messages.
@@ -600,19 +511,19 @@ var JSLINT = (function () {
600
511
  expected_selector_a: "Expected a CSS selector, and instead saw {a}.",
601
512
  expected_small_a: "Expected a small positive integer and instead saw '{a}'",
602
513
  expected_space_a_b: "Expected exactly one space between '{a}' and '{b}'.",
603
- expected_string_a: "Expected a string and instead saw {a}.",
514
+ expected_string_a: "Expected a string and instead saw '{a}'.",
604
515
  expected_style_attribute: "Excepted a style attribute, and instead saw '{a}'.",
605
516
  expected_style_pattern: "Expected a style pattern, and instead saw '{a}'.",
606
517
  expected_tagname_a: "Expected a tagName, and instead saw {a}.",
607
518
  expected_type_a: "Expected a type, and instead saw {a}.",
608
519
  for_if: "The body of a for in should be wrapped in an if " +
609
520
  "statement to filter unwanted properties from the prototype.",
610
- function_block: "Function statements should not be placed in blocks. " +
521
+ function_block: "Function statements should not be placed in blocks." +
611
522
  "Use a function expression or move the statement to the top of " +
612
523
  "the outer function.",
613
524
  function_eval: "The Function constructor is eval.",
614
525
  function_loop: "Don't make functions within a loop.",
615
- function_statement: "Function statements are not invocable. " +
526
+ function_statement: "Function statements are not invocable." +
616
527
  "Wrap the whole function invocation in parens.",
617
528
  function_strict: "Use the function form of 'use strict'.",
618
529
  html_confusion_a: "HTML confusion in regular expression '<{a}'.",
@@ -624,7 +535,6 @@ var JSLINT = (function () {
624
535
  "hasOwnProperty method instead.",
625
536
  insecure_a: "Insecure '{a}'.",
626
537
  isNaN: "Use the isNaN function to compare with NaN.",
627
- label_a_b: "Label '{a}' on '{b}' statement.",
628
538
  lang: "lang is deprecated.",
629
539
  leading_decimal_a: "A leading decimal point can be confused with a dot: '.{a}'.",
630
540
  missing_a: "Missing '{a}'.",
@@ -647,6 +557,8 @@ var JSLINT = (function () {
647
557
  not_a_label: "'{a}' is not a label.",
648
558
  not_a_scope: "'{a}' is out of scope.",
649
559
  not_greater: "'{a}' should not be greater than '{b}'.",
560
+ octal_a: "Don't use octal: '{a}'. Use '\\u....' instead.",
561
+ parameter_arguments_a: "Do not mutate parameter '{a}' when using 'arguments'.",
650
562
  parameter_a_get_b: "Unexpected parameter '{a}' in get {b} function.",
651
563
  parameter_set_a: "Expected parameter (value) in set {a} function.",
652
564
  radix: "Missing radix parameter.",
@@ -656,17 +568,18 @@ var JSLINT = (function () {
656
568
  scanned_a_b: "{a} ({b}% scanned).",
657
569
  slash_equal: "A regular expression literal can be confused with '/='.",
658
570
  statement_block: "Expected to see a statement and instead saw a block.",
659
- stopping: "Stopping. ",
571
+ stopping: "Stopping.",
660
572
  strange_loop: "Strange loop.",
661
573
  strict: "Strict violation.",
662
574
  subscript: "['{a}'] is better written in dot notation.",
575
+ sync_a: "Unexpected sync method: '{a}'.",
663
576
  tag_a_in_b: "A '<{a}>' must be within '<{b}>'.",
577
+ todo_comment: "Unexpected TODO comment.",
664
578
  too_long: "Line too long.",
665
579
  too_many: "Too many errors.",
666
580
  trailing_decimal_a: "A trailing decimal point can be confused " +
667
581
  "with a dot: '.{a}'.",
668
582
  type: "type is unnecessary.",
669
- type_confusion_a_b: "Type confusion: {a} and {b}.",
670
583
  unclosed: "Unclosed string.",
671
584
  unclosed_comment: "Unclosed comment.",
672
585
  unclosed_regexp: "Unclosed regular expression.",
@@ -674,8 +587,12 @@ var JSLINT = (function () {
674
587
  unexpected_a: "Unexpected '{a}'.",
675
588
  unexpected_char_a_b: "Unexpected character '{a}' in {b}.",
676
589
  unexpected_comment: "Unexpected comment.",
590
+ unexpected_else: "Unexpected 'else' after 'return'.",
591
+ unexpected_label_a: "Unexpected label '{a}'.",
677
592
  unexpected_property_a: "Unexpected /*property*/ '{a}'.",
678
593
  unexpected_space_a_b: "Unexpected space between '{a}' and '{b}'.",
594
+ unexpected_typeof_a: "Unexpected 'typeof'. " +
595
+ "Use '===' to compare directly with {a}.",
679
596
  unnecessary_initialize: "It is not necessary to initialize '{a}' " +
680
597
  "to 'undefined'.",
681
598
  unnecessary_use: "Unnecessary 'use strict'.",
@@ -776,7 +693,8 @@ var JSLINT = (function () {
776
693
  'r': '\r',
777
694
  '"': '"',
778
695
  '/': '/',
779
- '\\': '\\'
696
+ '\\': '\\',
697
+ '!': '!'
780
698
  },
781
699
 
782
700
  devel = array_to_object([
@@ -929,17 +847,11 @@ var JSLINT = (function () {
929
847
  ids, // HTML ids
930
848
  in_block,
931
849
  indent,
932
- // infer_statement,// Inference rules for statements
933
- is_type = array_to_object([
934
- '*', 'array', 'boolean', 'function', 'number', 'object',
935
- 'regexp', 'string'
936
- ], true),
937
850
  itself, // JSLint itself
938
851
  json_mode,
939
852
  lex, // the tokenizer
940
853
  lines,
941
854
  lookahead,
942
- member,
943
855
  node = array_to_object([
944
856
  'Buffer', 'clearInterval', 'clearTimeout', 'console', 'exports',
945
857
  'global', 'module', 'process', 'querystring', 'require',
@@ -952,7 +864,7 @@ var JSLINT = (function () {
952
864
  predefined, // Global variables defined by option
953
865
  prereg,
954
866
  prev_token,
955
- property_type,
867
+ property,
956
868
  regexp_flag = array_to_object(['g', 'i', 'm'], true),
957
869
  return_this = function return_this() {
958
870
  return this;
@@ -974,165 +886,19 @@ var JSLINT = (function () {
974
886
  standard = array_to_object([
975
887
  'Array', 'Boolean', 'Date', 'decodeURI', 'decodeURIComponent',
976
888
  'encodeURI', 'encodeURIComponent', 'Error', 'eval', 'EvalError',
977
- 'Function', 'isFinite', 'isNaN', 'JSON', 'Math', 'Number', 'Object',
978
- 'parseInt', 'parseFloat', 'RangeError', 'ReferenceError', 'RegExp',
979
- 'String', 'SyntaxError', 'TypeError', 'URIError'
889
+ 'Function', 'isFinite', 'isNaN', 'JSON', 'Math', 'Number',
890
+ 'Object', 'parseInt', 'parseFloat', 'RangeError', 'ReferenceError',
891
+ 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError'
980
892
  ], false),
981
893
 
982
- standard_property_type = {
983
- E : 'number',
984
- LN2 : 'number',
985
- LN10 : 'number',
986
- LOG2E : 'number',
987
- LOG10E : 'number',
988
- MAX_VALUE : 'number',
989
- MIN_VALUE : 'number',
990
- NEGATIVE_INFINITY : 'number',
991
- PI : 'number',
992
- POSITIVE_INFINITY : 'number',
993
- SQRT1_2 : 'number',
994
- SQRT2 : 'number',
995
- apply : 'function',
996
- bind : 'function function',
997
- call : 'function',
998
- ceil : 'function number',
999
- charAt : 'function string',
1000
- concat : 'function',
1001
- constructor : 'function object',
1002
- create : 'function object',
1003
- defineProperty : 'function object',
1004
- defineProperties : 'function object',
1005
- every : 'function boolean',
1006
- exec : 'function array',
1007
- filter : 'function array',
1008
- floor : 'function number',
1009
- forEach : 'function',
1010
- freeze : 'function object',
1011
- getDate : 'function number',
1012
- getDay : 'function number',
1013
- getFullYear : 'function number',
1014
- getHours : 'function number',
1015
- getMilliseconds : 'function number',
1016
- getMinutes : 'function number',
1017
- getMonth : 'function number',
1018
- getOwnPropertyDescriptor
1019
- : 'function object',
1020
- getOwnPropertyNames : 'function array',
1021
- getPrototypeOf : 'function object',
1022
- getSeconds : 'function number',
1023
- getTime : 'function number',
1024
- getTimezoneOffset : 'function number',
1025
- getUTCDate : 'function number',
1026
- getUTCDay : 'function number',
1027
- getUTCFullYear : 'function number',
1028
- getUTCHours : 'function number',
1029
- getUTCMilliseconds : 'function number',
1030
- getUTCMinutes : 'function number',
1031
- getUTCMonth : 'function number',
1032
- getUTCSeconds : 'function number',
1033
- getYear : 'function number',
1034
- hasOwnProperty : 'function boolean',
1035
- indexOf : 'function number',
1036
- isExtensible : 'function boolean',
1037
- isFrozen : 'function boolean',
1038
- isPrototypeOf : 'function boolean',
1039
- isSealed : 'function boolean',
1040
- join : 'function string',
1041
- keys : 'function array',
1042
- lastIndexOf : 'function number',
1043
- lastIndex : 'number',
1044
- length : 'number',
1045
- map : 'function array',
1046
- now : 'function number',
1047
- parse : 'function',
1048
- pop : 'function',
1049
- preventExtensions : 'function object',
1050
- propertyIsEnumerable: 'function boolean',
1051
- prototype : 'object',
1052
- push : 'function number',
1053
- reduce : 'function',
1054
- reduceRight : 'function',
1055
- reverse : 'function',
1056
- seal : 'function object',
1057
- setDate : 'function',
1058
- setDay : 'function',
1059
- setFullYear : 'function',
1060
- setHours : 'function',
1061
- setMilliseconds : 'function',
1062
- setMinutes : 'function',
1063
- setMonth : 'function',
1064
- setSeconds : 'function',
1065
- setTime : 'function',
1066
- setTimezoneOffset : 'function',
1067
- setUTCDate : 'function',
1068
- setUTCDay : 'function',
1069
- setUTCFullYear : 'function',
1070
- setUTCHours : 'function',
1071
- setUTCMilliseconds : 'function',
1072
- setUTCMinutes : 'function',
1073
- setUTCMonth : 'function',
1074
- setUTCSeconds : 'function',
1075
- setYear : 'function',
1076
- shift : 'function',
1077
- slice : 'function',
1078
- some : 'function boolean',
1079
- sort : 'function',
1080
- splice : 'function',
1081
- stringify : 'function string',
1082
- substr : 'function string',
1083
- substring : 'function string',
1084
- test : 'function boolean',
1085
- toDateString : 'function string',
1086
- toExponential : 'function string',
1087
- toFixed : 'function string',
1088
- toJSON : 'function',
1089
- toISOString : 'function string',
1090
- toLocaleDateString : 'function string',
1091
- toLocaleLowerCase : 'function string',
1092
- toLocaleUpperCase : 'function string',
1093
- toLocaleString : 'function string',
1094
- toLocaleTimeString : 'function string',
1095
- toLowerCase : 'function string',
1096
- toPrecision : 'function string',
1097
- toTimeString : 'function string',
1098
- toUpperCase : 'function string',
1099
- toUTCString : 'function string',
1100
- trim : 'function string',
1101
- unshift : 'function number',
1102
- valueOf : 'function'
1103
- },
1104
-
1105
894
  strict_mode,
1106
895
  syntax = {},
1107
896
  tab,
1108
897
  token,
1109
- // type_state_change,
1110
898
  urls,
1111
899
  var_mode,
1112
900
  warnings,
1113
901
 
1114
- // widget contains the global names which are provided to a Yahoo
1115
- // (fna Konfabulator) widget.
1116
-
1117
- widget = array_to_object([
1118
- 'alert', 'animator', 'appleScript', 'beep', 'bytesToUIString',
1119
- 'Canvas', 'chooseColor', 'chooseFile', 'chooseFolder',
1120
- 'closeWidget', 'COM', 'convertPathToHFS', 'convertPathToPlatform',
1121
- 'CustomAnimation', 'escape', 'FadeAnimation', 'filesystem', 'Flash',
1122
- 'focusWidget', 'form', 'FormField', 'Frame', 'HotKey', 'Image',
1123
- 'include', 'isApplicationRunning', 'iTunes', 'konfabulatorVersion',
1124
- 'log', 'md5', 'MenuItem', 'MoveAnimation', 'openURL', 'play',
1125
- 'Point', 'popupMenu', 'preferenceGroups', 'preferences', 'print',
1126
- 'prompt', 'random', 'Rectangle', 'reloadWidget', 'ResizeAnimation',
1127
- 'resolvePath', 'resumeUpdates', 'RotateAnimation', 'runCommand',
1128
- 'runCommandInBg', 'saveAs', 'savePreferences', 'screen',
1129
- 'ScrollBar', 'showWidgetPreferences', 'sleep', 'speak', 'Style',
1130
- 'suppressUpdates', 'system', 'tellWidget', 'Text', 'TextArea',
1131
- 'Timer', 'unescape', 'updateNow', 'URL', 'Web', 'widget', 'Window',
1132
- 'XMLDOM', 'XMLHttpRequest', 'yahooCheckLogin', 'yahooLogin',
1133
- 'yahooLogout'
1134
- ], true),
1135
-
1136
902
  windows = array_to_object([
1137
903
  'ActiveXObject', 'CScript', 'Debug', 'Enumerator', 'System',
1138
904
  'VBArray', 'WScript', 'WSH'
@@ -1155,9 +921,8 @@ var JSLINT = (function () {
1155
921
 
1156
922
  // unsafe comment or string
1157
923
  ax = /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i,
1158
- // carriage return, or carriage return linefeed
1159
- crx = /\r/g,
1160
- crlfx = /\r\n/g,
924
+ // carriage return, carriage return linefeed, or linefeed
925
+ crlfx = /\r\n?|\n/,
1161
926
  // unsafe characters that are silently deleted by one or more browsers
1162
927
  cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
1163
928
  // query characters for ids
@@ -1175,10 +940,15 @@ var JSLINT = (function () {
1175
940
  // outer html token
1176
941
  ox = /[>&]|<[\/!]?|--/,
1177
942
  // attributes characters
1178
- qx = /[^a-zA-Z0-9+\-_\/ ]/,
943
+ qx = /[^a-zA-Z0-9+\-_\/. ]/,
1179
944
  // style
1180
- sx = /^\s*([{}:#%.=,>+\[\]@()"';]|[*$\^~]=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
1181
945
  ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
946
+ sx = /^\s*([{}:#%.=,>+\[\]@()"';]|[*$\^~]=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
947
+
948
+ // sync
949
+ syx = /Sync$/,
950
+ // comment todo
951
+ tox = /^\W*to\s*do(?:\W|$)/i,
1182
952
  // token
1183
953
  tx = /^\s*([(){}\[\]\?.,:;'"~#@`]|={1,3}|\/(\*(jslint|properties|property|members?|globals?)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|[\^%]=?|&[&=]?|\|[|=]?|>{1,3}=?|<(?:[\/=!]|\!(\[|--)?|<=?)?|\!={0,2}|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+(?:[xX][0-9a-fA-F]+|\.[0-9]*)?(?:[eE][+\-]?[0-9]+)?)/,
1184
954
  // url badness
@@ -1321,13 +1091,6 @@ var JSLINT = (function () {
1321
1091
  option.node = false;
1322
1092
  node_js = true;
1323
1093
  }
1324
- if (option.widget) {
1325
- add_to_predefined(widget);
1326
- option.widget = false;
1327
- }
1328
- }
1329
- if (option.type) {
1330
- option.confusion = true;
1331
1094
  }
1332
1095
  }
1333
1096
 
@@ -1355,7 +1118,7 @@ var JSLINT = (function () {
1355
1118
 
1356
1119
  function warn(message, offender, a, b, c, d) {
1357
1120
  var character, line, warning;
1358
- offender = offender || next_token; // `~
1121
+ offender = offender || next_token; // ~~
1359
1122
  line = offender.line || 0;
1360
1123
  character = offender.from || 0;
1361
1124
  warning = {
@@ -1413,9 +1176,8 @@ var JSLINT = (function () {
1413
1176
  if (it[name] !== expected) {
1414
1177
  warn('expected_a_b', it, expected, it[name]);
1415
1178
  return true;
1416
- } else {
1417
- return false;
1418
1179
  }
1180
+ return false;
1419
1181
  }
1420
1182
 
1421
1183
 
@@ -1605,9 +1367,11 @@ var JSLINT = (function () {
1605
1367
  hex(2);
1606
1368
  break;
1607
1369
  default:
1608
- c = descapes[c];
1609
- if (typeof c !== 'string') {
1610
- warn_at('unexpected_a', line, character, '\\');
1370
+ if (typeof descapes[c] !== 'string') {
1371
+ warn_at(c >= '0' && c <= '7' ? 'octal_a' : 'unexpected_a',
1372
+ line, character, '\\' + c);
1373
+ } else {
1374
+ c = descapes[c];
1611
1375
  }
1612
1376
  }
1613
1377
  }
@@ -1656,6 +1420,8 @@ var JSLINT = (function () {
1656
1420
  warn_at('unexpected_a', line, character, '<\/');
1657
1421
  } else if (option.safe && ax.test(snippet)) {
1658
1422
  warn_at('dangerous_comment', line, character);
1423
+ } else if (!option.todo && tox.test(snippet)) {
1424
+ warn_at('todo_comment', line, character);
1659
1425
  }
1660
1426
  }
1661
1427
 
@@ -1916,10 +1682,7 @@ klass: do {
1916
1682
  return {
1917
1683
  init: function (source) {
1918
1684
  if (typeof source === 'string') {
1919
- lines = source
1920
- .replace(crlfx, '\n')
1921
- .replace(crx, '\n')
1922
- .split('\n');
1685
+ lines = source.split(crlfx);
1923
1686
  } else {
1924
1687
  lines = source;
1925
1688
  }
@@ -2344,7 +2107,6 @@ klass: do {
2344
2107
  option.sloppy =
2345
2108
  option.sub =
2346
2109
  option.undef =
2347
- option.widget =
2348
2110
  option.windows = false;
2349
2111
 
2350
2112
 
@@ -2432,39 +2194,23 @@ klass: do {
2432
2194
 
2433
2195
 
2434
2196
  function do_properties() {
2435
- var name, type;
2197
+ var name;
2436
2198
  option.properties = true;
2437
- if (!funct['(old_property_type)']) {
2438
- funct['(old_property_type)'] = property_type;
2439
- property_type = Object.create(property_type);
2440
- }
2441
2199
  for (;;) {
2442
2200
  if (next_token.id !== '(string)' && !next_token.identifier) {
2443
2201
  return;
2444
2202
  }
2445
2203
  name = next_token.string;
2446
- type = '';
2447
2204
  advance();
2448
2205
  if (next_token.id === ':') {
2449
- advance(':');
2450
- if (next_token.id === 'function') {
2451
- advance('function');
2452
- if (is_type[next_token.string] === true) {
2453
- type = 'function ' + next_token.string;
2454
- advance();
2455
- } else {
2456
- type = 'function';
2457
- }
2458
- } else {
2459
- type = next_token.string;
2460
- if (is_type[type] !== true) {
2461
- warn('expected_type_a', next_token);
2462
- type = '';
2463
- }
2206
+ for (;;) {
2464
2207
  advance();
2208
+ if (next_token.id !== '(string)' && !next_token.identifier) {
2209
+ break;
2210
+ }
2465
2211
  }
2466
2212
  }
2467
- property_type[name] = type;
2213
+ property[name] = 0;
2468
2214
  if (next_token.id !== ',') {
2469
2215
  return;
2470
2216
  }
@@ -2529,18 +2275,18 @@ klass: do {
2529
2275
  open: true,
2530
2276
  was: indent
2531
2277
  };
2532
- } else if (mode === 'statement') {
2533
- indent = {
2534
- at: indent.at,
2535
- open: true,
2536
- was: indent
2537
- };
2538
2278
  } else if (!indent) {
2539
2279
  indent = {
2540
2280
  at: 1,
2541
2281
  mode: 'statement',
2542
2282
  open: true
2543
2283
  };
2284
+ } else if (mode === 'statement') {
2285
+ indent = {
2286
+ at: indent.at,
2287
+ open: true,
2288
+ was: indent
2289
+ };
2544
2290
  } else {
2545
2291
  open = mode === 'var' || next_token.line !== token.line;
2546
2292
  indent = {
@@ -2655,12 +2401,10 @@ klass: do {
2655
2401
  advance();
2656
2402
  semicolon();
2657
2403
  strict_mode = true;
2658
- option.newcap = false;
2659
2404
  option.undef = false;
2660
2405
  return true;
2661
- } else {
2662
- return false;
2663
2406
  }
2407
+ return false;
2664
2408
  }
2665
2409
 
2666
2410
 
@@ -2708,7 +2452,8 @@ klass: do {
2708
2452
  } else {
2709
2453
  if (a.id === '.' && b.id === '[' && b.arity === 'infix') {
2710
2454
  return a.second.string === b.second.string && b.second.id === '(string)';
2711
- } else if (a.id === '[' && a.arity === 'infix' && b.id === '.') {
2455
+ }
2456
+ if (a.id === '[' && a.arity === 'infix' && b.id === '.') {
2712
2457
  return a.second.string === b.second.string && a.second.id === '(string)';
2713
2458
  }
2714
2459
  }
@@ -2759,9 +2504,8 @@ klass: do {
2759
2504
  warn('leading_decimal_a', token, artifact());
2760
2505
  advance();
2761
2506
  return token;
2762
- } else {
2763
- stop('expected_identifier_a', token, token.id);
2764
2507
  }
2508
+ stop('expected_identifier_a', token, token.id);
2765
2509
  }
2766
2510
  while (rbp < next_token.lbp) {
2767
2511
  advance();
@@ -2802,7 +2546,7 @@ klass: do {
2802
2546
  x.thru = 1;
2803
2547
  x.line = 0;
2804
2548
  x.edge = 'edge';
2805
- s.string = s;
2549
+ x.string = s;
2806
2550
  return postscript(x);
2807
2551
  }
2808
2552
 
@@ -2834,7 +2578,7 @@ klass: do {
2834
2578
  }
2835
2579
 
2836
2580
 
2837
- function prefix(s, f, type) {
2581
+ function prefix(s, f) {
2838
2582
  var x = symbol(s, 150);
2839
2583
  reserve_name(x);
2840
2584
  x.nud = typeof f === 'function'
@@ -2847,15 +2591,27 @@ klass: do {
2847
2591
  }
2848
2592
  this.first = expression(150);
2849
2593
  this.arity = 'prefix';
2850
- if (this.id === '++' || this.id === '--') {
2594
+ switch (this.id) {
2595
+ case '++':
2596
+ case '--':
2851
2597
  if (!option.plusplus) {
2852
2598
  warn('unexpected_a', this);
2853
2599
  } else if ((!this.first.identifier || this.first.reserved) &&
2854
2600
  this.first.id !== '.' && this.first.id !== '[') {
2855
2601
  warn('bad_operand', this);
2856
2602
  }
2603
+ break;
2604
+ case '+':
2605
+ case '-':
2606
+ switch (this.first.id) {
2607
+ case '[':
2608
+ case '{':
2609
+ case '!':
2610
+ warn('unexpected_a', this.first);
2611
+ break;
2612
+ }
2613
+ break;
2857
2614
  }
2858
- this.type = type;
2859
2615
  return this;
2860
2616
  };
2861
2617
  return x;
@@ -2864,7 +2620,7 @@ klass: do {
2864
2620
 
2865
2621
  function type(s, t, nud) {
2866
2622
  var x = symbol(s);
2867
- x.arity = x.type = t;
2623
+ x.arity = t;
2868
2624
  if (nud) {
2869
2625
  x.nud = nud;
2870
2626
  }
@@ -2882,9 +2638,8 @@ klass: do {
2882
2638
  }
2883
2639
 
2884
2640
 
2885
- function constant(name, type) {
2641
+ function constant(name) {
2886
2642
  var x = reserve(name);
2887
- x.type = type;
2888
2643
  x.string = name;
2889
2644
  x.nud = return_this;
2890
2645
  return x;
@@ -2901,7 +2656,7 @@ klass: do {
2901
2656
  }
2902
2657
 
2903
2658
 
2904
- function infix(s, p, f, type, w) {
2659
+ function infix(s, p, f, w) {
2905
2660
  var x = symbol(s, p);
2906
2661
  reserve_name(x);
2907
2662
  x.led = function (left) {
@@ -2915,15 +2670,11 @@ klass: do {
2915
2670
  }
2916
2671
  if (typeof f === 'function') {
2917
2672
  return f(left, this);
2918
- } else {
2919
- this.first = left;
2920
- this.second = expression(p);
2921
- return this;
2922
2673
  }
2674
+ this.first = left;
2675
+ this.second = expression(p);
2676
+ return this;
2923
2677
  };
2924
- if (type) {
2925
- x.type = type;
2926
- }
2927
2678
  return x;
2928
2679
  }
2929
2680
 
@@ -2957,7 +2708,10 @@ klass: do {
2957
2708
  warn(message || bundle.weird_condition, node);
2958
2709
  break;
2959
2710
  case '(':
2960
- if (node.first.id === '.' && numbery[node.first.second.string] === true) {
2711
+ if (node.first.id === 'new' ||
2712
+ (node.first.string === 'Boolean') ||
2713
+ (node.first.id === '.' &&
2714
+ numbery[node.first.second.string] === true)) {
2961
2715
  warn(message || bundle.weird_condition, node);
2962
2716
  }
2963
2717
  break;
@@ -2984,7 +2738,7 @@ klass: do {
2984
2738
  break;
2985
2739
  default:
2986
2740
  if (node.id === 'NaN') {
2987
- warn('isnan', node);
2741
+ warn('isNaN', node);
2988
2742
  }
2989
2743
  }
2990
2744
  return node;
@@ -3002,11 +2756,20 @@ klass: do {
3002
2756
  ((left.id === '(string)' || left.id === '(number)') &&
3003
2757
  (right.id === '(string)' || right.id === '(number)'))) {
3004
2758
  warn('weird_relation', that);
2759
+ } else if (left.id === 'typeof') {
2760
+ if (right.id !== '(string)') {
2761
+ warn("expected_string_a", right, right.id === '(number)'
2762
+ ? right.number
2763
+ : right.string);
2764
+ } else if (right.string === 'undefined' ||
2765
+ right.string === 'null') {
2766
+ warn("unexpected_typeof_a", left, right.string);
2767
+ }
3005
2768
  }
3006
2769
  that.first = left;
3007
2770
  that.second = check_relation(right);
3008
2771
  return that;
3009
- }, 'boolean');
2772
+ });
3010
2773
  }
3011
2774
 
3012
2775
 
@@ -3022,6 +2785,13 @@ klass: do {
3022
2785
  } else {
3023
2786
  stop('read_only');
3024
2787
  }
2788
+ if (funct['(params)']) {
2789
+ funct['(params)'].forEach(function (value) {
2790
+ if (value.string === left.string) {
2791
+ value.assign = true;
2792
+ }
2793
+ });
2794
+ }
3025
2795
  } else if (option.safe) {
3026
2796
  l = left;
3027
2797
  do {
@@ -3053,9 +2823,6 @@ klass: do {
3053
2823
  });
3054
2824
  x.assign = true;
3055
2825
  if (op) {
3056
- if (syntax[op].type) {
3057
- x.type = syntax[op].type;
3058
- }
3059
2826
  if (syntax[op].bitwise) {
3060
2827
  x.bitwise = true;
3061
2828
  }
@@ -3134,12 +2901,10 @@ klass: do {
3134
2901
  advance(':');
3135
2902
  scope = Object.create(old_scope);
3136
2903
  add_label(label, 'label');
3137
- if (next_token.labeled !== true) {
3138
- warn('label_a_b', next_token, label.string, artifact());
2904
+ if (next_token.labeled !== true || funct === global_funct) {
2905
+ stop('unexpected_label_a', label);
3139
2906
  } else if (jx.test(label.string + ':')) {
3140
2907
  warn('url', label);
3141
- } else if (funct === global_funct) {
3142
- stop('unexpected_a', token);
3143
2908
  }
3144
2909
  next_token.label = label;
3145
2910
  }
@@ -3166,7 +2931,7 @@ klass: do {
3166
2931
 
3167
2932
  // If this is an expression statement, determine if it is acceptable.
3168
2933
  // We do not like
3169
- // new Blah();
2934
+ // new Blah;
3170
2935
  // statments. If it is to be used at all, new should only be used to make
3171
2936
  // objects, not side effects. The expression statements we do like do
3172
2937
  // assignment or invocation or delete.
@@ -3179,7 +2944,7 @@ klass: do {
3179
2944
  the_statement.id !== 'delete' &&
3180
2945
  the_statement.id !== '++' &&
3181
2946
  the_statement.id !== '--') {
3182
- warn('assignment_function_expression', token);
2947
+ warn('assignment_function_expression', the_statement);
3183
2948
  }
3184
2949
  semicolon();
3185
2950
  }
@@ -3269,13 +3034,13 @@ klass: do {
3269
3034
 
3270
3035
 
3271
3036
  function tally_property(name) {
3272
- if (option.properties && typeof property_type[name] !== 'string') {
3037
+ if (option.properties && typeof property[name] !== 'number') {
3273
3038
  warn('unexpected_property_a', token, name);
3274
3039
  }
3275
- if (typeof member[name] === 'number') {
3276
- member[name] += 1;
3040
+ if (typeof property[name] === 'number') {
3041
+ property[name] += 1;
3277
3042
  } else {
3278
- member[name] = 1;
3043
+ property[name] = 1;
3279
3044
  }
3280
3045
  }
3281
3046
 
@@ -3446,6 +3211,7 @@ klass: do {
3446
3211
  } else if (option.safe) {
3447
3212
  warn('adsafe_a', x);
3448
3213
  }
3214
+ funct['(arguments)'] = true;
3449
3215
  });
3450
3216
  reservevar('eval', function (x) {
3451
3217
  if (option.safe) {
@@ -3459,8 +3225,9 @@ klass: do {
3459
3225
  reservevar('this', function (x) {
3460
3226
  if (option.safe) {
3461
3227
  warn('adsafe_a', x);
3462
- } else if (strict_mode && funct['(token)'].arity === 'statement' &&
3463
- funct['(name)'].charAt(0) > 'Z') {
3228
+ } else if (strict_mode && funct['(token)'] &&
3229
+ (funct['(token)'].arity === 'statement' &&
3230
+ funct['(name)'].charAt(0) > 'Z')) {
3464
3231
  warn('strict', x);
3465
3232
  }
3466
3233
  });
@@ -3521,7 +3288,6 @@ klass: do {
3521
3288
  } else if (this.first.number !== 0) {
3522
3289
  warn('expected_a_b', this.first, '0', artifact(this.first));
3523
3290
  }
3524
- this.type = 'undefined';
3525
3291
  return this;
3526
3292
  });
3527
3293
 
@@ -3547,8 +3313,8 @@ klass: do {
3547
3313
  that.left = left;
3548
3314
  that.right = expression(130);
3549
3315
  return that;
3550
- }, 'boolean');
3551
- infix('instanceof', 120, null, 'boolean');
3316
+ });
3317
+ infix('instanceof', 120);
3552
3318
  infix('+', 130, function (left, that) {
3553
3319
  if (left.id === '(number)') {
3554
3320
  if (left.number === 0) {
@@ -3606,7 +3372,7 @@ klass: do {
3606
3372
  }
3607
3373
  var right = expression(130);
3608
3374
  if ((right.id === '(number)' && right.number === 0) || right.id === '(string)') {
3609
- warn('unexpected_a', left);
3375
+ warn('unexpected_a', right);
3610
3376
  }
3611
3377
  if (left.id === right.id && left.id === '(number)') {
3612
3378
  left.number -= right.number;
@@ -3616,7 +3382,7 @@ klass: do {
3616
3382
  that.first = left;
3617
3383
  that.second = right;
3618
3384
  return that;
3619
- }, 'number');
3385
+ });
3620
3386
  prefix('-');
3621
3387
  prefix('---', function () {
3622
3388
  warn('confusing_a', token);
@@ -3646,7 +3412,7 @@ klass: do {
3646
3412
  that.first = left;
3647
3413
  that.second = right;
3648
3414
  return that;
3649
- }, 'number');
3415
+ });
3650
3416
  infix('/', 140, function (left, that) {
3651
3417
  if ((left.id === '(number)' && left.number === 0) || left.id === '(string)') {
3652
3418
  warn('unexpected_a', left);
@@ -3663,7 +3429,7 @@ klass: do {
3663
3429
  that.first = left;
3664
3430
  that.second = right;
3665
3431
  return that;
3666
- }, 'number');
3432
+ });
3667
3433
  infix('%', 140, function (left, that) {
3668
3434
  if ((left.id === '(number)' && (left.number === 0 || left.number === 1)) || left.id === '(string)') {
3669
3435
  warn('unexpected_a', left);
@@ -3680,7 +3446,7 @@ klass: do {
3680
3446
  that.first = left;
3681
3447
  that.second = right;
3682
3448
  return that;
3683
- }, 'number');
3449
+ });
3684
3450
 
3685
3451
  suffix('++');
3686
3452
  prefix('++');
@@ -3705,7 +3471,7 @@ klass: do {
3705
3471
  }
3706
3472
  expression(150);
3707
3473
  return this;
3708
- }, 'number');
3474
+ });
3709
3475
  prefix('!', function () {
3710
3476
  no_space_only();
3711
3477
  this.first = expected_condition(expression(150));
@@ -3714,8 +3480,8 @@ klass: do {
3714
3480
  warn('confusing_a', this);
3715
3481
  }
3716
3482
  return this;
3717
- }, 'boolean');
3718
- prefix('typeof', null, 'string');
3483
+ });
3484
+ prefix('typeof', null);
3719
3485
  prefix('new', function () {
3720
3486
  one_space();
3721
3487
  var c = expression(160), n, p, v;
@@ -3734,7 +3500,7 @@ klass: do {
3734
3500
  if (next_token.id !== ')') {
3735
3501
  n = expression(0);
3736
3502
  p.second = [n];
3737
- if (n.type !== 'number' || next_token.id === ',') {
3503
+ if (n.id !== '(number)' || next_token.id === ',') {
3738
3504
  warn('use_array', p);
3739
3505
  }
3740
3506
  while (next_token.id === ',') {
@@ -3788,7 +3554,7 @@ klass: do {
3788
3554
  });
3789
3555
 
3790
3556
  infix('(', 160, function (left, that) {
3791
- var p;
3557
+ var e, p;
3792
3558
  if (indent && indent.mode === 'expression') {
3793
3559
  no_space(prev_token, token);
3794
3560
  } else {
@@ -3825,7 +3591,11 @@ klass: do {
3825
3591
  no_space();
3826
3592
  for (;;) {
3827
3593
  edge();
3828
- p.push(expression(10));
3594
+ e = expression(10);
3595
+ if (left.string === 'Boolean' && (e.id === '!' || e.id === '~')) {
3596
+ warn('weird_condition', e);
3597
+ }
3598
+ p.push(e);
3829
3599
  if (next_token.id !== ',') {
3830
3600
  break;
3831
3601
  }
@@ -3857,7 +3627,7 @@ klass: do {
3857
3627
  that.first = left;
3858
3628
  that.second = p;
3859
3629
  return that;
3860
- }, '', true);
3630
+ }, true);
3861
3631
 
3862
3632
  prefix('(', function () {
3863
3633
  step_in('expression');
@@ -3871,9 +3641,15 @@ klass: do {
3871
3641
  no_space();
3872
3642
  step_out(')', this);
3873
3643
  if (value.id === 'function') {
3874
- if (next_token.id === '(') {
3644
+ switch (next_token.id) {
3645
+ case '(':
3875
3646
  warn('move_invocation');
3876
- } else {
3647
+ break;
3648
+ case '.':
3649
+ case '[':
3650
+ warn('unexpected_a');
3651
+ break;
3652
+ default:
3877
3653
  warn('bad_wrap', this);
3878
3654
  }
3879
3655
  }
@@ -3883,7 +3659,7 @@ klass: do {
3883
3659
  infix('.', 170, function (left, that) {
3884
3660
  no_space(prev_token, token);
3885
3661
  no_space();
3886
- var name = identifier(), type;
3662
+ var name = identifier();
3887
3663
  if (typeof name === 'string') {
3888
3664
  tally_property(name);
3889
3665
  }
@@ -3895,6 +3671,8 @@ klass: do {
3895
3671
  } else if (!option.evil && left && left.string === 'document' &&
3896
3672
  (name === 'write' || name === 'writeln')) {
3897
3673
  warn('write_is_wrong', left);
3674
+ } else if (!option.stupid && syx.test(name)) {
3675
+ warn('sync_a', token);
3898
3676
  } else if (option.adsafe) {
3899
3677
  if (!adsafe_top && left.string === 'ADSAFE') {
3900
3678
  if (name === 'id' || name === 'lib') {
@@ -3939,12 +3717,8 @@ klass: do {
3939
3717
  }
3940
3718
  }
3941
3719
  }
3942
- type = property_type[name];
3943
- if (type && typeof type === 'string' && type !== '*') {
3944
- that.type = type;
3945
- }
3946
3720
  return that;
3947
- }, '', true);
3721
+ }, true);
3948
3722
 
3949
3723
  infix('[', 170, function (left, that) {
3950
3724
  var e, s;
@@ -3953,39 +3727,33 @@ klass: do {
3953
3727
  step_in();
3954
3728
  edge();
3955
3729
  e = expression(0);
3956
- switch (e.type) {
3957
- case 'number':
3730
+ switch (e.id) {
3731
+ case '(number)':
3958
3732
  if (e.id === '(number)' && left.id === 'arguments') {
3959
3733
  warn('use_param', left);
3960
3734
  }
3961
3735
  break;
3962
- case 'string':
3963
- if (e.id === '(string)') {
3964
- if (option.safe && (banned[e.string] ||
3965
- e.string.charAt(0) === '_' || e.string.slice(-1) === '_')) {
3966
- warn('adsafe_subscript_a', e);
3967
- } else if (!option.evil &&
3968
- (e.string === 'eval' || e.string === 'execScript')) {
3969
- warn('evil', e);
3970
- } else if (!option.sub && ix.test(e.string)) {
3971
- s = syntax[e.string];
3972
- if (!s || !s.reserved) {
3973
- warn('subscript', e);
3974
- }
3975
- }
3976
- tally_property(e.string);
3977
- } else if (option.safe && e.id !== 'typeof') {
3978
- warn('adsafe_subscript_a', e);
3979
- }
3980
- break;
3981
- case undefined:
3982
- if (option.safe) {
3736
+ case '(string)':
3737
+ if (option.safe && (banned[e.string] ||
3738
+ e.string.charAt(0) === '_' || e.string.slice(-1) === '_')) {
3983
3739
  warn('adsafe_subscript_a', e);
3740
+ } else if (!option.evil &&
3741
+ (e.string === 'eval' || e.string === 'execScript')) {
3742
+ warn('evil', e);
3743
+ } else if (!option.sub && ix.test(e.string)) {
3744
+ s = syntax[e.string];
3745
+ if (!s || !s.reserved) {
3746
+ warn('subscript', e);
3747
+ }
3984
3748
  }
3749
+ tally_property(e.string);
3985
3750
  break;
3986
3751
  default:
3987
3752
  if (option.safe) {
3988
- warn('adsafe_subscript_a', e);
3753
+ if ((e.id !== '+' || e.arity !== 'prefix') &&
3754
+ e.id !== '-' && e.id !== '*') {
3755
+ warn('adsafe_subscript_a', e);
3756
+ }
3989
3757
  }
3990
3758
  }
3991
3759
  step_out(']', that);
@@ -3993,7 +3761,7 @@ klass: do {
3993
3761
  that.first = left;
3994
3762
  that.second = e;
3995
3763
  return that;
3996
- }, '', true);
3764
+ }, true);
3997
3765
 
3998
3766
  prefix('[', function () {
3999
3767
  this.arity = 'prefix';
@@ -4056,7 +3824,7 @@ klass: do {
4056
3824
  if (next_token.id === ')') {
4057
3825
  no_space();
4058
3826
  step_out(')', paren);
4059
- return;
3827
+ return params;
4060
3828
  }
4061
3829
  for (;;) {
4062
3830
  edge();
@@ -4099,12 +3867,12 @@ klass: do {
4099
3867
  func.first = funct['(params)'] = function_params();
4100
3868
  one_space();
4101
3869
  func.block = block(false);
4102
- if (funct['(old_property_type)']) {
4103
- property_type = funct['(old_property_type)'];
4104
- delete funct['(old_property_type)'];
4105
- }
4106
- if (option.confusion) {
4107
- funct['(confusion)'] = true;
3870
+ if (funct['(arguments)']) {
3871
+ func.first.forEach(function (value) {
3872
+ if (value.assign) {
3873
+ warn('parameter_arguments_a', value, value.string);
3874
+ }
3875
+ });
4108
3876
  }
4109
3877
  funct = old_funct;
4110
3878
  option = old_option;
@@ -4158,7 +3926,7 @@ klass: do {
4158
3926
  warn('function_loop', get);
4159
3927
  }
4160
3928
  p = get.first;
4161
- if (p) {
3929
+ if (p && p.length) {
4162
3930
  warn('parameter_a_get_b', p[0], p[0].string, i);
4163
3931
  }
4164
3932
  comma();
@@ -4327,6 +4095,23 @@ klass: do {
4327
4095
  if (funct['(loopage)']) {
4328
4096
  warn('function_loop');
4329
4097
  }
4098
+ switch (next_token.id) {
4099
+ case ';':
4100
+ case '(':
4101
+ case ')':
4102
+ case ',':
4103
+ case ']':
4104
+ case '}':
4105
+ case ':':
4106
+ break;
4107
+ case '.':
4108
+ if (peek().string !== 'bind' || peek(1).id !== '(') {
4109
+ warn('unexpected_a');
4110
+ }
4111
+ break;
4112
+ default:
4113
+ stop('unexpected_a');
4114
+ }
4330
4115
  this.arity = 'function';
4331
4116
  return this;
4332
4117
  });
@@ -4746,7 +4531,7 @@ klass: do {
4746
4531
  });
4747
4532
 
4748
4533
  disrupt_stmt('return', function () {
4749
- if (funct === global_funct) {
4534
+ if (funct === global_funct && xmode !== 'scriptstring') {
4750
4535
  warn('unexpected_a', this);
4751
4536
  }
4752
4537
  this.arity = 'statement';
@@ -4757,6 +4542,9 @@ klass: do {
4757
4542
  }
4758
4543
  this.first = expression(20);
4759
4544
  }
4545
+ if (peek(0).id === '}' && peek(1).id === 'else') {
4546
+ warn('unexpected_else', this);
4547
+ }
4760
4548
  return this;
4761
4549
  });
4762
4550
 
@@ -4791,215 +4579,6 @@ klass: do {
4791
4579
  reserve('yield');
4792
4580
 
4793
4581
 
4794
- // Type inference
4795
-
4796
- // function get_type(one) {
4797
- // var type;
4798
- // if (typeof one === 'string') {
4799
- // return one;
4800
- // } else if (one.type) {
4801
- // return one.type;
4802
- // } else if (one.id === '.') {
4803
- // type = property_type[one.second.string];
4804
- // return typeof type === 'string' ? type : '';
4805
- // } else {
4806
- // return ((one.identifier && scope[one.string]) || one).type;
4807
- // }
4808
- // }
4809
-
4810
-
4811
- // function match_type(one_type, two_type, one, two) {
4812
- // if (one_type === two_type) {
4813
- // return true;
4814
- // } else {
4815
- // if (!funct.confusion && !two.warn) {
4816
- // if (typeof one !== 'string') {
4817
- // if (one.id === '.') {
4818
- // one_type = '.' + one.second.string + ': ' + one_type;
4819
- // } else {
4820
- // one_type = one.string + ': ' + one_type;
4821
- // }
4822
- // }
4823
- // if (two.id === '.') {
4824
- // two_type = '.' + two.second.string + ': ' + one_type;
4825
- // } else {
4826
- // two_type = two.string + ': ' + one_type;
4827
- // }
4828
- // warn('type_confusion_a_b', two, one_type, two_type);
4829
- // two.warn = true;
4830
- // }
4831
- // return false;
4832
- // }
4833
- // }
4834
-
4835
-
4836
- // function conform(one, two) {
4837
- //
4838
- // // The conform function takes a type string and a token, or two tokens.
4839
- //
4840
- // var one_type = typeof one === 'string' ? one : one.type,
4841
- // two_type = two.type,
4842
- // two_thing;
4843
- //
4844
- // // If both tokens already have a type, and if they match, then we are done.
4845
- // // Once a token has a type, it is locked. Neither token will change, but if
4846
- // // they do not match, there will be a warning.
4847
- //
4848
- // if (one_type) {
4849
- // if (two_type) {
4850
- // match_type(one_type, two_type, one, two);
4851
- // } else {
4852
- //
4853
- // // two does not have a type, so look deeper. If two is a variable or property,
4854
- // // then use its type if it has one, and make the deep type one's type if it
4855
- // // doesn't. If the type was *, or if there was a mismatch, don't change the
4856
- // // deep type.
4857
- //
4858
- // two_thing = two.id === '(identifier)'
4859
- // ? scope[two.string]
4860
- // : two.id === '.'
4861
- // ? property_type[two.second.string]
4862
- // : null;
4863
- // if (two_thing) {
4864
- // two_type = two_thing.type;
4865
- // if (two_type) {
4866
- // if (two_type !== '*') {
4867
- // if (!match_type(one_type, two_type, one, two)) {
4868
- // return '';
4869
- // }
4870
- // }
4871
- // } else {
4872
- // two_thing.type = one_type;
4873
- // }
4874
- // }
4875
- //
4876
- // // In any case, we give two a type.
4877
- //
4878
- // two.type = one_type;
4879
- // type_state_change = true;
4880
- // return one_type;
4881
- // }
4882
- //
4883
- // // one does not have a type, but two does, so do the old switcheroo.
4884
- //
4885
- // } else {
4886
- // if (two_type) {
4887
- // return conform(two, one);
4888
- //
4889
- // // Neither token has a type yet. So we have to look deeper to see if either
4890
- // // is a variable or property.
4891
- //
4892
- // } else {
4893
- // if (one.id === '(identifier)') {
4894
- // one_type = scope[one.string].type;
4895
- // if (one_type && one_type !== '*') {
4896
- // one.type = one_type;
4897
- // return conform(one, two);
4898
- // }
4899
- // } else if (one.id === '.') {
4900
- // one_type = property_type[one.second.string];
4901
- // if (one_type && one_type !== '*') {
4902
- // one.type = scope[one.string].type;
4903
- // return conform(one, two);
4904
- // }
4905
- // }
4906
- // if (two.id === '(identifier)') {
4907
- // two_type = scope[two.string].type;
4908
- // if (two_type && two_type !== '*') {
4909
- // two.type = two_type;
4910
- // return conform(two, one);
4911
- // }
4912
- // } else if (two.id === '.') {
4913
- // two_type = property_type[two.second.string];
4914
- // if (two_type && two_type !== '*') {
4915
- // two.type = scope[two.string].type;
4916
- // return conform(two, one);
4917
- // }
4918
- // }
4919
- // }
4920
- // }
4921
- //
4922
- // // Return a falsy string if we were unable to determine the type of either token.
4923
- //
4924
- // return '';
4925
- // }
4926
-
4927
- // function conform_array(type, array) {
4928
- // array.forEach(function (item) {
4929
- // return conform(type, item);
4930
- // }, type);
4931
- // }
4932
-
4933
-
4934
- // function infer(node) {
4935
- // if (Array.isArray(node)) {
4936
- // node.forEach(infer);
4937
- // } else {
4938
- // switch (node.arity) {
4939
- // case 'statement':
4940
- // infer_statement[node.id](node);
4941
- // break;
4942
- // case 'infix':
4943
- // infer(node.first);
4944
- // infer(node.second);
4945
- // switch (node.id) {
4946
- // case '(':
4947
- // conform('function', node.first);
4948
- // break;
4949
- // default:
4950
- // stop('unfinished');
4951
- // }
4952
- // break;
4953
- // case 'number':
4954
- // case 'string':
4955
- // case 'boolean':
4956
- // break;
4957
- // default:
4958
- // stop('unfinished');
4959
- // }
4960
- // }
4961
- // }
4962
-
4963
-
4964
- // infer_statement = {
4965
- // 'var': function (node) {
4966
- // var i, item, list = node.first;
4967
- // for (i = 0; i < list.length; i += 1) {
4968
- // item = list[i];
4969
- // if (item.id === '=') {
4970
- // infer(item.second);
4971
- // conform(item.first, item.second);
4972
- // conform(item.first, item);
4973
- // }
4974
- // }
4975
- // },
4976
- // 'for': function (node) {
4977
- // infer(node.first);
4978
- // infer(node.second);
4979
- // if (node.forin) {
4980
- // conform('string', node.first);
4981
- // conform('object', node.second);
4982
- // } else {
4983
- // infer(node.third);
4984
- // conform_array('number', node.first);
4985
- // conform('boolean', node.second);
4986
- // conform_array('number', node.third);
4987
- // }
4988
- // infer(node.block);
4989
- // }
4990
- // };
4991
-
4992
-
4993
- // function infer_types(node) {
4994
- // do {
4995
- // funct = global_funct;
4996
- // scope = global_scope;
4997
- // type_state_change = false;
4998
- // infer(node);
4999
- // } while (type_state_change);
5000
- // }
5001
-
5002
-
5003
4582
  // Parse JSON
5004
4583
 
5005
4584
  function json_value() {
@@ -5160,7 +4739,8 @@ klass: do {
5160
4739
  }
5161
4740
  advance(')', paren);
5162
4741
  return true;
5163
- } else if (css_colorData[next_token.string] === true) {
4742
+ }
4743
+ if (css_colorData[next_token.string] === true) {
5164
4744
  advance();
5165
4745
  return true;
5166
4746
  }
@@ -5312,6 +4892,26 @@ klass: do {
5312
4892
  }
5313
4893
 
5314
4894
 
4895
+ function css_shadow() {
4896
+ for (;;) {
4897
+ if (next_token.string === 'inset') {
4898
+ advance();
4899
+ }
4900
+ for (;;) {
4901
+ if (!css_length()) {
4902
+ break;
4903
+ }
4904
+ }
4905
+ css_color();
4906
+ if (next_token.id !== ',') {
4907
+ break;
4908
+ }
4909
+ advance(',');
4910
+ }
4911
+ return true;
4912
+ }
4913
+
4914
+
5315
4915
  function css_shape() {
5316
4916
  var i;
5317
4917
  if (next_token.identifier && next_token.string === 'rect') {
@@ -5518,6 +5118,7 @@ klass: do {
5518
5118
  'border-top-width': css_width,
5519
5119
  'border-width': [4, css_width],
5520
5120
  bottom: [css_length, 'auto'],
5121
+ 'box-shadow': ['none', css_shadow],
5521
5122
  'caption-side' : ['bottom', 'left', 'right', 'top'],
5522
5123
  clear: ['both', 'left', 'none', 'right'],
5523
5124
  clip: [css_shape, 'auto'],
@@ -5661,30 +5262,26 @@ klass: do {
5661
5262
  }
5662
5263
  advance();
5663
5264
  return css_any;
5265
+ }
5266
+ if (!next_token.identifier) {
5267
+ warn('expected_style_attribute');
5664
5268
  } else {
5665
- if (!next_token.identifier) {
5666
- warn('expected_style_attribute');
5269
+ if (Object.prototype.hasOwnProperty.call(css_attribute_data,
5270
+ next_token.string)) {
5271
+ v = css_attribute_data[next_token.string];
5667
5272
  } else {
5668
- if (Object.prototype.hasOwnProperty.call(css_attribute_data,
5669
- next_token.string)) {
5670
- v = css_attribute_data[next_token.string];
5671
- } else {
5672
- v = css_any;
5673
- if (!option.css) {
5674
- warn('unrecognized_style_attribute_a');
5675
- }
5273
+ v = css_any;
5274
+ if (!option.css) {
5275
+ warn('unrecognized_style_attribute_a');
5676
5276
  }
5677
5277
  }
5678
- advance();
5679
- return v;
5680
5278
  }
5279
+ advance();
5280
+ return v;
5681
5281
  }
5682
5282
 
5683
5283
 
5684
5284
  function style_value(v) {
5685
-
5686
- /*jslint confusion: true */
5687
-
5688
5285
  var i = 0,
5689
5286
  n,
5690
5287
  once,
@@ -5764,12 +5361,11 @@ klass: do {
5764
5361
  }
5765
5362
  }
5766
5363
  return;
5767
- } else {
5768
- if (next_token.identifier &&
5769
- (next_token.string === 'odd' || next_token.string === 'even')) {
5770
- advance();
5771
- return;
5772
- }
5364
+ }
5365
+ if (next_token.identifier &&
5366
+ (next_token.string === 'odd' || next_token.string === 'even')) {
5367
+ advance();
5368
+ return;
5773
5369
  }
5774
5370
  warn('unexpected_a');
5775
5371
  }
@@ -6133,9 +5729,6 @@ klass: do {
6133
5729
  if (option.adsafe && (!adsafe_may || !approved[attribute.src])) {
6134
5730
  warn('adsafe_source', token);
6135
5731
  }
6136
- if (attribute.type) {
6137
- warn('type', token);
6138
- }
6139
5732
  } else {
6140
5733
  step_in(next_token.from);
6141
5734
  edge();
@@ -6243,9 +5836,6 @@ klass: do {
6243
5836
  }
6244
5837
 
6245
5838
  function html() {
6246
-
6247
- /*jslint confusion: true */
6248
-
6249
5839
  var attribute, attributes, is_empty, name, old_white = option.white,
6250
5840
  quote, tag_name, tag, wmode;
6251
5841
  xmode = 'html';
@@ -6351,7 +5941,7 @@ klass: do {
6351
5941
  next_token.id !== '"' &&
6352
5942
  next_token.id !== '\'' &&
6353
5943
  next_token.id !== '(string)' &&
6354
- next_token.id !== '(string)' &&
5944
+ next_token.id !== '(number)' &&
6355
5945
  next_token.id !== '(color)') {
6356
5946
  warn('expected_attribute_value_a', token, attribute);
6357
5947
  }
@@ -6422,6 +6012,9 @@ klass: do {
6422
6012
  advance('>');
6423
6013
  break;
6424
6014
  case '(end)':
6015
+ if (stack.length !== 0) {
6016
+ warn('missing_a', next_token, '</' + stack.pop().string + '>');
6017
+ }
6425
6018
  return;
6426
6019
  default:
6427
6020
  if (next_token.id === '(end)') {
@@ -6449,11 +6042,12 @@ klass: do {
6449
6042
  var i, predef, tree;
6450
6043
  JSLINT.errors = [];
6451
6044
  JSLINT.tree = '';
6045
+ JSLINT.properties = '';
6452
6046
  begin = prev_token = token = next_token =
6453
6047
  Object.create(syntax['(begin)']);
6454
6048
  predefined = {};
6455
6049
  add_to_predefined(standard);
6456
- property_type = Object.create(standard_property_type);
6050
+ property = {};
6457
6051
  if (the_option) {
6458
6052
  option = Object.create(the_option);
6459
6053
  predef = option.predef;
@@ -6500,7 +6094,6 @@ klass: do {
6500
6094
  indent = null;
6501
6095
  json_mode = false;
6502
6096
  lookahead = [];
6503
- member = {};
6504
6097
  node_js = false;
6505
6098
  prereg = true;
6506
6099
  src = false;
@@ -6569,8 +6162,7 @@ klass: do {
6569
6162
  adsafe_top = true;
6570
6163
  tree = statements();
6571
6164
  begin.first = tree;
6572
- JSLINT.tree = begin;
6573
- // infer_types(tree);
6165
+ itself.tree = begin;
6574
6166
  if (option.adsafe && (tree.length !== 1 ||
6575
6167
  aint(tree[0], 'id', '(') ||
6576
6168
  aint(tree[0].first, 'id', '.') ||
@@ -6588,8 +6180,9 @@ klass: do {
6588
6180
  }
6589
6181
  indent = null;
6590
6182
  advance('(end)');
6183
+ itself.property = property;
6591
6184
  } catch (e) {
6592
- if (e) { // `~
6185
+ if (e) { // ~~
6593
6186
  JSLINT.errors.push({
6594
6187
  reason : e.message,
6595
6188
  line : e.line || next_token.line,
@@ -6610,7 +6203,6 @@ klass: do {
6610
6203
  i,
6611
6204
  j,
6612
6205
  kind,
6613
- members = [],
6614
6206
  name,
6615
6207
  the_function,
6616
6208
  undef = [],
@@ -6683,105 +6275,106 @@ klass: do {
6683
6275
  if (undef.length > 0) {
6684
6276
  data['undefined'] = undef;
6685
6277
  }
6686
-
6687
- members = [];
6688
- for (name in member) {
6689
- if (typeof member[name] === 'number') {
6690
- data.member = member;
6691
- break;
6692
- }
6693
- }
6694
-
6695
6278
  return data;
6696
6279
  };
6697
6280
 
6698
-
6699
- itself.report = function (errors_only) {
6700
- var data = itself.data(), err, evidence, i, italics, j, key, keys, length,
6701
- mem = '', name, names, output = [], snippets, the_function, type,
6702
- warning;
6703
-
6704
- function detail(h, value) {
6705
- var comma_needed, singularity;
6706
- if (Array.isArray(value)) {
6707
- output.push('<div><i>' + h + '</i> ');
6708
- value.sort().forEach(function (item) {
6709
- if (item !== singularity) {
6710
- singularity = item;
6711
- output.push((comma_needed ? ', ' : '') + singularity);
6712
- comma_needed = true;
6281
+ itself.error_report = function (data) {
6282
+ var evidence, i, output = [], snippets, warning;
6283
+ if (data.errors) {
6284
+ for (i = 0; i < data.errors.length; i += 1) {
6285
+ warning = data.errors[i];
6286
+ if (warning) {
6287
+ evidence = warning.evidence || '';
6288
+ output.push('<cite>');
6289
+ if (isFinite(warning.line)) {
6290
+ output.push('<address>line ' +
6291
+ String(warning.line) +
6292
+ ' character ' + String(warning.character) +
6293
+ '</address>');
6713
6294
  }
6714
- });
6715
- output.push('</div>');
6716
- } else if (value) {
6717
- output.push('<div><i>' + h + '</i> ' + value + '</div>');
6718
- }
6719
- }
6720
-
6721
- if (data.errors || data.unused || data['undefined']) {
6722
- err = true;
6723
- output.push('<div id=errors><i>Error:</i>');
6724
- if (data.errors) {
6725
- for (i = 0; i < data.errors.length; i += 1) {
6726
- warning = data.errors[i];
6727
- if (warning) {
6728
- evidence = warning.evidence || '';
6729
- output.push('<p>Problem' + (isFinite(warning.line)
6730
- ? ' at line ' + String(warning.line) +
6731
- ' character ' + String(warning.character)
6732
- : '') +
6733
- ': ' + warning.reason.entityify() +
6734
- '</p><p class=evidence>' +
6735
- (evidence && (evidence.length > 80
6736
- ? evidence.slice(0, 77) + '...'
6737
- : evidence).entityify()) + '</p>');
6295
+ output.push(warning.reason.entityify() + '</cite>');
6296
+ if (evidence) {
6297
+ output.push('<pre>' + evidence.entityify() + '</pre>');
6738
6298
  }
6739
6299
  }
6740
6300
  }
6741
-
6301
+ }
6302
+ if (data.unused || data['undefined']) {
6303
+ output.push('<dl>');
6742
6304
  if (data['undefined']) {
6305
+ output.push('<dt>undefined</dt><dd>');
6743
6306
  snippets = [];
6744
6307
  for (i = 0; i < data['undefined'].length; i += 1) {
6745
- snippets[i] = '<code><u>' + data['undefined'][i].name + '</u></code>&nbsp;<i>' +
6746
- String(data['undefined'][i].line) + ' </i> <small>' +
6747
- data['undefined'][i]['function'] + '</small>';
6308
+ snippets[i] = '<code>' + data['undefined'][i].name +
6309
+ '</code>&nbsp;<address>' +
6310
+ data['undefined'][i]['function'] + ' ' +
6311
+ String(data['undefined'][i].line) + '</address>';
6748
6312
  }
6749
- output.push('<p><i>Undefined variable:</i> ' + snippets.join(', ') + '</p>');
6313
+ output.push(snippets.join(', '));
6314
+ output.push('</dd>');
6750
6315
  }
6751
6316
  if (data.unused) {
6317
+ output.push('<dt>unused</dt><dd>');
6752
6318
  snippets = [];
6753
6319
  for (i = 0; i < data.unused.length; i += 1) {
6754
- snippets[i] = '<code><u>' + data.unused[i].name + '</u></code>&nbsp;<i>' +
6755
- String(data.unused[i].line) + ' </i> <small>' +
6756
- data.unused[i]['function'] + '</small>';
6320
+ snippets[i] = '<code>' + data.unused[i].name + '</code>&nbsp;<address>' +
6321
+ data.unused[i]['function'] + ' ' +
6322
+ String(data.unused[i].line) + '</address>';
6757
6323
  }
6758
- output.push('<p><i>Unused variable:</i> ' + snippets.join(', ') + '</p>');
6324
+ output.push(snippets.join(', '));
6325
+ output.push('</dd>');
6759
6326
  }
6760
- if (data.json) {
6761
- output.push('<p>JSON: bad.</p>');
6762
- }
6763
- output.push('</div>');
6327
+ output.push('</dl>');
6328
+ }
6329
+ if (data.json) {
6330
+ output.push('<p>JSON: bad.</p>');
6764
6331
  }
6332
+ return output.join('');
6333
+ };
6765
6334
 
6766
- if (!errors_only) {
6767
6335
 
6768
- output.push('<br><div id=functions>');
6336
+ itself.report = function (data) {
6337
+ var dl, err, i, j, names, output = [], the_function;
6769
6338
 
6770
- if (data.urls) {
6771
- detail("URLs<br>", data.urls, '<br>');
6339
+ function detail(h, value) {
6340
+ var comma_needed, singularity;
6341
+ if (Array.isArray(value)) {
6342
+ output.push('<dt>' + h + '</dt><dd>');
6343
+ value.sort().forEach(function (item) {
6344
+ if (item !== singularity) {
6345
+ singularity = item;
6346
+ output.push((comma_needed ? ', ' : '') + singularity);
6347
+ comma_needed = true;
6348
+ }
6349
+ });
6350
+ output.push('</dd>');
6351
+ } else if (value) {
6352
+ output.push('<dt>' + h + '</dt><dd>', value, '</dd>');
6772
6353
  }
6354
+ }
6773
6355
 
6774
- if (xmode === 'style') {
6775
- output.push('<p>CSS.</p>');
6776
- } else if (data.json && !err) {
6777
- output.push('<p>JSON: good.</p>');
6778
- } else if (data.globals) {
6779
- output.push('<div><i>Global</i> ' +
6780
- data.globals.sort().join(', ') + '</div>');
6781
- } else {
6782
- output.push('<div><i>No new global variables introduced.</i></div>');
6783
- }
6356
+ output.push('<dl>');
6357
+ if (data.urls) {
6358
+ detail("url", data.urls);
6359
+ dl = true;
6360
+ }
6361
+ if (data.globals) {
6362
+ detail('global', data.globals);
6363
+ dl = true;
6364
+ } else if (xmode === 'style') {
6365
+ output.push('<p>CSS.</p>');
6366
+ } else if (data.json && !err) {
6367
+ output.push('<p>JSON: good.</p>');
6368
+ } else {
6369
+ output.push('<div><i>No new global variables introduced.</i></div>');
6370
+ }
6371
+ if (dl) {
6372
+ output.push('</dl>');
6373
+ } else {
6374
+ output[0] = '';
6375
+ }
6784
6376
 
6377
+ if (data.functions) {
6785
6378
  for (i = 0; i < data.functions.length; i += 1) {
6786
6379
  the_function = data.functions[i];
6787
6380
  names = [];
@@ -6790,95 +6383,61 @@ klass: do {
6790
6383
  names[j] = the_function.params[j].string;
6791
6384
  }
6792
6385
  }
6793
- output.push('<br><div class=function><i>' +
6794
- String(the_function.line) + '</i> ' +
6386
+ output.push('<dl><address>line ' +
6387
+ String(the_function.line) + '</address>' +
6795
6388
  the_function.name.entityify() +
6796
- '(' + names.join(', ') + ')</div>');
6797
- detail('<big><b>Undefined</b></big>', the_function['undefined']);
6798
- detail('<big><b>Unused</b></big>', the_function.unused);
6799
- detail('Closure', the_function.closure);
6800
- detail('Variable', the_function['var']);
6801
- detail('Exception', the_function.exception);
6802
- detail('Outer', the_function.outer);
6803
- detail('Global', the_function.global);
6804
- detail('Label', the_function.label);
6805
- }
6806
-
6807
- if (data.member) {
6808
- keys = Object.keys(data.member);
6809
- if (keys.length) {
6810
- keys = keys.sort();
6811
- output.push('<br><pre id=properties>/*properties<br>');
6389
+ '(' + names.join(', ') + ')');
6390
+ detail('undefined', the_function['undefined']);
6391
+ detail('unused', the_function.unused);
6392
+ detail('closure', the_function.closure);
6393
+ detail('variable', the_function['var']);
6394
+ detail('exception', the_function.exception);
6395
+ detail('outer', the_function.outer);
6396
+ detail('global', the_function.global);
6397
+ detail('label', the_function.label);
6398
+ output.push('</dl>');
6399
+ }
6400
+ }
6401
+ return output.join('');
6402
+ };
6403
+
6404
+ itself.properties_report = function (property) {
6405
+ if (!property) {
6406
+ return '';
6407
+ }
6408
+ var i,
6409
+ key,
6410
+ keys = Object.keys(property).sort(),
6411
+ length,
6412
+ output = ['/*properties'],
6413
+ mem = ' ',
6414
+ name,
6415
+ not_first = false;
6416
+ for (i = 0; i < keys.length; i += 1) {
6417
+ key = keys[i];
6418
+ if (property[key] > 0) {
6419
+ if (not_first) {
6420
+ mem += ', ';
6421
+ }
6422
+ name = ix.test(key)
6423
+ ? key
6424
+ : '\'' + key.replace(nx, sanitize) + '\'';
6425
+ length += name.length + 2;
6426
+ if (mem.length + name.length > 80) {
6427
+ output.push(mem);
6812
6428
  mem = ' ';
6813
- italics = 0;
6814
- j = 0;
6815
- if (option.confusion) {
6816
- for (i = 0; i < keys.length; i += 1) {
6817
- key = keys[i];
6818
- if (typeof standard_property_type[key] !== 'string') {
6819
- name = ix.test(key)
6820
- ? key
6821
- : '\'' + key.entityify().replace(nx, sanitize) + '\'';
6822
- if (data.member[key] === 1) {
6823
- name = '<i>' + name + '</i>';
6824
- italics += 1;
6825
- j = 1;
6826
- }
6827
- if (i < keys.length - 1) {
6828
- name += ', ';
6829
- }
6830
- if (mem.length + name.length - (italics * 7) > 80) {
6831
- output.push(mem + '<br>');
6832
- mem = ' ';
6833
- italics = j;
6834
- }
6835
- mem += name;
6836
- j = 0;
6837
- }
6838
- }
6839
- } else {
6840
- for (i = 0; i < keys.length; i += 1) {
6841
- key = keys[i];
6842
- type = property_type[key];
6843
- if (typeof type !== 'string') {
6844
- type = '';
6845
- }
6846
- if (standard_property_type[key] !== type) {
6847
- name = ix.test(key)
6848
- ? key
6849
- : '\'' + key.entityify().replace(nx, sanitize) + '\'';
6850
- length += name.length + 2;
6851
- if (data.member[key] === 1) {
6852
- name = '<i>' + name + '</i>';
6853
- italics += 1;
6854
- j = 1;
6855
- }
6856
- if (type) {
6857
- name += ': ' + type;
6858
- }
6859
- if (i < keys.length - 1) {
6860
- name += ', ';
6861
- }
6862
- if (mem.length + name.length - (italics * 7) > 80) {
6863
- output.push(mem + '<br>');
6864
- mem = ' ';
6865
- italics = j;
6866
- }
6867
- mem += name;
6868
- j = 0;
6869
- }
6870
- }
6871
- }
6872
- output.push(mem + '<br>*/</pre>');
6873
6429
  }
6874
- output.push('</div>');
6430
+ mem += name;
6431
+ not_first = true;
6875
6432
  }
6876
6433
  }
6877
- return output.join('');
6434
+ output.push(mem, '*/\n');
6435
+ return output.join('\n');
6878
6436
  };
6437
+
6879
6438
  itself.jslint = itself;
6880
6439
 
6881
- itself.edition = '2012-01-13';
6440
+ itself.edition = '2012-08-11';
6882
6441
 
6883
6442
  return itself;
6884
6443
  }());