forked from davidmiller/lintnode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fulljslint.js
6457 lines (6006 loc) · 219 KB
/
fulljslint.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
// 2012-12-04
// 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 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 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>. It should be given the result of the
// JSLINT.data function.
// var myReport = JSLINT.report(data);
// You can request an HTML error report.
// var myErrorReport = JSLINT.error_report(data);
// You can request a properties report, which produces a list of the program's
// properties in the form of a /*properties*/ declaration.
// var myPropertyReport = JSLINT.properties_report(JSLINT.property);
// You can obtain the parse tree that JSLint constructed while parsing. The
// latest tree is kept in JSLINT.tree. A nice stringification 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.
// For example:
/*jslint
evil: true, nomen: true, regexp: true, todo: true
*/
// The current option set is
// anon true, if the space may be omitted in anonymous function declarations
// bitwise true, if bitwise operators should be allowed
// browser true, if the standard browser globals should be predefined
// '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
// sloppy true, if the 'use strict'; pragma is optional
// stupid true, if really stupid practices are tolerated
// sub true, if all forms of subscript notation are tolerated
// todo true, if TODO comments are tolerated
// vars true, if multiple var statements per function should be allowed
// white true, if sloppy whitespace is tolerated
// windows true, if MS Windows-specific globals should be predefined
// 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', '\t', '\n', '\f', '\r', '!', '!=', '!==', '"', '%', '\'',
'(arguments)', '(begin)', '(breakage)', '(context)', '(error)',
'(identifier)', '(line)', '(loopage)', '(name)', '(params)', '(scope)',
'(token)', '(vars)', '(verb)', '*', '+', '-', '/', '<', '<=', '==', '===',
'>', '>=', ADSAFE, Array, Date, Function, Object, '\\', a, a_label,
a_not_allowed, a_not_defined, a_scope, abbr, acronym, address, adsafe,
adsafe_a, adsafe_autocomplete, adsafe_bad_id, adsafe_div, adsafe_fragment,
adsafe_go, adsafe_html, adsafe_id, adsafe_id_go, adsafe_lib,
adsafe_lib_second, adsafe_missing_id, adsafe_name_a, adsafe_placement,
adsafe_prefix_a, adsafe_script, adsafe_source, adsafe_subscript_a,
adsafe_tag, all, already_defined, and, anon, applet, apply, approved, area,
arity, article, aside, assign, assign_exception,
assignment_function_expression, at, attribute_case_a, audio, autocomplete,
avoid_a, b, background, 'background-attachment', 'background-color',
'background-image', 'background-position', 'background-repeat',
bad_assignment, bad_color_a, bad_constructor, bad_entity, bad_html, bad_id_a,
bad_in_a, bad_invocation, bad_name_a, bad_new, bad_number, bad_operand,
bad_style, bad_type, bad_url_a, bad_wrap, base, bdo, big, bitwise, block,
blockquote, body, border, 'border-bottom', 'border-bottom-color',
'border-bottom-left-radius', 'border-bottom-right-radius',
'border-bottom-style', 'border-bottom-width', 'border-collapse',
'border-color', 'border-left', 'border-left-color', 'border-left-style',
'border-left-width', 'border-radius', 'border-right', 'border-right-color',
'border-right-style', 'border-right-width', 'border-spacing', 'border-style',
'border-top', 'border-top-color', 'border-top-left-radius',
'border-top-right-radius', 'border-top-style', 'border-top-width',
'border-width', bottom, 'box-shadow', br, braille, browser, button, c, call,
canvas, caption, 'caption-side', center, charAt, charCodeAt, character,
cite, clear, clip, closure, cm, code, col, colgroup, color, combine_var,
command, conditional_assignment, confusing_a, confusing_regexp,
constructor_name_a, content, continue, control_a, 'counter-increment',
'counter-reset', create, css, cursor, d, dangerous_comment, dangling_a, data,
datalist, dd, debug, del, deleted, details, devel, dfn, dialog, dir,
direction, display, disrupt, div, dl, dt, duplicate_a, edge, edition, else,
em, embed, embossed, empty, 'empty-cells', empty_block, empty_case,
empty_class, entityify, eqeq, error_report, errors, es5, eval, evidence,
evil, ex, exception, exec, expected_a, expected_a_at_b_c, expected_a_b,
expected_a_b_from_c_d, expected_at_a, expected_attribute_a,
expected_attribute_value_a, expected_class_a, expected_fraction_a,
expected_id_a, expected_identifier_a, expected_identifier_a_reserved,
expected_lang_a, expected_linear_a, expected_media_a, expected_name_a,
expected_nonstandard_style_attribute, expected_number_a, expected_operator_a,
expected_percent_a, expected_positive_a, expected_pseudo_a,
expected_selector_a, expected_small_a, expected_space_a_b, expected_string_a,
expected_style_attribute, expected_style_pattern, expected_tagname_a,
expected_type_a, f, fieldset, figcaption, figure, filter, first, flag, float,
floor, font, 'font-family', 'font-size', 'font-size-adjust', 'font-stretch',
'font-style', 'font-variant', 'font-weight', footer, forEach, for_if, forin,
form, fragment, frame, frameset, from, fromCharCode, fud, funct, function,
function_block, function_eval, function_loop, function_statement,
function_strict, functions, global, globals, h1, h2, h3, h4, h5, h6,
handheld, hasOwnProperty, head, header, height, hgroup, hr,
'hta:application', html, html_confusion_a, html_handlers, i, id, identifier,
identifier_function, iframe, img, immed, implied_evil, in, indent, indexOf,
infix_in, init, input, ins, insecure_a, isAlpha, isArray, isDigit, isNaN,
join, jslint, json, kbd, keygen, keys, label, labeled, lang, lbp,
leading_decimal_a, led, left, legend, length, 'letter-spacing', li, lib,
line, 'line-height', link, 'list-style', 'list-style-image',
'list-style-position', 'list-style-type', map, margin, 'margin-bottom',
'margin-left', 'margin-right', 'margin-top', mark, 'marker-offset', match,
'max-height', 'max-width', maxerr, maxlen, menu, message, meta, meter,
'min-height', 'min-width', missing_a, missing_a_after_b, missing_option,
missing_property, missing_space_a_b, missing_url, missing_use_strict, mixed,
mm, mode, move_invocation, move_var, n, name, name_function, nav,
nested_comment, newcap, node, noframes, nomen, noscript, not,
not_a_constructor, not_a_defined, not_a_function, not_a_label, not_a_scope,
not_greater, nud, number, object, octal_a, ol, on, opacity, open, optgroup,
option, outer, outline, 'outline-color', 'outline-style', 'outline-width',
output, overflow, 'overflow-x', 'overflow-y', p, padding, 'padding-bottom',
'padding-left', 'padding-right', 'padding-top', 'page-break-after',
'page-break-before', param, parameter_a_get_b, parameter_arguments_a,
parameter_set_a, params, paren, parent, passfail, pc, plusplus, pop,
position, postscript, pre, predef, print, progress, projection, properties,
properties_report, property, prototype, pt, push, px, q, quote, quotes, r,
radix, range, raw, read_only, reason, redefinition_a, regexp, replace,
report, reserved, reserved_a, rhino, right, rp, rt, ruby, safe, samp,
scanned_a_b, screen, script, search, second, section, select, shift,
slash_equal, slice, sloppy, small, sort, source, span, speech, split, src,
statement_block, stopping, strange_loop, strict, string, strong, stupid,
style, styleproperty, sub, subscript, substr, sup, supplant, sync_a, t,
table, 'table-layout', tag_a_in_b, tbody, td, test, 'text-align',
'text-decoration', 'text-indent', 'text-shadow', 'text-transform', textarea,
tfoot, th, thead, third, thru, time, title, todo, todo_comment, toLowerCase,
toString, toUpperCase, token, too_long, too_many, top, tr,
trailing_decimal_a, tree, tt, tty, tv, type, u, ul, unclosed,
unclosed_comment, unclosed_regexp, undef, undefined, unescaped_a,
unexpected_a, unexpected_char_a_b, unexpected_comment, unexpected_else,
unexpected_label_a, unexpected_property_a, unexpected_space_a_b,
unexpected_typeof_a, 'unicode-bidi', unnecessary_initialize,
unnecessary_use, unparam, unreachable_a_b, unrecognized_style_attribute_a,
unrecognized_tag_a, unsafe, unused, url, urls, use_array, use_braces,
use_charAt, use_object, use_or, use_param, used_before_a, var, var_a_not,
vars, 'vertical-align', video, visibility, was, weird_assignment,
weird_condition, weird_new, weird_program, weird_relation, weird_ternary,
white, 'white-space', width, windows, 'word-spacing', 'word-wrap', wrap,
wrap_immediate, wrap_regexp, write_is_wrong, writeable, 'z-index'
*/
// 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) {
// Make an object from an array of keys and a common value.
var i, length = array.length, object = {};
for (i = 0; i < 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.
allowed_option = {
anon : true,
bitwise : true,
browser : true,
'continue': true,
css : true,
debug : true,
devel : true,
eqeq : true,
es5 : true,
evil : true,
forin : true,
fragment : true,
indent : 10,
maxerr : 1000,
maxlen : 256,
newcap : true,
node : true,
nomen : true,
on : true,
passfail : true,
plusplus : true,
properties: true,
regexp : true,
rhino : true,
undef : true,
unparam : true,
sloppy : true,
stupid : true,
sub : true,
todo : true,
vars : true,
white : true,
windows : true
},
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', 'FormData',
'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 positive integer 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.",
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}'.",
octal_a: "Don't use octal: '{a}'. Use '\\u....' instead.",
parameter_arguments_a: "Do not mutate parameter '{a}' when using 'arguments'.",
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.",
sync_a: "Unexpected sync method: '{a}'.",
tag_a_in_b: "A '<{a}>' must be within '<{b}>'.",
todo_comment: "Unexpected TODO comment.",
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.",
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_else: "Unexpected 'else' after 'return'.",
unexpected_label_a: "Unexpected label '{a}'.",
unexpected_property_a: "Unexpected /*property*/ '{a}'.",
unexpected_space_a_b: "Unexpected space between '{a}' and '{b}'.",
unexpected_typeof_a: "Unexpected 'typeof'. " +
"Use '===' to compare directly with {a}.",
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', 'WSH'
], false),
directive,
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 (breakage),
// (context), (loopage), (name), (params), (token),
// (vars), (verb)
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: {},
figcaption: {parent: ' figure '},
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,
itself, // JSLint itself
json_mode,
lex, // the tokenizer
lines,
lookahead,
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,
regexp_flag = array_to_object(['g', 'i', 'm'], true),
return_this = function return_this() {
return this;
},
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),
strict_mode,
syntax = {},
tab,
token,
urls,
var_mode,
warnings,
windows = array_to_object([
'ActiveXObject', 'CScript', 'Debug', 'Enumerator', 'System',
'VBArray', 'WScript', 'WSH'
], false),
// xmode is used to adapt to the exceptions in html parsing.
// It can have these states:
// '' .js script file
// 'html'
// 'outer'
// 'script'
// 'style'
// 'scriptstring'
// 'styleproperty'
xmode,
xquote,
// Regular expressions. Some of these are stupidly long.
// unsafe comment or string
ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
// carriage return, carriage return linefeed, or linefeed
crlfx = /\r\n?|\n/,
// unsafe characters that are silently deleted by one or more browsers
cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
// query characters for ids
dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
// html token
hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
// identifier
ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
// javascript url
jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
// star slash
lx = /\*\/|\/\*/,
// characters in strings that need escapement
nx = /[\u0000-\u001f'\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
// outer html token
ox = /[>&]|<[\/!]?|--/,
// attributes characters
qx = /[^a-zA-Z0-9+\-_\/. ]/,
// style
ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
sx = /^\s*([{}:#%.=,>+\[\]@()"';]|[*$\^~]=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
// sync
syx = /Sync$/,
// comment todo
tox = /^\W*to\s*do(?:\W|$)/i,
// token
tx = /^\s*([(){}\[\]\?.,:;'"~#@`]|={1,3}|\/(\*(jslint|properties|property|members?|globals?)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|[\^%]=?|&[&=]?|\|[|=]?|>{1,3}=?|<(?:[\/=!]|\!(\[|--)?|<=?)?|\!(\!|==?)?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+(?:[xX][0-9a-fA-F]+|\.[0-9]*)?(?:[eE][+\-]?[0-9]+)?)/,
// url badness
ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto|script/i,
rx = {
outer: hx,
html: hx,
style: sx,
styleproperty: ssx
};
function F() {} // Used by Object.create
// Provide critical ES5 functions to ES3.
if (typeof Array.prototype.filter !== 'function') {
Array.prototype.filter = function (f) {
var i, length = this.length, result = [], value;
for (i = 0; i < length; i += 1) {
try {
value = this[i];
if (f(value)) {
result.push(value);
}
} catch (ignore) {
}
}
return result;
};
}
if (typeof Array.prototype.forEach !== 'function') {
Array.prototype.forEach = function (f) {
var i, length = this.length;
for (i = 0; i < length; i += 1) {
try {
f(this[i]);
} catch (ignore) {
}
}
};
}
if (typeof Array.isArray !== 'function') {
Array.isArray = function (o) {
return Object.prototype.toString.apply(o) === '[object Array]';
};
}