forked from jshint/jshint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jshint.js
4504 lines (4090 loc) · 159 KB
/
jshint.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
/*!
* JSHint, by JSHint Community.
*
* Licensed under the same slightly modified MIT license that JSLint is.
* It stops evil-doers everywhere.
*
* JSHint is a derivative work of JSLint:
*
* 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.
*
* JSHint was forked from 2010-12-16 edition of JSLint.
*
*/
/*
JSHINT is a global function. It takes two parameters.
var myResult = JSHINT(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 a JSON text.
The second parameter is an optional object of options which control the
operation of JSHINT. 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, JSHINT returns true. Otherwise, it returns false.
If false, you can inspect JSHINT.errors to find out the problems.
JSHINT.errors is an array of objects containing these members:
{
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 fatal error was found, a null will be the last element of the
JSHINT.errors array.
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 = JSHINT.report(limited);
If limited is true, then the report will be limited to only errors.
You can request a data structure which contains JSHint's results.
var myData = JSHINT.data();
It returns a structure with this form:
{
errors: [
{
line: NUMBER,
character: NUMBER,
reason: STRING,
evidence: STRING
}
],
functions: [
name: STRING,
line: NUMBER,
last: NUMBER,
param: [
STRING
],
closure: [
STRING
],
var: [
STRING
],
exception: [
STRING
],
outer: [
STRING
],
unused: [
STRING
],
global: [
STRING
],
label: [
STRING
]
],
globals: [
STRING
],
member: {
STRING: NUMBER
},
unused: [
{
name: STRING,
line: NUMBER
}
],
implieds: [
{
name: STRING,
line: NUMBER
}
],
urls: [
STRING
],
json: BOOLEAN
}
Empty arrays will not be included.
*/
/*jshint
evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true,
undef: true, maxlen: 100, indent:4
*/
/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%", "(begin)",
"(breakage)", "(context)", "(error)", "(global)", "(identifier)", "(last)",
"(line)", "(loopage)", "(name)", "(onevar)", "(params)", "(scope)",
"(statement)", "(verb)", "*", "+", "++", "-", "--", "\/", "<", "<=", "==",
"===", ">", ">=", $, $$, $A, $F, $H, $R, $break, $continue, $w, Abstract, Ajax,
__filename, __dirname, ActiveXObject, Array, ArrayBuffer, ArrayBufferView, Audio,
Autocompleter, Assets, Boolean, Builder, Buffer, Browser, COM, CScript, Canvas,
CustomAnimation, Class, Control, Chain, Color, Cookie, Core, DataView, Date,
Debug, Draggable, Draggables, Droppables, Document, DomReady, DOMReady, DOMParser, Drag,
E, Enumerator, Enumerable, Element, Elements, Error, Effect, EvalError, Event,
Events, FadeAnimation, Field, Flash, Float32Array, Float64Array, Form,
FormField, Frame, FormData, Function, Fx, GetObject, Group, Hash, HotKey,
HTMLElement, HTMLAnchorElement, HTMLBaseElement, HTMLBlockquoteElement,
HTMLBodyElement, HTMLBRElement, HTMLButtonElement, HTMLCanvasElement, HTMLDirectoryElement,
HTMLDivElement, HTMLDListElement, HTMLFieldSetElement,
HTMLFontElement, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement,
HTMLHeadElement, HTMLHeadingElement, HTMLHRElement, HTMLHtmlElement,
HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLIsIndexElement,
HTMLLabelElement, HTMLLayerElement, HTMLLegendElement, HTMLLIElement,
HTMLLinkElement, HTMLMapElement, HTMLMenuElement, HTMLMetaElement,
HTMLModElement, HTMLObjectElement, HTMLOListElement, HTMLOptGroupElement,
HTMLOptionElement, HTMLParagraphElement, HTMLParamElement, HTMLPreElement,
HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLStyleElement,
HtmlTable, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement,
HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement,
HTMLTextAreaElement, HTMLTitleElement, HTMLUListElement, HTMLVideoElement,
Iframe, IframeShim, Image, Int16Array, Int32Array, Int8Array,
Insertion, InputValidator, JSON, Keyboard, Locale, LN10, LN2, LOG10E, LOG2E,
MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem, MessageChannel, MessageEvent, MessagePort,
MoveAnimation, MooTools, Native, NEGATIVE_INFINITY, Number, Object, ObjectRange, Option,
Options, OverText, PI, POSITIVE_INFINITY, PeriodicalExecuter, Point, Position, Prototype,
RangeError, Rectangle, ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation,
SQRT1_2, SQRT2, ScrollBar, ScriptEngine, ScriptEngineBuildVersion,
ScriptEngineMajorVersion, ScriptEngineMinorVersion, Scriptaculous, Scroller,
Slick, Slider, Selector, SharedWorker, String, Style, SyntaxError, Sortable, Sortables,
SortableObserver, Sound, Spinner, System, Swiff, Text, TextArea, Template,
Timer, Tips, Type, TypeError, Toggle, Try, "use strict", unescape, URI, URIError, URL,
VBArray, WSH, WScript, XDomainRequest, Web, Window, XMLDOM, XMLHttpRequest, XMLSerializer,
XPathEvaluator, XPathException, XPathExpression, XPathNamespace, XPathNSResolver, XPathResult,
"\\", a, addEventListener, address, alert, apply, applicationCache, arguments, arity, asi, atob,
b, basic, basicToken, bitwise, block, blur, boolOptions, boss, browser, btoa, c, call, callee,
caller, cases, charAt, charCodeAt, character, clearInterval, clearTimeout,
close, closed, closure, comment, condition, confirm, console, constructor,
content, couch, create, css, curly, d, data, datalist, dd, debug, decodeURI,
decodeURIComponent, defaultStatus, defineClass, deserialize, devel, document,
dojo, dijit, dojox, define, else, emit, encodeURI, encodeURIComponent,
entityify, eqeq, eqeqeq, eqnull, errors, es5, escape, esnext, eval, event, evidence, evil,
ex, exception, exec, exps, expr, exports, FileReader, first, floor, focus,
forin, fragment, frames, from, fromCharCode, fud, funcscope, funct, function, functions,
g, gc, getComputedStyle, getRow, getter, getterToken, GLOBAL, global, globals, globalstrict,
hasOwnProperty, help, history, i, id, identifier, immed, implieds, importPackage, include,
indent, indexOf, init, ins, instanceOf, isAlpha, isApplicationRunning, isArray,
isDigit, isFinite, isNaN, iterator, java, join, jshint,
JSHINT, json, jquery, jQuery, keys, label, labelled, last, lastsemic, laxbreak, laxcomma,
latedef, lbp, led, left, length, line, load, loadClass, localStorage, location,
log, loopfunc, m, match, maxerr, maxlen, member,message, meta, module, moveBy,
moveTo, mootools, multistr, name, navigator, new, newcap, noarg, node, noempty, nomen,
nonew, nonstandard, nud, onbeforeunload, onblur, onerror, onevar, onecase, onfocus,
onload, onresize, onunload, open, openDatabase, openURL, opener, opera, options, outer, param,
parent, parseFloat, parseInt, passfail, plusplus, predef, print, process, prompt,
proto, prototype, prototypejs, provides, push, quit, range, raw, reach, reason, regexp,
readFile, readUrl, regexdash, removeEventListener, replace, report, require,
reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, respond, rhino, right,
runCommand, scroll, screen, scripturl, scrollBy, scrollTo, scrollbar, search, seal,
send, serialize, sessionStorage, setInterval, setTimeout, setter, setterToken, shift, slice,
smarttabs, sort, spawn, split, stack, status, start, strict, sub, substr, supernew, shadow,
supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32, token, top, trailing,
type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef, undefs, unused, urls, validthis,
value, valueOf, var, vars, version, WebSocket, withstmt, white, window, windows, Worker, wsh*/
/*global exports: false */
// 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 JSHINT function itself.
var JSHINT = (function () {
"use strict";
var anonname, // The guessed name for anonymous functions.
// 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 the JSHint boolean options.
boolOptions = {
asi : true, // if automatic semicolon insertion should be tolerated
bitwise : true, // if bitwise operators should not be allowed
boss : true, // if advanced usage of assignments should be allowed
browser : true, // if the standard browser globals should be predefined
couch : true, // if CouchDB globals should be predefined
curly : true, // if curly braces around all blocks should be required
debug : true, // if debugger statements should be allowed
devel : true, // if logging globals should be predefined (console,
// alert, etc.)
dojo : true, // if Dojo Toolkit globals should be predefined
eqeqeq : true, // if === should be required
eqnull : true, // if == null comparisons should be tolerated
es5 : true, // if ES5 syntax should be allowed
esnext : true, // if es.next specific syntax should be allowed
evil : true, // if eval should be allowed
expr : true, // if ExpressionStatement should be allowed as Programs
forin : true, // if for in statements must filter
funcscope : true, // if only function scope should be used for scope tests
globalstrict: true, // if global "use strict"; should be allowed (also
// enables 'strict')
immed : true, // if immediate invocations must be wrapped in parens
iterator : true, // if the `__iterator__` property should be allowed
jquery : true, // if jQuery globals should be predefined
lastsemic : true, // if semicolons may be ommitted for the trailing
// statements inside of a one-line blocks.
latedef : true, // if the use before definition should not be tolerated
laxbreak : true, // if line breaks should not be checked
laxcomma : true, // if line breaks should not be checked around commas
loopfunc : true, // if functions should be allowed to be defined within
// loops
mootools : true, // if MooTools globals should be predefined
multistr : true, // allow multiline strings
newcap : true, // if constructor names must be capitalized
noarg : true, // if arguments.caller and arguments.callee should be
// disallowed
node : true, // if the Node.js environment globals should be
// predefined
noempty : true, // if empty blocks should be disallowed
nonew : true, // if using `new` for side-effects should be disallowed
nonstandard : true, // if non-standard (but widely adopted) globals should
// be predefined
nomen : true, // if names should be checked
onevar : true, // if only one var statement per function should be
// allowed
onecase : true, // if one case switch statements should be allowed
passfail : true, // if the scan should stop on first error
plusplus : true, // if increment/decrement should not be allowed
proto : true, // if the `__proto__` property should be allowed
prototypejs : true, // if Prototype and Scriptaculous globals should be
// predefined
regexdash : true, // if unescaped first/last dash (-) inside brackets
// should be tolerated
regexp : true, // if the . should not be allowed in regexp literals
rhino : true, // if the Rhino environment globals should be predefined
undef : true, // if variables should be declared before used
scripturl : true, // if script-targeted URLs should be tolerated
shadow : true, // if variable shadowing should be tolerated
smarttabs : true, // if smarttabs should be tolerated
// (http://www.emacswiki.org/emacs/SmartTabs)
strict : true, // require the "use strict"; pragma
sub : true, // if all forms of subscript notation are tolerated
supernew : true, // if `new function () { ... };` and `new Object;`
// should be tolerated
trailing : true, // if trailing whitespace rules apply
validthis : true, // if 'this' inside a non-constructor function is valid.
// This is a function scoped option only.
withstmt : true, // if with statements should be allowed
white : true, // if strict whitespace rules apply
wsh : true // if the Windows Scripting Host environment globals
// should be predefined
},
// These are the JSHint options that can take any value
// (we use this object to detect invalid options)
valOptions = {
maxlen: false,
indent: false,
maxerr: false,
predef: false
},
// These are JSHint boolean options which are shared with JSLint
// where the definition in JSHint is opposite JSLint
invertedOptions = {
bitwise : true,
forin : true,
newcap : true,
nomen : true,
plusplus : true,
regexp : true,
undef : true,
white : true,
// Inverted and renamed, use JSHint name here
eqeqeq : true,
onevar : true
},
// These are JSHint boolean options which are shared with JSLint
// where the name has been changed but the effect is unchanged
renamedOptions = {
eqeq : "eqeqeq",
vars : "onevar",
windows : "wsh"
},
// browser contains a set of global names which are commonly provided by a
// web browser environment.
browser = {
ArrayBuffer : false,
ArrayBufferView : false,
Audio : false,
addEventListener : false,
applicationCache : false,
atob : false,
blur : false,
btoa : false,
clearInterval : false,
clearTimeout : false,
close : false,
closed : false,
DataView : false,
DOMParser : false,
defaultStatus : false,
document : false,
event : false,
FileReader : false,
Float32Array : false,
Float64Array : false,
FormData : false,
focus : false,
frames : false,
getComputedStyle : false,
HTMLElement : false,
HTMLAnchorElement : false,
HTMLBaseElement : false,
HTMLBlockquoteElement : false,
HTMLBodyElement : false,
HTMLBRElement : false,
HTMLButtonElement : false,
HTMLCanvasElement : false,
HTMLDirectoryElement : false,
HTMLDivElement : false,
HTMLDListElement : false,
HTMLFieldSetElement : false,
HTMLFontElement : false,
HTMLFormElement : false,
HTMLFrameElement : false,
HTMLFrameSetElement : false,
HTMLHeadElement : false,
HTMLHeadingElement : false,
HTMLHRElement : false,
HTMLHtmlElement : false,
HTMLIFrameElement : false,
HTMLImageElement : false,
HTMLInputElement : false,
HTMLIsIndexElement : false,
HTMLLabelElement : false,
HTMLLayerElement : false,
HTMLLegendElement : false,
HTMLLIElement : false,
HTMLLinkElement : false,
HTMLMapElement : false,
HTMLMenuElement : false,
HTMLMetaElement : false,
HTMLModElement : false,
HTMLObjectElement : false,
HTMLOListElement : false,
HTMLOptGroupElement : false,
HTMLOptionElement : false,
HTMLParagraphElement : false,
HTMLParamElement : false,
HTMLPreElement : false,
HTMLQuoteElement : false,
HTMLScriptElement : false,
HTMLSelectElement : false,
HTMLStyleElement : false,
HTMLTableCaptionElement : false,
HTMLTableCellElement : false,
HTMLTableColElement : false,
HTMLTableElement : false,
HTMLTableRowElement : false,
HTMLTableSectionElement : false,
HTMLTextAreaElement : false,
HTMLTitleElement : false,
HTMLUListElement : false,
HTMLVideoElement : false,
history : false,
Int16Array : false,
Int32Array : false,
Int8Array : false,
Image : false,
length : false,
localStorage : false,
location : false,
MessageChannel : false,
MessageEvent : false,
MessagePort : false,
moveBy : false,
moveTo : false,
name : false,
navigator : false,
onbeforeunload : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : false,
openDatabase : false,
opener : false,
Option : false,
parent : false,
print : false,
removeEventListener : false,
resizeBy : false,
resizeTo : false,
screen : false,
scroll : false,
scrollBy : false,
scrollTo : false,
sessionStorage : false,
setInterval : false,
setTimeout : false,
SharedWorker : false,
status : false,
top : false,
Uint16Array : false,
Uint32Array : false,
Uint8Array : false,
WebSocket : false,
window : false,
Worker : false,
XMLHttpRequest : false,
XMLSerializer : false,
XPathEvaluator : false,
XPathException : false,
XPathExpression : false,
XPathNamespace : false,
XPathNSResolver : false,
XPathResult : false
},
couch = {
"require" : false,
respond : false,
getRow : false,
emit : false,
send : false,
start : false,
sum : false,
log : false,
exports : false,
module : false,
provides : false
},
devel = {
alert : false,
confirm : false,
console : false,
Debug : false,
opera : false,
prompt : false
},
dojo = {
dojo : false,
dijit : false,
dojox : false,
define : false,
"require" : false
},
escapes = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'/' : '\\/',
'\\': '\\\\'
},
funct, // The current function
functionicity = [
'closure', 'exception', 'global', 'label',
'outer', 'unused', 'var'
],
functions, // All of the functions
global, // The global scope
implied, // Implied globals
inblock,
indent,
jsonmode,
jquery = {
'$' : false,
jQuery : false
},
lines,
lookahead,
member,
membersOnly,
mootools = {
'$' : false,
'$$' : false,
Assets : false,
Browser : false,
Chain : false,
Class : false,
Color : false,
Cookie : false,
Core : false,
Document : false,
DomReady : false,
DOMReady : false,
Drag : false,
Element : false,
Elements : false,
Event : false,
Events : false,
Fx : false,
Group : false,
Hash : false,
HtmlTable : false,
Iframe : false,
IframeShim : false,
InputValidator : false,
instanceOf : false,
Keyboard : false,
Locale : false,
Mask : false,
MooTools : false,
Native : false,
Options : false,
OverText : false,
Request : false,
Scroller : false,
Slick : false,
Slider : false,
Sortables : false,
Spinner : false,
Swiff : false,
Tips : false,
Type : false,
typeOf : false,
URI : false,
Window : false
},
nexttoken,
node = {
__filename : false,
__dirname : false,
Buffer : false,
console : false,
exports : false,
GLOBAL : false,
global : false,
module : false,
process : false,
require : false,
setTimeout : false,
clearTimeout : false,
setInterval : false,
clearInterval : false
},
noreach,
option,
predefined, // Global variables defined by option
prereg,
prevtoken,
prototypejs = {
'$' : false,
'$$' : false,
'$A' : false,
'$F' : false,
'$H' : false,
'$R' : false,
'$break' : false,
'$continue' : false,
'$w' : false,
Abstract : false,
Ajax : false,
Class : false,
Enumerable : false,
Element : false,
Event : false,
Field : false,
Form : false,
Hash : false,
Insertion : false,
ObjectRange : false,
PeriodicalExecuter: false,
Position : false,
Prototype : false,
Selector : false,
Template : false,
Toggle : false,
Try : false,
Autocompleter : false,
Builder : false,
Control : false,
Draggable : false,
Draggables : false,
Droppables : false,
Effect : false,
Sortable : false,
SortableObserver : false,
Sound : false,
Scriptaculous : false
},
rhino = {
defineClass : false,
deserialize : false,
gc : false,
help : false,
importPackage: false,
"java" : false,
load : false,
loadClass : false,
print : false,
quit : false,
readFile : false,
readUrl : false,
runCommand : false,
seal : false,
serialize : false,
spawn : false,
sync : false,
toint32 : false,
version : false
},
scope, // The current scope
stack,
// standard contains the global names that are provided by the
// ECMAScript standard.
standard = {
Array : false,
Boolean : false,
Date : false,
decodeURI : false,
decodeURIComponent : false,
encodeURI : false,
encodeURIComponent : false,
Error : false,
'eval' : false,
EvalError : false,
Function : false,
hasOwnProperty : false,
isFinite : false,
isNaN : false,
JSON : false,
Math : false,
Number : false,
Object : false,
parseInt : false,
parseFloat : false,
RangeError : false,
ReferenceError : false,
RegExp : false,
String : false,
SyntaxError : false,
TypeError : false,
URIError : false
},
// widely adopted global names that are not part of ECMAScript standard
nonstandard = {
escape : false,
unescape : false
},
standard_member = {
E : true,
LN2 : true,
LN10 : true,
LOG2E : true,
LOG10E : true,
MAX_VALUE : true,
MIN_VALUE : true,
NEGATIVE_INFINITY : true,
PI : true,
POSITIVE_INFINITY : true,
SQRT1_2 : true,
SQRT2 : true
},
directive,
syntax = {},
tab,
token,
urls,
useESNextSyntax,
warnings,
wsh = {
ActiveXObject : true,
Enumerator : true,
GetObject : true,
ScriptEngine : true,
ScriptEngineBuildVersion : true,
ScriptEngineMajorVersion : true,
ScriptEngineMinorVersion : true,
VBArray : true,
WSH : true,
WScript : true,
XDomainRequest : true
};
// Regular expressions. Some of these are stupidly long.
var ax, cx, tx, nx, nxg, lx, ix, jx, ft;
(function () {
/*jshint maxlen:300 */
// unsafe comment or string
ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i;
// 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]/;
// token
tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;
// 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]/;
nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
// star slash
lx = /\*\/|\/\*/;
// identifier
ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
// javascript url
jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
// catches /* falls through */ comments
ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
}());
function F() {} // Used by Object.create
function is_own(object, name) {
// The object.hasOwnProperty method fails when the property under consideration
// is named 'hasOwnProperty'. So we have to use this more convoluted form.
return Object.prototype.hasOwnProperty.call(object, name);
}
function checkOption(name, t) {
if (valOptions[name] === undefined && boolOptions[name] === undefined) {
warning("Bad option: '" + name + "'.", t);
}
}
// Provide critical ES5 functions to ES3.
if (typeof Array.isArray !== 'function') {
Array.isArray = function (o) {
return Object.prototype.toString.apply(o) === '[object Array]';
};
}
if (typeof Object.create !== 'function') {
Object.create = function (o) {
F.prototype = o;
return new F();
};
}
if (typeof Object.keys !== 'function') {
Object.keys = function (o) {
var a = [], k;
for (k in o) {
if (is_own(o, k)) {
a.push(k);
}
}
return a;
};
}
// Non standard methods
if (typeof String.prototype.entityify !== 'function') {
String.prototype.entityify = function () {
return this
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>');
};
}
if (typeof String.prototype.isAlpha !== 'function') {
String.prototype.isAlpha = function () {
return (this >= 'a' && this <= 'z\uffff') ||
(this >= 'A' && this <= 'Z\uffff');
};
}
if (typeof String.prototype.isDigit !== 'function') {
String.prototype.isDigit = function () {
return (this >= '0' && this <= '9');
};
}
if (typeof String.prototype.supplant !== 'function') {
String.prototype.supplant = function (o) {
return this.replace(/\{([^{}]*)\}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
};
}
if (typeof String.prototype.name !== 'function') {
String.prototype.name = function () {
// If the string looks like an identifier, then we can return it as is.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can simply slap some quotes around it.
// Otherwise we must also replace the offending characters with safe
// sequences.
if (ix.test(this)) {
return this;
}
if (nx.test(this)) {
return '"' + this.replace(nxg, function (a) {
var c = escapes[a];
if (c) {
return c;
}
return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
}) + '"';
}
return '"' + this + '"';
};
}
function combine(t, o) {
var n;
for (n in o) {
if (is_own(o, n)) {
t[n] = o[n];
}
}
}
function assume() {
if (option.couch) {
combine(predefined, couch);
}
if (option.rhino) {
combine(predefined, rhino);
}
if (option.prototypejs) {
combine(predefined, prototypejs);
}
if (option.node) {
combine(predefined, node);
option.globalstrict = true;
}
if (option.devel) {
combine(predefined, devel);
}
if (option.dojo) {
combine(predefined, dojo);
}
if (option.browser) {
combine(predefined, browser);
}
if (option.nonstandard) {
combine(predefined, nonstandard);
}
if (option.jquery) {
combine(predefined, jquery);
}
if (option.mootools) {
combine(predefined, mootools);
}
if (option.wsh) {
combine(predefined, wsh);
}
if (option.esnext) {
useESNextSyntax();
}
if (option.globalstrict && option.strict !== false) {
option.strict = true;
}
}
// Produce an error warning.
function quit(message, line, chr) {
var percentage = Math.floor((line / lines.length) * 100);
throw {
name: 'JSHintError',
line: line,
character: chr,
message: message + " (" + percentage + "% scanned).",
raw: message
};
}
function isundef(scope, m, t, a) {
return JSHINT.undefs.push([scope, m, t, a]);
}
function warning(m, t, a, b, c, d) {
var ch, l, w;