-
Notifications
You must be signed in to change notification settings - Fork 1
/
jslint.js
6947 lines (6460 loc) · 241 KB
/
jslint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// jslint.js
// 2011-07-19
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// The Software shall be used for Good, not Evil.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// WARNING: JSLint will hurt your feelings.
// JSLINT is a global function. It takes two parameters.
// var myResult = JSLINT(source, option);
// The first parameter is either a string or an array of strings. If it is a
// string, it will be split on '\n' or '\r'. If it is an array of strings, it
// is assumed that each string represents one line. The source can be a
// JavaScript text, or HTML text, or a JSON text, or a CSS text.
// The second parameter is an optional object of options that control the
// operation of JSLINT. Most of the options are booleans: They are all
// optional and have a default value of false. One of the options, predef,
// can be an array of names, which will be used to declare global variables,
// or an object whose keys are used as global names, with a boolean value
// that determines if they are assignable.
// If it checks out, JSLINT returns true. Otherwise, it returns false.
// If false, you can inspect JSLINT.errors to find out the problems.
// JSLINT.errors is an array of objects containing these properties:
// {
// line : The line (relative to 0) at which the lint was found
// character : The character (relative to 0) at which the lint was found
// reason : The problem
// evidence : The text line in which the problem occurred
// raw : The raw message before the details were inserted
// a : The first detail
// b : The second detail
// c : The third detail
// d : The fourth detail
// }
// If a stopping error was found, a null will be the last element of the
// JSLINT.errors array. A stopping error means that JSLint was not confident
// enough to continue. It does not necessarily mean that the error was
// especially heinous.
// You can request a Function Report, which shows all of the functions
// and the parameters and vars that they use. This can be used to find
// implied global variables and other problems. The report is in HTML and
// can be inserted in an HTML <body>.
// var myReport = JSLINT.report(errors_only);
// If errors_only is true, then the report will be limited to only errors.
// You can request a data structure that contains JSLint's results.
// var myData = JSLINT.data();
// It returns a structure with this form:
// {
// errors: [
// {
// line: NUMBER,
// character: NUMBER,
// reason: STRING,
// evidence: STRING
// }
// ],
// functions: [
// {
// name: STRING,
// line: NUMBER,
// last: NUMBER,
// params: [
// {
// string: STRING
// }
// ],
// closure: [
// STRING
// ],
// var: [
// STRING
// ],
// exception: [
// STRING
// ],
// outer: [
// STRING
// ],
// unused: [
// STRING
// ],
// undef: [
// STRING
// ],
// global: [
// STRING
// ],
// label: [
// STRING
// ]
// }
// ],
// globals: [
// STRING
// ],
// member: {
// STRING: NUMBER
// },
// urls: [
// STRING
// ],
// json: BOOLEAN
// }
// Empty arrays will not be included.
// You can obtain the parse tree that JSLint constructed while parsing. The
// latest tree is kept in JSLINT.tree. A nice stringication can be produced
// with
// JSON.stringify(JSLINT.tree, [
// 'string', 'arity', 'name', 'first',
// 'second', 'third', 'block', 'else'
// ], 4));
// JSLint provides three directives. They look like slashstar comments, and
// allow for setting options, declaring global variables, and establishing a
// set of allowed property names.
// These directives respect function scope.
// The jslint directive is a special comment that can set one or more options.
// The current option set is
// adsafe true, if ADsafe rules should be enforced
// bitwise true, if bitwise operators should be allowed
// browser true, if the standard browser globals should be predefined
// cap true, if upper case HTML should be allowed
// confusion true, if types can be used inconsistently
// 'continue' true, if the continuation statement should be tolerated
// css true, if CSS workarounds should be tolerated
// debug true, if debugger statements should be allowed
// devel true, if logging should be allowed (console, alert, etc.)
// eqeq true, if == should be allowed
// es5 true, if ES5 syntax should be allowed
// evil true, if eval should be allowed
// forin true, if for in statements need not filter
// fragment true, if HTML fragments should be allowed
// indent the indentation factor
// maxerr the maximum number of errors to allow
// maxlen the maximum length of a source line
// newcap true, if constructor names capitalization is ignored
// node true, if Node.js globals should be predefined
// nomen true, if names may have dangling _
// on true, if HTML event handlers should be allowed
// passfail true, if the scan should stop on first error
// plusplus true, if increment/decrement should be allowed
// properties true, if all property names must be declared with /*properties*/
// regexp true, if the . should be allowed in regexp literals
// rhino true, if the Rhino environment globals should be predefined
// undef true, if variables can be declared out of order
// unparam true, if unused parameters should be tolerated
// safe true, if use of some browser features should be restricted
// sloppy true, if the 'use strict'; pragma is optional
// sub true, if all forms of subscript notation are tolerated
// vars true, if multiple var statements per function should be allowed
// white true, if sloppy whitespace is tolerated
// widget true if the Yahoo Widgets globals should be predefined
// windows true, if MS Windows-specific globals should be predefined
// For example:
/*jslint
evil: true, nomen: true, regexp: true
*/
// The properties directive declares an exclusive list of property names.
// Any properties named in the program that are not in the list will
// produce a warning.
// For example:
/*properties
'\b': string, '\t': string, '\n': string, '\f': string, '\r': string,
'!=': boolean, '!==': boolean, '"': string, '%': boolean, '\'': string,
'(begin)', '(breakage)': number, '(complexity)', '(confusion)': boolean,
'(context)': object, '(error)', '(identifier)', '(line)': number,
'(loopage)': number, '(name)', '(old_property_type)', '(params)',
'(scope)': object, '(statement)', '(token)', '(vars)', '(verb)',
'*': boolean, '+': boolean, '-': boolean, '/': *, '<': boolean,
'<=': boolean, '==': boolean, '===': boolean, '>': boolean,
'>=': boolean, ADSAFE: boolean, Array, Date, E: string, Function,
LN10: string, LN2: string, LOG10E: string, LOG2E: string,
MAX_VALUE: string, MIN_VALUE: string, NEGATIVE_INFINITY: string, Object,
PI: string, POSITIVE_INFINITY: string, SQRT1_2: string, SQRT2: string,
'\\': string, a: object, a_label: string, a_not_allowed: string,
a_not_defined: string, a_scope: string, abbr: object, acronym: object,
address: object, adsafe, adsafe_a: string, adsafe_autocomplete: string,
adsafe_bad_id: string, adsafe_div: string, adsafe_fragment: string,
adsafe_go: string, adsafe_html: string, adsafe_id: string,
adsafe_id_go: string, adsafe_lib: string, adsafe_lib_second: string,
adsafe_missing_id: string, adsafe_name_a: string, adsafe_placement: string,
adsafe_prefix_a: string, adsafe_script: string, adsafe_source: string,
adsafe_subscript_a: string, adsafe_tag: string, all: boolean,
already_defined: string, and: string, applet: object, apply: string,
approved: array, area: object, arity: string, article: object,
aside: object, assign: boolean, assign_exception: string,
assignment_function_expression: string, at: number,
attribute_case_a: string, audio: object, autocomplete: string,
avoid_a: string, b: *, background: array, 'background-attachment': array,
'background-color': array, 'background-image': array,
'background-position': array, 'background-repeat': array,
bad_assignment: string, bad_color_a: string, bad_constructor: string,
bad_entity: string, bad_html: string, bad_id_a: string, bad_in_a: string,
bad_invocation: string, bad_name_a: string, bad_new: string,
bad_number: string, bad_operand: string, bad_style: string,
bad_type: string, bad_url_a: string, bad_wrap: string, base: object,
bdo: object, big: object, bind: string, bitwise: boolean, block: array,
blockquote: object, body: object, border: array, 'border-bottom': array,
'border-bottom-color', 'border-bottom-left-radius',
'border-bottom-right-radius', 'border-bottom-style': array,
'border-bottom-width', 'border-collapse': array, 'border-color': array,
'border-left': array, 'border-left-color', 'border-left-style': array,
'border-left-width', 'border-radius', 'border-right': array,
'border-right-color', 'border-right-style': array, 'border-right-width',
'border-spacing': array, 'border-style': array, 'border-top': array,
'border-top-color', 'border-top-left-radius', 'border-top-right-radius',
'border-top-style': array, 'border-top-width', 'border-width': array,
bottom: array, br: object, braille: boolean, browser: boolean,
button: object, c, call: string, canvas: object, cap, caption: object,
'caption-side': array, ceil: string, center: object, charAt: *,
charCodeAt: *, character, cite: object, clear: array, clip: array, closure,
cm: boolean, code: object, col: object, colgroup: object, color,
combine_var: string, command: object, concat: string,
conditional_assignment: string, confusing_a: string,
confusing_regexp: string, confusion: boolean, constructor: string,
constructor_name_a: string, content: array, continue, control_a: string,
'counter-increment': array, 'counter-reset': array, create: *, css: string,
cursor: array, d, dangerous_comment: string, dangling_a: string,
data: function object, datalist: object, dd: object, debug,
defineProperties: string, defineProperty: string, del: object,
deleted: string, details: object, devel: boolean, dfn: object,
dialog: object, dir: object, direction: array, display: array,
disrupt: boolean, div: object, dl: object, dt: object, duplicate_a: string,
edge: string, edition: string, else, em: *, embed: object,
embossed: boolean, empty: boolean, 'empty-cells': array,
empty_block: string, empty_case: string, empty_class: string,
entityify: function, eqeq, errors: array, es5: string, eval, every: string,
evidence, evil: string, ex: boolean, exception, exec: *,
expected_a: string, expected_a_at_b_c: string, expected_a_b: string,
expected_a_b_from_c_d: string, expected_at_a: string,
expected_attribute_a: string, expected_attribute_value_a: string,
expected_class_a: string, expected_fraction_a: string,
expected_id_a: string, expected_identifier_a: string,
expected_identifier_a_reserved: string, expected_lang_a: string,
expected_linear_a: string, expected_media_a: string,
expected_name_a: string, expected_nonstandard_style_attribute: string,
expected_number_a: string, expected_operator_a: string,
expected_percent_a: string, expected_positive_a: string,
expected_pseudo_a: string, expected_selector_a: string,
expected_small_a: string, expected_space_a_b: string,
expected_string_a: string, expected_style_attribute: string,
expected_style_pattern: string, expected_tagname_a: string,
expected_type_a: string, f: string, fieldset: object, figure: object,
filter: *, first: *, float: array, floor: *, font: *, 'font-family',
'font-size': array, 'font-size-adjust': array, 'font-stretch': array,
'font-style': array, 'font-variant': array, 'font-weight': array,
footer: object, for, forEach: *, for_if: string, forin, form: object,
fragment, frame: object, frameset: object, freeze: string, from: number,
fromCharCode: function, fud: function, funct: object, function,
function_block: string, function_eval: string, function_loop: string,
function_statement: string, function_strict: string, functions: array,
getDate: string, getDay: string, getFullYear: string, getHours: string,
getMilliseconds: string, getMinutes: string, getMonth: string,
getOwnPropertyDescriptor: string, getOwnPropertyNames: string,
getPrototypeOf: string, getSeconds: string, getTime: string,
getTimezoneOffset: string, getUTCDate: string, getUTCDay: string,
getUTCFullYear: string, getUTCHours: string, getUTCMilliseconds: string,
getUTCMinutes: string, getUTCMonth: string, getUTCSeconds: string,
getYear: string, global, globals, h1: object, h2: object, h3: object,
h4: object, h5: object, h6: object, handheld: boolean, hasOwnProperty: *,
head: object, header: object, height: array, hgroup: object, hr: object,
'hta:application': object, html: *, html_confusion_a: string,
html_handlers: string, i: object, id: string, identifier: boolean,
identifier_function: string, iframe: object, img: object, immed: boolean,
implied_evil: string, in, indent: number, indexOf: *, infix_in: string,
init: function, input: object, ins: object, insecure_a: string,
isAlpha: function, isArray: function boolean, isDigit: function,
isExtensible: string, isFrozen: string, isNaN: string,
isPrototypeOf: string, isSealed: string, join: *, jslint: function boolean,
json: boolean, kbd: object, keygen: object, keys: *, label: object,
label_a_b: string, labeled: boolean, lang: string, lastIndex: string,
lastIndexOf: *, lbp: number, leading_decimal_a: string, led: function,
left: array, legend: object, length: *, 'letter-spacing': array,
li: object, lib: boolean, line: number, 'line-height': array, link: object,
'list-style': array, 'list-style-image': array,
'list-style-position': array, 'list-style-type': array, map: *,
margin: array, 'margin-bottom', 'margin-left', 'margin-right',
'margin-top', mark: object, 'marker-offset': array, match: function,
'max-height': array, 'max-width': array, maxerr: number, maxlen: number,
member: object, menu: object, message, meta: object, meter: object,
'min-height': function, 'min-width': function, missing_a: string,
missing_a_after_b: string, missing_option: string,
missing_property: string, missing_space_a_b: string, missing_url: string,
missing_use_strict: string, mixed: string, mm: boolean, mode: string,
move_invocation: string, move_var: string, n: string, name: string,
name_function: string, nav: object, nested_comment: string,
newcap: boolean, node: boolean, noframes: object, nomen, noscript: object,
not: string, not_a_constructor: string, not_a_defined: string,
not_a_function: string, not_a_label: string, not_a_scope: string,
not_greater: string, now: string, nud: function, number: number,
object: object, ol: object, on, opacity, open: boolean, optgroup: object,
option: object, outer: regexp, outline: array, 'outline-color': array,
'outline-style': array, 'outline-width', output: object, overflow: array,
'overflow-x': array, 'overflow-y': array, p: object, padding: array,
'padding-bottom': function, 'padding-left': function,
'padding-right': function, 'padding-top': function,
'page-break-after': array, 'page-break-before': array, param: object,
parameter_a_get_b: string, parameter_set_a: string, params: array,
paren: boolean, parent: string, parse: string, passfail, pc: boolean,
plusplus, pop: *, position: array, postscript: boolean, pre: object,
predef, preventExtensions: string, print: boolean, progress: object,
projection: boolean, properties: boolean, propertyIsEnumerable: string,
prototype: string, pt: boolean, push: *, px: boolean, q: object, quote,
quotes: array, r: string, radix: string, range: function, raw,
read_only: string, reason, redefinition_a: string, reduce: string,
reduceRight: string, regexp, replace: function, report: function,
reserved: boolean, reserved_a: string, reverse: string, rhino: boolean,
right: array, rp: object, rt: object, ruby: object, safe: boolean,
samp: object, scanned_a_b: string, screen: boolean, script: object,
seal: string, search: function, second: *, section: object, select: object,
setDate: string, setDay: string, setFullYear: string, setHours: string,
setMilliseconds: string, setMinutes: string, setMonth: string,
setSeconds: string, setTime: string, setTimezoneOffset: string,
setUTCDate: string, setUTCDay: string, setUTCFullYear: string,
setUTCHours: string, setUTCMilliseconds: string, setUTCMinutes: string,
setUTCMonth: string, setUTCSeconds: string, setYear: string, shift: *,
slash_equal: string, slice: string, sloppy, small: object, some: string,
sort: *, source: object, span: object, speech: boolean, splice: string,
split: function, src, statement_block: string, stopping: string,
strange_loop: string, strict: string, string: string, stringify: string,
strong: object, style: *, styleproperty: regexp, sub: object,
subscript: string, substr: *, substring: string, sup: object,
supplant: function, t: string, table: object, 'table-layout': array,
tag_a_in_b: string, tbody: object, td: object, test: *,
'text-align': array, 'text-decoration': array, 'text-indent': function,
'text-shadow': array, 'text-transform': array, textarea: object,
tfoot: object, th: object, thead: object, third: array, thru: number,
time: object, title: object, toDateString: string, toExponential: string,
toFixed: string, toISOString: string, toJSON: string,
toLocaleDateString: string, toLocaleLowerCase: string,
toLocaleString: string, toLocaleTimeString: string,
toLocaleUpperCase: string, toLowerCase: *, toPrecision: string,
toString: function, toTimeString: string, toUTCString: string,
toUpperCase: *, token: function, too_long: string, too_many: string,
top: array, tr: object, trailing_decimal_a: string, tree: string,
trim: string, tt: object, tty: boolean, tv: boolean, type: string,
type_confusion_a_b: string, u: object, ul: object, unclosed: string,
unclosed_comment: string, unclosed_regexp: string, undef: boolean,
undefined, unescaped_a: string, unexpected_a: string,
unexpected_char_a_b: string, unexpected_comment: string,
unexpected_property_a: string, unexpected_space_a_b: string,
'unicode-bidi': array, unnecessary_initialize: string,
unnecessary_use: string, unparam, unreachable_a_b: string,
unrecognized_style_attribute_a: string, unrecognized_tag_a: string,
unsafe: string, unshift: string, unused: array, url: string, urls: array,
use_array: string, use_braces: string, use_charAt: string,
use_object: string, use_or: string, use_param: string,
used_before_a: string, valueOf: string, var: object, var_a_not: string,
vars, 'vertical-align': array, video: object, visibility: array,
warn: boolean, was: object, weird_assignment: string,
weird_condition: string, weird_new: string, weird_program: string,
weird_relation: string, weird_ternary: string, white: boolean,
'white-space': array, widget: boolean, width: array, windows: boolean,
'word-spacing': array, 'word-wrap': array, wrap: boolean,
wrap_immediate: string, wrap_regexp: string, write_is_wrong: string,
writeable: boolean, 'z-index': array
*/
// The global directive is used to declare global variables that can
// be accessed by the program. If a declaration is true, then the variable
// is writeable. Otherwise, it is read-only.
// We build the application inside a function so that we produce only a single
// global variable. That function will be invoked immediately, and its return
// value is the JSLINT function itself. That function is also an object that
// can contain data and other functions.
var JSLINT = (function () {
'use strict';
function array_to_object(array, value) {
var i, object = {};
for (i = 0; i < array.length; i += 1) {
object[array[i]] = value;
}
return object;
}
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_top, // At the top of the widget script.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
approved, // ADsafe approved urls.
// These are operators that should not be used with the ! operator.
bang = {
'<' : true,
'<=' : true,
'==' : true,
'===': true,
'!==': true,
'!=' : true,
'>' : true,
'>=' : true,
'+' : true,
'-' : true,
'*' : true,
'/' : true,
'%' : true
},
// These are property names that should not be permitted in the safe subset.
banned = array_to_object([
'arguments', 'callee', 'caller', 'constructor', 'eval', 'prototype',
'stack', 'unwatch', 'valueOf', 'watch'
], true),
begin, // The root token
// browser contains a set of global names that are commonly provided by a
// web browser environment.
browser = array_to_object([
'clearInterval', 'clearTimeout', 'document', 'event', 'frames',
'history', 'Image', 'localStorage', 'location', 'name', 'navigator',
'Option', 'parent', 'screen', 'sessionStorage', 'setInterval',
'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
], false),
// bundle contains the text messages.
bundle = {
a_label: "'{a}' is a statement label.",
a_not_allowed: "'{a}' is not allowed.",
a_not_defined: "'{a}' is not defined.",
a_scope: "'{a}' used out of scope.",
adsafe_a: "ADsafe violation: '{a}'.",
adsafe_autocomplete: "ADsafe autocomplete violation.",
adsafe_bad_id: "ADSAFE violation: bad id.",
adsafe_div: "ADsafe violation: Wrap the widget in a div.",
adsafe_fragment: "ADSAFE: Use the fragment option.",
adsafe_go: "ADsafe violation: Misformed ADSAFE.go.",
adsafe_html: "Currently, ADsafe does not operate on whole HTML " +
"documents. It operates on <div> fragments and .js files.",
adsafe_id: "ADsafe violation: id does not match.",
adsafe_id_go: "ADsafe violation: Missing ADSAFE.id or ADSAFE.go.",
adsafe_lib: "ADsafe lib violation.",
adsafe_lib_second: "ADsafe: The second argument to lib must be a function.",
adsafe_missing_id: "ADSAFE violation: missing ID_.",
adsafe_name_a: "ADsafe name violation: '{a}'.",
adsafe_placement: "ADsafe script placement violation.",
adsafe_prefix_a: "ADsafe violation: An id must have a '{a}' prefix",
adsafe_script: "ADsafe script violation.",
adsafe_source: "ADsafe unapproved script source.",
adsafe_subscript_a: "ADsafe subscript '{a}'.",
adsafe_tag: "ADsafe violation: Disallowed tag '{a}'.",
already_defined: "'{a}' is already defined.",
and: "The '&&' subexpression should be wrapped in parens.",
assign_exception: "Do not assign to the exception parameter.",
assignment_function_expression: "Expected an assignment or " +
"function call and instead saw an expression.",
attribute_case_a: "Attribute '{a}' not all lower case.",
avoid_a: "Avoid '{a}'.",
bad_assignment: "Bad assignment.",
bad_color_a: "Bad hex color '{a}'.",
bad_constructor: "Bad constructor.",
bad_entity: "Bad entity.",
bad_html: "Bad HTML string",
bad_id_a: "Bad id: '{a}'.",
bad_in_a: "Bad for in variable '{a}'.",
bad_invocation: "Bad invocation.",
bad_name_a: "Bad name: '{a}'.",
bad_new: "Do not use 'new' for side effects.",
bad_number: "Bad number '{a}'.",
bad_operand: "Bad operand.",
bad_style: "Bad style.",
bad_type: "Bad type.",
bad_url_a: "Bad url '{a}'.",
bad_wrap: "Do not wrap function literals in parens unless they " +
"are to be immediately invoked.",
combine_var: "Combine this with the previous 'var' statement.",
conditional_assignment: "Expected a conditional expression and " +
"instead saw an assignment.",
confusing_a: "Confusing use of '{a}'.",
confusing_regexp: "Confusing regular expression.",
constructor_name_a: "A constructor name '{a}' should start with " +
"an uppercase letter.",
control_a: "Unexpected control character '{a}'.",
css: "A css file should begin with @charset 'UTF-8';",
dangling_a: "Unexpected dangling '_' in '{a}'.",
dangerous_comment: "Dangerous comment.",
deleted: "Only properties should be deleted.",
duplicate_a: "Duplicate '{a}'.",
empty_block: "Empty block.",
empty_case: "Empty case.",
empty_class: "Empty class.",
es5: "This is an ES5 feature.",
evil: "eval is evil.",
expected_a: "Expected '{a}'.",
expected_a_b: "Expected '{a}' and instead saw '{b}'.",
expected_a_b_from_c_d: "Expected '{a}' to match '{b}' from line " +
"{c} and instead saw '{d}'.",
expected_at_a: "Expected an at-rule, and instead saw @{a}.",
expected_a_at_b_c: "Expected '{a}' at column {b}, not column {c}.",
expected_attribute_a: "Expected an attribute, and instead saw [{a}].",
expected_attribute_value_a: "Expected an attribute value and " +
"instead saw '{a}'.",
expected_class_a: "Expected a class, and instead saw .{a}.",
expected_fraction_a: "Expected a number between 0 and 1 and " +
"instead saw '{a}'",
expected_id_a: "Expected an id, and instead saw #{a}.",
expected_identifier_a: "Expected an identifier and instead saw '{a}'.",
expected_identifier_a_reserved: "Expected an identifier and " +
"instead saw '{a}' (a reserved word).",
expected_linear_a: "Expected a linear unit and instead saw '{a}'.",
expected_lang_a: "Expected a lang code, and instead saw :{a}.",
expected_media_a: "Expected a CSS media type, and instead saw '{a}'.",
expected_name_a: "Expected a name and instead saw '{a}'.",
expected_nonstandard_style_attribute: "Expected a non-standard " +
"style attribute and instead saw '{a}'.",
expected_number_a: "Expected a number and instead saw '{a}'.",
expected_operator_a: "Expected an operator and instead saw '{a}'.",
expected_percent_a: "Expected a percentage and instead saw '{a}'",
expected_positive_a: "Expected a positive number and instead saw '{a}'",
expected_pseudo_a: "Expected a pseudo, and instead saw :{a}.",
expected_selector_a: "Expected a CSS selector, and instead saw {a}.",
expected_small_a: "Expected a small number and instead saw '{a}'",
expected_space_a_b: "Expected exactly one space between '{a}' and '{b}'.",
expected_string_a: "Expected a string and instead saw {a}.",
expected_style_attribute: "Excepted a style attribute, and instead saw '{a}'.",
expected_style_pattern: "Expected a style pattern, and instead saw '{a}'.",
expected_tagname_a: "Expected a tagName, and instead saw {a}.",
expected_type_a: "Expected a type, and instead saw {a}.",
for_if: "The body of a for in should be wrapped in an if " +
"statement to filter unwanted properties from the prototype.",
function_block: "Function statements should not be placed in blocks. " +
"Use a function expression or move the statement to the top of " +
"the outer function.",
function_eval: "The Function constructor is eval.",
function_loop: "Don't make functions within a loop.",
function_statement: "Function statements are not invocable. " +
"Wrap the whole function invocation in parens.",
function_strict: "Use the function form of 'use strict'.",
html_confusion_a: "HTML confusion in regular expression '<{a}'.",
html_handlers: "Avoid HTML event handlers.",
identifier_function: "Expected an identifier in an assignment " +
"and instead saw a function invocation.",
implied_evil: "Implied eval is evil. Pass a function instead of a string.",
infix_in: "Unexpected 'in'. Compare with undefined, or use the " +
"hasOwnProperty method instead.",
insecure_a: "Insecure '{a}'.",
isNaN: "Use the isNaN function to compare with NaN.",
label_a_b: "Label '{a}' on '{b}' statement.",
lang: "lang is deprecated.",
leading_decimal_a: "A leading decimal point can be confused with a dot: '.{a}'.",
missing_a: "Missing '{a}'.",
missing_a_after_b: "Missing '{a}' after '{b}'.",
missing_option: "Missing option value.",
missing_property: "Missing property name.",
missing_space_a_b: "Missing space between '{a}' and '{b}'.",
missing_url: "Missing url.",
missing_use_strict: "Missing 'use strict' statement.",
mixed: "Mixed spaces and tabs.",
move_invocation: "Move the invocation into the parens that " +
"contain the function.",
move_var: "Move 'var' declarations to the top of the function.",
name_function: "Missing name in function statement.",
nested_comment: "Nested comment.",
not: "Nested not.",
not_a_constructor: "Do not use {a} as a constructor.",
not_a_defined: "'{a}' has not been fully defined yet.",
not_a_function: "'{a}' is not a function.",
not_a_label: "'{a}' is not a label.",
not_a_scope: "'{a}' is out of scope.",
not_greater: "'{a}' should not be greater than '{b}'.",
parameter_a_get_b: "Unexpected parameter '{a}' in get {b} function.",
parameter_set_a: "Expected parameter (value) in set {a} function.",
radix: "Missing radix parameter.",
read_only: "Read only.",
redefinition_a: "Redefinition of '{a}'.",
reserved_a: "Reserved name '{a}'.",
scanned_a_b: "{a} ({b}% scanned).",
slash_equal: "A regular expression literal can be confused with '/='.",
statement_block: "Expected to see a statement and instead saw a block.",
stopping: "Stopping. ",
strange_loop: "Strange loop.",
strict: "Strict violation.",
subscript: "['{a}'] is better written in dot notation.",
tag_a_in_b: "A '<{a}>' must be within '<{b}>'.",
too_long: "Line too long.",
too_many: "Too many errors.",
trailing_decimal_a: "A trailing decimal point can be confused " +
"with a dot: '.{a}'.",
type: "type is unnecessary.",
type_confusion_a_b: "Type confusion: {a} and {b}.",
unclosed: "Unclosed string.",
unclosed_comment: "Unclosed comment.",
unclosed_regexp: "Unclosed regular expression.",
unescaped_a: "Unescaped '{a}'.",
unexpected_a: "Unexpected '{a}'.",
unexpected_char_a_b: "Unexpected character '{a}' in {b}.",
unexpected_comment: "Unexpected comment.",
unexpected_property_a: "Unexpected /*property*/ '{a}'.",
unexpected_space_a_b: "Unexpected space between '{a}' and '{b}'.",
unnecessary_initialize: "It is not necessary to initialize '{a}' " +
"to 'undefined'.",
unnecessary_use: "Unnecessary 'use strict'.",
unreachable_a_b: "Unreachable '{a}' after '{b}'.",
unrecognized_style_attribute_a: "Unrecognized style attribute '{a}'.",
unrecognized_tag_a: "Unrecognized tag '<{a}>'.",
unsafe: "Unsafe character.",
url: "JavaScript URL.",
use_array: "Use the array literal notation [].",
use_braces: "Spaces are hard to count. Use {{a}}.",
use_charAt: "Use the charAt method.",
use_object: "Use the object literal notation {}.",
use_or: "Use the || operator.",
use_param: "Use a named parameter.",
used_before_a: "'{a}' was used before it was defined.",
var_a_not: "Variable {a} was not declared correctly.",
weird_assignment: "Weird assignment.",
weird_condition: "Weird condition.",
weird_new: "Weird construction. Delete 'new'.",
weird_program: "Weird program.",
weird_relation: "Weird relation.",
weird_ternary: "Weird ternary.",
wrap_immediate: "Wrap an immediate function invocation in parentheses " +
"to assist the reader in understanding that the expression " +
"is the result of a function, and not the function itself.",
wrap_regexp: "Wrap the /regexp/ literal in parens to " +
"disambiguate the slash operator.",
write_is_wrong: "document.write can be a form of eval."
},
comments_off,
css_attribute_data,
css_any,
css_colorData = array_to_object([
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral",
"cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue",
"darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki",
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid",
"darkred", "darksalmon", "darkseagreen", "darkslateblue",
"darkslategray", "darkturquoise", "darkviolet", "deeppink",
"deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite",
"forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold",
"goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink",
"indianred", "indigo", "ivory", "khaki", "lavender",
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgreen",
"lightpink", "lightsalmon", "lightseagreen", "lightskyblue",
"lightslategray", "lightsteelblue", "lightyellow", "lime",
"limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
"mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen",
"mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose",
"moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab",
"orange", "orangered", "orchid", "palegoldenrod", "palegreen",
"paleturquoise", "palevioletred", "papayawhip", "peachpuff",
"peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown",
"royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray",
"snow", "springgreen", "steelblue", "tan", "teal", "thistle",
"tomato", "turquoise", "violet", "wheat", "white", "whitesmoke",
"yellow", "yellowgreen",
"activeborder", "activecaption", "appworkspace", "background",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext",
"captiontext", "graytext", "highlight", "highlighttext",
"inactiveborder", "inactivecaption", "inactivecaptiontext",
"infobackground", "infotext", "menu", "menutext", "scrollbar",
"threeddarkshadow", "threedface", "threedhighlight",
"threedlightshadow", "threedshadow", "window", "windowframe",
"windowtext"
], true),
css_border_style,
css_break,
css_lengthData = {
'%': true,
'cm': true,
'em': true,
'ex': true,
'in': true,
'mm': true,
'pc': true,
'pt': true,
'px': true
},
css_media,
css_overflow,
descapes = {
'b': '\b',
't': '\t',
'n': '\n',
'f': '\f',
'r': '\r',
'"': '"',
'/': '/',
'\\': '\\'
},
devel = array_to_object([
'alert', 'confirm', 'console', 'Debug', 'opera', 'prompt'
], false),
escapes = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'\'': '\\\'',
'"' : '\\"',
'/' : '\\/',
'\\': '\\\\'
},
funct, // The current function, including the labels used
// in the function, as well as (verb), (context),
// (statement), (name), (params), (complexity),
// (loopage), (breakage), (vars)
functionicity = [
'closure', 'exception', 'global', 'label', 'outer', 'undef',
'unused', 'var'
],
functions, // All of the functions
global_funct, // The global body
global_scope, // The global scope
html_tag = {
a: {},
abbr: {},
acronym: {},
address: {},
applet: {},
area: {empty: true, parent: ' map '},
article: {},
aside: {},
audio: {},
b: {},
base: {empty: true, parent: ' head '},
bdo: {},
big: {},
blockquote: {},
body: {parent: ' html noframes '},
br: {empty: true},
button: {},
canvas: {parent: ' body p div th td '},
caption: {parent: ' table '},
center: {},
cite: {},
code: {},
col: {empty: true, parent: ' table colgroup '},
colgroup: {parent: ' table '},
command: {parent: ' menu '},
datalist: {},
dd: {parent: ' dl '},
del: {},
details: {},
dialog: {},
dfn: {},
dir: {},
div: {},
dl: {},
dt: {parent: ' dl '},
em: {},
embed: {},
fieldset: {},
figure: {},
font: {},
footer: {},
form: {},
frame: {empty: true, parent: ' frameset '},
frameset: {parent: ' html frameset '},
h1: {},
h2: {},
h3: {},
h4: {},
h5: {},
h6: {},
head: {parent: ' html '},
header: {},
hgroup: {},
hr: {empty: true},
'hta:application':
{empty: true, parent: ' head '},
html: {parent: '*'},
i: {},
iframe: {},
img: {empty: true},
input: {empty: true},
ins: {},
kbd: {},
keygen: {},
label: {},
legend: {parent: ' details fieldset figure '},
li: {parent: ' dir menu ol ul '},
link: {empty: true, parent: ' head '},
map: {},
mark: {},
menu: {},
meta: {empty: true, parent: ' head noframes noscript '},
meter: {},
nav: {},
noframes: {parent: ' html body '},
noscript: {parent: ' body head noframes '},
object: {},
ol: {},
optgroup: {parent: ' select '},
option: {parent: ' optgroup select '},
output: {},
p: {},
param: {empty: true, parent: ' applet object '},
pre: {},
progress: {},
q: {},
rp: {},
rt: {},
ruby: {},
samp: {},
script: {empty: true, parent: ' body div frame head iframe p pre span '},
section: {},
select: {},
small: {},
span: {},
source: {},
strong: {},
style: {parent: ' head ', empty: true},
sub: {},
sup: {},
table: {},
tbody: {parent: ' table '},
td: {parent: ' tr '},
textarea: {},
tfoot: {parent: ' table '},
th: {parent: ' tr '},
thead: {parent: ' table '},
time: {},
title: {parent: ' head '},
tr: {parent: ' table tbody thead tfoot '},
tt: {},
u: {},
ul: {},
'var': {},
video: {}
},
ids, // HTML ids
in_block,
indent,
infer_statement,// Inference rules for statements
is_type = array_to_object([
'*', 'array', 'boolean', 'function', 'number', 'object',
'regexp', 'string'
], true),
itself, // JSLint itself
json_mode,
lex, // the tokenizer
lines,
lookahead,
member,
node = array_to_object([
'Buffer', 'clearInterval', 'clearTimeout', 'console', 'exports',
'global', 'module', 'process', 'querystring', 'require',
'setInterval', 'setTimeout', '__dirname', '__filename'
], false),
node_js,
numbery = array_to_object(['indexOf', 'lastIndexOf', 'search'], true),
next_token,
option,
predefined, // Global variables defined by option
prereg,
prev_token,
property_type,
regexp_flag = array_to_object(['g', 'i', 'm'], true),
rhino = array_to_object([
'defineClass', 'deserialize', 'gc', 'help', 'load', 'loadClass',
'print', 'quit', 'readFile', 'readUrl', 'runCommand', 'seal',
'serialize', 'spawn', 'sync', 'toint32', 'version'
], false),
scope, // An object containing an object for each variable in scope
semicolon_coda = array_to_object([';', '"', '\'', ')'], true),
src,
stack,
// standard contains the global names that are provided by the
// ECMAScript standard.
standard = array_to_object([
'Array', 'Boolean', 'Date', 'decodeURI', 'decodeURIComponent',
'encodeURI', 'encodeURIComponent', 'Error', 'eval', 'EvalError',
'Function', 'isFinite', 'isNaN', 'JSON', 'Math', 'Number', 'Object',
'parseInt', 'parseFloat', 'RangeError', 'ReferenceError', 'RegExp',
'String', 'SyntaxError', 'TypeError', 'URIError'
], false),
standard_property_type = {
E : 'number',
LN2 : 'number',
LN10 : 'number',
LOG2E : 'number',
LOG10E : 'number',
MAX_VALUE : 'number',
MIN_VALUE : 'number',
NEGATIVE_INFINITY : 'number',
PI : 'number',
POSITIVE_INFINITY : 'number',
SQRT1_2 : 'number',
SQRT2 : 'number',
apply : 'function',
bind : 'function function',
call : 'function',
ceil : 'function number',
charAt : 'function string',
concat : 'function',
constructor : 'function object',
create : 'function object',
defineProperty : 'function object',
defineProperties : 'function object',
every : 'function boolean',
exec : 'function array',
filter : 'function array',
floor : 'function number',
forEach : 'function',
freeze : 'function object',
getDate : 'function number',
getDay : 'function number',
getFullYear : 'function number',
getHours : 'function number',
getMilliseconds : 'function number',
getMinutes : 'function number',
getMonth : 'function number',
getOwnPropertyDescriptor
: 'function object',
getOwnPropertyNames : 'function array',
getPrototypeOf : 'function object',
getSeconds : 'function number',
getTime : 'function number',
getTimezoneOffset : 'function number',
getUTCDate : 'function number',
getUTCDay : 'function number',
getUTCFullYear : 'function number',
getUTCHours : 'function number',
getUTCMilliseconds : 'function number',
getUTCMinutes : 'function number',
getUTCMonth : 'function number',
getUTCSeconds : 'function number',
getYear : 'function number',
hasOwnProperty : 'function boolean',
indexOf : 'function number',
isExtensible : 'function boolean',
isFrozen : 'function boolean',
isPrototypeOf : 'function boolean',
isSealed : 'function boolean',
join : 'function string',