3
if (typeof window.window != "undefined" && window.document) {
9
var msgs = Array.prototype.slice.call(arguments, 0);
10
postMessage({type: "log", data: msgs});
13
var msgs = Array.prototype.slice.call(arguments, 0);
14
postMessage({type: "log", data: msgs});
17
window.window = window;
20
window.normalizeModule = function(parentId, moduleName) {
21
// normalize plugin requires
22
if (moduleName.indexOf("!") !== -1) {
23
var chunks = moduleName.split("!");
24
return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
26
// normalize relative requires
27
if (moduleName.charAt(0) == ".") {
28
var base = parentId.split("/").slice(0, -1).join("/");
29
moduleName = base + "/" + moduleName;
31
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
32
var previous = moduleName;
33
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
40
window.require = function(parentId, id) {
42
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
44
id = normalizeModule(parentId, id);
46
var module = require.modules[id];
48
if (!module.initialized) {
49
module.initialized = true;
50
module.exports = module.factory().exports;
52
return module.exports;
55
var chunks = id.split("/");
56
chunks[0] = require.tlns[chunks[0]] || chunks[0];
57
var path = chunks.join("/") + ".js";
61
return require(parentId, id);
67
window.define = function(id, deps, factory) {
68
if (arguments.length == 2) {
70
if (typeof id != "string") {
74
} else if (arguments.length == 1) {
79
if (id.indexOf("text!") === 0)
82
var req = function(deps, factory) {
83
return require(id, deps, factory);
86
require.modules[id] = {
91
var returnExports = factory(req, module.exports, module);
93
module.exports = returnExports;
99
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
100
require.tlns = topLevelNamespaces;
103
window.initSender = function initSender() {
105
var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
106
var oop = require(null, "ace/lib/oop");
108
var Sender = function() {};
112
oop.implement(this, EventEmitter);
114
this.callback = function(data, callbackId) {
122
this.emit = function(name, data) {
130
}).call(Sender.prototype);
136
window.sender = null;
138
window.onmessage = function(e) {
141
if (main[msg.command])
142
main[msg.command].apply(main, msg.args);
144
throw new Error("Unknown command:" + msg.command);
147
initBaseUrls(msg.tlns);
148
require(null, "ace/lib/fixoldbrowsers");
149
sender = initSender();
150
var clazz = require(null, msg.module)[msg.classname];
151
main = new clazz(sender);
153
else if (msg.event && sender) {
154
sender._emit(msg.event, msg.data);
157
})(this);// vim:set ts=4 sts=4 sw=4 st:
159
define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
163
require("./es5-shim");
167
define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
170
exec: RegExp.prototype.exec,
171
test: RegExp.prototype.test,
172
match: String.prototype.match,
173
replace: String.prototype.replace,
174
split: String.prototype.split
176
compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
177
compliantLastIndexIncrement = function () {
179
real.test.call(x, "");
183
if (compliantLastIndexIncrement && compliantExecNpcg)
185
RegExp.prototype.exec = function (str) {
186
var match = real.exec.apply(this, arguments),
188
if ( typeof(str) == 'string' && match) {
189
if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
190
r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
191
real.replace.call(str.slice(match.index), r2, function () {
192
for (var i = 1; i < arguments.length - 2; i++) {
193
if (arguments[i] === undefined)
194
match[i] = undefined;
198
if (this._xregexp && this._xregexp.captureNames) {
199
for (var i = 1; i < match.length; i++) {
200
name = this._xregexp.captureNames[i - 1];
202
match[name] = match[i];
205
if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
210
if (!compliantLastIndexIncrement) {
211
RegExp.prototype.test = function (str) {
212
var match = real.exec.call(this, str);
213
if (match && this.global && !match[0].length && (this.lastIndex > match.index))
219
function getNativeFlags (regex) {
220
return (regex.global ? "g" : "") +
221
(regex.ignoreCase ? "i" : "") +
222
(regex.multiline ? "m" : "") +
223
(regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
224
(regex.sticky ? "y" : "");
227
function indexOf (array, item, from) {
228
if (Array.prototype.indexOf) // Use the native array method if available
229
return array.indexOf(item, from);
230
for (var i = from || 0; i < array.length; i++) {
231
if (array[i] === item)
239
define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
243
if (!Function.prototype.bind) {
244
Function.prototype.bind = function bind(that) { // .length is 1
246
if (typeof target != "function") {
247
throw new TypeError("Function.prototype.bind called on incompatible " + target);
249
var args = slice.call(arguments, 1); // for normal call
250
var bound = function () {
252
if (this instanceof bound) {
254
var result = target.apply(
256
args.concat(slice.call(arguments))
258
if (Object(result) === result) {
266
args.concat(slice.call(arguments))
272
if(target.prototype) {
273
Empty.prototype = target.prototype;
274
bound.prototype = new Empty();
275
Empty.prototype = null;
280
var call = Function.prototype.call;
281
var prototypeOfArray = Array.prototype;
282
var prototypeOfObject = Object.prototype;
283
var slice = prototypeOfArray.slice;
284
var _toString = call.bind(prototypeOfObject.toString);
285
var owns = call.bind(prototypeOfObject.hasOwnProperty);
290
var supportsAccessors;
291
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
292
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
293
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
294
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
295
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
297
if ([1,2].splice(0).length != 2) {
298
if(function() { // test IE < 9 to splice bug - see issue #138
299
function makeArray(l) {
300
var a = new Array(l+2);
304
var array = [], lengthBefore;
306
array.splice.apply(array, makeArray(20));
307
array.splice.apply(array, makeArray(26));
309
lengthBefore = array.length; //46
310
array.splice(5, 0, "XXX"); // add one element
312
lengthBefore + 1 == array.length
314
if (lengthBefore + 1 == array.length) {
315
return true;// has right splice implementation without bugs
318
var array_splice = Array.prototype.splice;
319
Array.prototype.splice = function(start, deleteCount) {
320
if (!arguments.length) {
323
return array_splice.apply(this, [
324
start === void 0 ? 0 : start,
325
deleteCount === void 0 ? (this.length - start) : deleteCount
326
].concat(slice.call(arguments, 2)))
330
Array.prototype.splice = function(pos, removeCount){
331
var length = this.length;
335
} else if (pos == void 0) {
337
} else if (pos < 0) {
338
pos = Math.max(length + pos, 0);
341
if (!(pos+removeCount < length))
342
removeCount = length - pos;
344
var removed = this.slice(pos, pos+removeCount);
345
var insert = slice.call(arguments, 2);
346
var add = insert.length;
347
if (pos === length) {
349
this.push.apply(this, insert);
352
var remove = Math.min(removeCount, length - pos);
353
var tailOldPos = pos + remove;
354
var tailNewPos = tailOldPos + add - remove;
355
var tailCount = length - tailOldPos;
356
var lengthAfterRemove = length - remove;
358
if (tailNewPos < tailOldPos) { // case A
359
for (var i = 0; i < tailCount; ++i) {
360
this[tailNewPos+i] = this[tailOldPos+i];
362
} else if (tailNewPos > tailOldPos) { // case B
363
for (i = tailCount; i--; ) {
364
this[tailNewPos+i] = this[tailOldPos+i];
366
} // else, add == remove (nothing to do)
368
if (add && pos === lengthAfterRemove) {
369
this.length = lengthAfterRemove; // truncate array
370
this.push.apply(this, insert);
372
this.length = lengthAfterRemove + add; // reserves space
373
for (i = 0; i < add; ++i) {
374
this[pos+i] = insert[i];
382
if (!Array.isArray) {
383
Array.isArray = function isArray(obj) {
384
return _toString(obj) == "[object Array]";
387
var boxedString = Object("a"),
388
splitString = boxedString[0] != "a" || !(0 in boxedString);
390
if (!Array.prototype.forEach) {
391
Array.prototype.forEach = function forEach(fun /*, thisp*/) {
392
var object = toObject(this),
393
self = splitString && _toString(this) == "[object String]" ?
396
thisp = arguments[1],
398
length = self.length >>> 0;
399
if (_toString(fun) != "[object Function]") {
400
throw new TypeError(); // TODO message
403
while (++i < length) {
405
fun.call(thisp, self[i], i, object);
410
if (!Array.prototype.map) {
411
Array.prototype.map = function map(fun /*, thisp*/) {
412
var object = toObject(this),
413
self = splitString && _toString(this) == "[object String]" ?
416
length = self.length >>> 0,
417
result = Array(length),
418
thisp = arguments[1];
419
if (_toString(fun) != "[object Function]") {
420
throw new TypeError(fun + " is not a function");
423
for (var i = 0; i < length; i++) {
425
result[i] = fun.call(thisp, self[i], i, object);
430
if (!Array.prototype.filter) {
431
Array.prototype.filter = function filter(fun /*, thisp */) {
432
var object = toObject(this),
433
self = splitString && _toString(this) == "[object String]" ?
436
length = self.length >>> 0,
439
thisp = arguments[1];
440
if (_toString(fun) != "[object Function]") {
441
throw new TypeError(fun + " is not a function");
444
for (var i = 0; i < length; i++) {
447
if (fun.call(thisp, value, i, object)) {
455
if (!Array.prototype.every) {
456
Array.prototype.every = function every(fun /*, thisp */) {
457
var object = toObject(this),
458
self = splitString && _toString(this) == "[object String]" ?
461
length = self.length >>> 0,
462
thisp = arguments[1];
463
if (_toString(fun) != "[object Function]") {
464
throw new TypeError(fun + " is not a function");
467
for (var i = 0; i < length; i++) {
468
if (i in self && !fun.call(thisp, self[i], i, object)) {
475
if (!Array.prototype.some) {
476
Array.prototype.some = function some(fun /*, thisp */) {
477
var object = toObject(this),
478
self = splitString && _toString(this) == "[object String]" ?
481
length = self.length >>> 0,
482
thisp = arguments[1];
483
if (_toString(fun) != "[object Function]") {
484
throw new TypeError(fun + " is not a function");
487
for (var i = 0; i < length; i++) {
488
if (i in self && fun.call(thisp, self[i], i, object)) {
495
if (!Array.prototype.reduce) {
496
Array.prototype.reduce = function reduce(fun /*, initial*/) {
497
var object = toObject(this),
498
self = splitString && _toString(this) == "[object String]" ?
501
length = self.length >>> 0;
502
if (_toString(fun) != "[object Function]") {
503
throw new TypeError(fun + " is not a function");
505
if (!length && arguments.length == 1) {
506
throw new TypeError("reduce of empty array with no initial value");
511
if (arguments.length >= 2) {
512
result = arguments[1];
520
throw new TypeError("reduce of empty array with no initial value");
525
for (; i < length; i++) {
527
result = fun.call(void 0, result, self[i], i, object);
534
if (!Array.prototype.reduceRight) {
535
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
536
var object = toObject(this),
537
self = splitString && _toString(this) == "[object String]" ?
540
length = self.length >>> 0;
541
if (_toString(fun) != "[object Function]") {
542
throw new TypeError(fun + " is not a function");
544
if (!length && arguments.length == 1) {
545
throw new TypeError("reduceRight of empty array with no initial value");
548
var result, i = length - 1;
549
if (arguments.length >= 2) {
550
result = arguments[1];
558
throw new TypeError("reduceRight of empty array with no initial value");
565
result = fun.call(void 0, result, self[i], i, object);
572
if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
573
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
574
var self = splitString && _toString(this) == "[object String]" ?
577
length = self.length >>> 0;
584
if (arguments.length > 1) {
585
i = toInteger(arguments[1]);
587
i = i >= 0 ? i : Math.max(0, length + i);
588
for (; i < length; i++) {
589
if (i in self && self[i] === sought) {
596
if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
597
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
598
var self = splitString && _toString(this) == "[object String]" ?
601
length = self.length >>> 0;
607
if (arguments.length > 1) {
608
i = Math.min(i, toInteger(arguments[1]));
610
i = i >= 0 ? i : length - Math.abs(i);
611
for (; i >= 0; i--) {
612
if (i in self && sought === self[i]) {
619
if (!Object.getPrototypeOf) {
620
Object.getPrototypeOf = function getPrototypeOf(object) {
621
return object.__proto__ || (
623
object.constructor.prototype :
628
if (!Object.getOwnPropertyDescriptor) {
629
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
631
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
632
if ((typeof object != "object" && typeof object != "function") || object === null)
633
throw new TypeError(ERR_NON_OBJECT + object);
634
if (!owns(object, property))
637
var descriptor, getter, setter;
638
descriptor = { enumerable: true, configurable: true };
639
if (supportsAccessors) {
640
var prototype = object.__proto__;
641
object.__proto__ = prototypeOfObject;
643
var getter = lookupGetter(object, property);
644
var setter = lookupSetter(object, property);
645
object.__proto__ = prototype;
647
if (getter || setter) {
648
if (getter) descriptor.get = getter;
649
if (setter) descriptor.set = setter;
653
descriptor.value = object[property];
657
if (!Object.getOwnPropertyNames) {
658
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
659
return Object.keys(object);
662
if (!Object.create) {
664
if (Object.prototype.__proto__ === null) {
665
createEmpty = function () {
666
return { "__proto__": null };
669
createEmpty = function () {
674
empty.hasOwnProperty =
675
empty.propertyIsEnumerable =
676
empty.isPrototypeOf =
677
empty.toLocaleString =
680
empty.__proto__ = null;
685
Object.create = function create(prototype, properties) {
687
if (prototype === null) {
688
object = createEmpty();
690
if (typeof prototype != "object")
691
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
692
var Type = function () {};
693
Type.prototype = prototype;
695
object.__proto__ = prototype;
697
if (properties !== void 0)
698
Object.defineProperties(object, properties);
703
function doesDefinePropertyWork(object) {
705
Object.defineProperty(object, "sentinel", {});
706
return "sentinel" in object;
707
} catch (exception) {
710
if (Object.defineProperty) {
711
var definePropertyWorksOnObject = doesDefinePropertyWork({});
712
var definePropertyWorksOnDom = typeof document == "undefined" ||
713
doesDefinePropertyWork(document.createElement("div"));
714
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
715
var definePropertyFallback = Object.defineProperty;
719
if (!Object.defineProperty || definePropertyFallback) {
720
var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
721
var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
722
var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
723
"on this javascript engine";
725
Object.defineProperty = function defineProperty(object, property, descriptor) {
726
if ((typeof object != "object" && typeof object != "function") || object === null)
727
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
728
if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
729
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
730
if (definePropertyFallback) {
732
return definePropertyFallback.call(Object, object, property, descriptor);
733
} catch (exception) {
736
if (owns(descriptor, "value")) {
738
if (supportsAccessors && (lookupGetter(object, property) ||
739
lookupSetter(object, property)))
741
var prototype = object.__proto__;
742
object.__proto__ = prototypeOfObject;
743
delete object[property];
744
object[property] = descriptor.value;
745
object.__proto__ = prototype;
747
object[property] = descriptor.value;
750
if (!supportsAccessors)
751
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
752
if (owns(descriptor, "get"))
753
defineGetter(object, property, descriptor.get);
754
if (owns(descriptor, "set"))
755
defineSetter(object, property, descriptor.set);
761
if (!Object.defineProperties) {
762
Object.defineProperties = function defineProperties(object, properties) {
763
for (var property in properties) {
764
if (owns(properties, property))
765
Object.defineProperty(object, property, properties[property]);
771
Object.seal = function seal(object) {
775
if (!Object.freeze) {
776
Object.freeze = function freeze(object) {
781
Object.freeze(function () {});
782
} catch (exception) {
783
Object.freeze = (function freeze(freezeObject) {
784
return function freeze(object) {
785
if (typeof object == "function") {
788
return freezeObject(object);
793
if (!Object.preventExtensions) {
794
Object.preventExtensions = function preventExtensions(object) {
798
if (!Object.isSealed) {
799
Object.isSealed = function isSealed(object) {
803
if (!Object.isFrozen) {
804
Object.isFrozen = function isFrozen(object) {
808
if (!Object.isExtensible) {
809
Object.isExtensible = function isExtensible(object) {
810
if (Object(object) === object) {
811
throw new TypeError(); // TODO message
814
while (owns(object, name)) {
818
var returnValue = owns(object, name);
824
var hasDontEnumBug = true,
831
"propertyIsEnumerable",
834
dontEnumsLength = dontEnums.length;
836
for (var key in {"toString": null}) {
837
hasDontEnumBug = false;
840
Object.keys = function keys(object) {
843
(typeof object != "object" && typeof object != "function") ||
846
throw new TypeError("Object.keys called on a non-object");
850
for (var name in object) {
851
if (owns(object, name)) {
856
if (hasDontEnumBug) {
857
for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
858
var dontEnum = dontEnums[i];
859
if (owns(object, dontEnum)) {
869
Date.now = function now() {
870
return new Date().getTime();
873
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
874
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
876
if (!String.prototype.trim || ws.trim()) {
878
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
879
trimEndRegexp = new RegExp(ws + ws + "*$");
880
String.prototype.trim = function trim() {
881
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
885
function toInteger(n) {
887
if (n !== n) { // isNaN
889
} else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
890
n = (n > 0 || -1) * Math.floor(Math.abs(n));
895
function isPrimitive(input) {
896
var type = typeof input;
899
type === "undefined" ||
900
type === "boolean" ||
906
function toPrimitive(input) {
907
var val, valueOf, toString;
908
if (isPrimitive(input)) {
911
valueOf = input.valueOf;
912
if (typeof valueOf === "function") {
913
val = valueOf.call(input);
914
if (isPrimitive(val)) {
918
toString = input.toString;
919
if (typeof toString === "function") {
920
val = toString.call(input);
921
if (isPrimitive(val)) {
925
throw new TypeError();
927
var toObject = function (o) {
928
if (o == null) { // this matches both null and undefined
929
throw new TypeError("can't convert "+o+" to object");
936
define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
939
var EventEmitter = {};
940
var stopPropagation = function() { this.propagationStopped = true; };
941
var preventDefault = function() { this.defaultPrevented = true; };
944
EventEmitter._dispatchEvent = function(eventName, e) {
945
this._eventRegistry || (this._eventRegistry = {});
946
this._defaultHandlers || (this._defaultHandlers = {});
948
var listeners = this._eventRegistry[eventName] || [];
949
var defaultHandler = this._defaultHandlers[eventName];
950
if (!listeners.length && !defaultHandler)
953
if (typeof e != "object" || !e)
958
if (!e.stopPropagation)
959
e.stopPropagation = stopPropagation;
960
if (!e.preventDefault)
961
e.preventDefault = preventDefault;
965
for (var i=0; i<listeners.length; i++) {
967
if (e.propagationStopped)
971
if (defaultHandler && !e.defaultPrevented)
972
return defaultHandler(e);
976
EventEmitter._signal = function(eventName, e) {
977
var listeners = (this._eventRegistry || {})[eventName];
981
for (var i=0; i<listeners.length; i++)
985
EventEmitter.once = function(eventName, callback) {
987
var newCallback = function() {
988
fun && fun.apply(null, arguments);
989
_self.removeEventListener(event, newCallback);
991
this.addEventListener(event, newCallback);
995
EventEmitter.setDefaultHandler = function(eventName, callback) {
996
this._defaultHandlers = this._defaultHandlers || {};
998
if (this._defaultHandlers[eventName])
999
throw new Error("The default handler for '" + eventName + "' is already set");
1001
this._defaultHandlers[eventName] = callback;
1005
EventEmitter.addEventListener = function(eventName, callback, capturing) {
1006
this._eventRegistry = this._eventRegistry || {};
1008
var listeners = this._eventRegistry[eventName];
1010
listeners = this._eventRegistry[eventName] = [];
1012
if (listeners.indexOf(callback) == -1)
1013
listeners[capturing ? "unshift" : "push"](callback);
1017
EventEmitter.removeListener =
1018
EventEmitter.removeEventListener = function(eventName, callback) {
1019
this._eventRegistry = this._eventRegistry || {};
1021
var listeners = this._eventRegistry[eventName];
1025
var index = listeners.indexOf(callback);
1027
listeners.splice(index, 1);
1030
EventEmitter.removeAllListeners = function(eventName) {
1031
if (this._eventRegistry) this._eventRegistry[eventName] = [];
1034
exports.EventEmitter = EventEmitter;
1038
define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
1041
exports.inherits = (function() {
1042
var tempCtor = function() {};
1043
return function(ctor, superCtor) {
1044
tempCtor.prototype = superCtor.prototype;
1045
ctor.super_ = superCtor.prototype;
1046
ctor.prototype = new tempCtor();
1047
ctor.prototype.constructor = ctor;
1051
exports.mixin = function(obj, mixin) {
1052
for (var key in mixin) {
1053
obj[key] = mixin[key];
1057
exports.implement = function(proto, mixin) {
1058
exports.mixin(proto, mixin);
1063
define('ace/mode/javascript_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/javascript/jshint'], function(require, exports, module) {
1066
var oop = require("../lib/oop");
1067
var Mirror = require("../worker/mirror").Mirror;
1068
var lint = require("./javascript/jshint").JSHINT;
1070
function startRegex(arr) {
1071
return RegExp("^(" + arr.join("|") + ")");
1074
var disabledWarningsRe = startRegex([
1075
"Bad for in variable '(.+)'.",
1076
'Missing "use strict"'
1078
var errorsRe = startRegex([
1081
"Confusing (plus|minus)",
1082
"\\{a\\} unterminated regular expression",
1087
"Missing space after",
1088
"Missing operator at"
1090
var infoRe = startRegex([
1091
"Expected an assignment",
1092
"Bad escapement of EOL",
1095
"Missing radix parameter.",
1096
"A leading decimal point can",
1097
"\\['{a}'\\] is better written in dot notation.",
1098
"'{a}' used out of scope"
1101
var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
1102
Mirror.call(this, sender);
1103
this.setTimeout(500);
1107
oop.inherits(JavaScriptWorker, Mirror);
1110
this.setOptions = function(options) {
1111
this.options = options || {
1127
this.doc.getValue() && this.deferredUpdate.schedule(100);
1130
this.changeOptions = function(newOptions) {
1131
oop.mixin(this.options, newOptions);
1132
this.doc.getValue() && this.deferredUpdate.schedule(100);
1135
this.isValidJS = function(str) {
1137
eval("throw 0;" + str);
1145
this.onUpdate = function() {
1146
var value = this.doc.getValue();
1147
value = value.replace(/^#!.*\n/, "\n");
1149
this.sender.emit("jslint", []);
1153
var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
1154
lint(value, this.options);
1155
var results = lint.errors;
1157
var errorAdded = false
1158
for (var i = 0; i < results.length; i++) {
1159
var error = results[i];
1162
var raw = error.raw;
1163
var type = "warning";
1165
if (raw == "Missing semicolon.") {
1166
var str = error.evidence.substr(error.character);
1167
str = str.charAt(str.search(/\S/));
1168
if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
1169
error.reason = 'Missing ";" before statement';
1175
else if (disabledWarningsRe.test(raw)) {
1178
else if (infoRe.test(raw)) {
1181
else if (errorsRe.test(raw)) {
1183
type = maxErrorLevel;
1185
else if (raw == "'{a}' is not defined.") {
1188
else if (raw == "'{a}' is defined but never used.") {
1194
column: error.character-1,
1204
this.sender.emit("jslint", errors);
1207
}).call(JavaScriptWorker.prototype);
1210
define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
1213
var Document = require("../document").Document;
1214
var lang = require("../lib/lang");
1216
var Mirror = exports.Mirror = function(sender) {
1217
this.sender = sender;
1218
var doc = this.doc = new Document("");
1220
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1223
sender.on("change", function(e) {
1224
doc.applyDeltas([e.data]);
1225
deferredUpdate.schedule(_self.$timeout);
1231
this.$timeout = 500;
1233
this.setTimeout = function(timeout) {
1234
this.$timeout = timeout;
1237
this.setValue = function(value) {
1238
this.doc.setValue(value);
1239
this.deferredUpdate.schedule(this.$timeout);
1242
this.getValue = function(callbackId) {
1243
this.sender.callback(this.doc.getValue(), callbackId);
1246
this.onUpdate = function() {
1249
}).call(Mirror.prototype);
1253
define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
1256
var oop = require("./lib/oop");
1257
var EventEmitter = require("./lib/event_emitter").EventEmitter;
1258
var Range = require("./range").Range;
1259
var Anchor = require("./anchor").Anchor;
1261
var Document = function(text) {
1263
if (text.length == 0) {
1265
} else if (Array.isArray(text)) {
1266
this.insertLines(0, text);
1268
this.insert({row: 0, column:0}, text);
1274
oop.implement(this, EventEmitter);
1275
this.setValue = function(text) {
1276
var len = this.getLength();
1277
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
1278
this.insert({row: 0, column:0}, text);
1280
this.getValue = function() {
1281
return this.getAllLines().join(this.getNewLineCharacter());
1283
this.createAnchor = function(row, column) {
1284
return new Anchor(this, row, column);
1286
if ("aaa".split(/a/).length == 0)
1287
this.$split = function(text) {
1288
return text.replace(/\r\n|\r/g, "\n").split("\n");
1291
this.$split = function(text) {
1292
return text.split(/\r\n|\r|\n/);
1297
this.$detectNewLine = function(text) {
1298
var match = text.match(/^.*?(\r\n|\r|\n)/m);
1300
this.$autoNewLine = match[1];
1302
this.$autoNewLine = "\n";
1305
this.getNewLineCharacter = function() {
1306
switch (this.$newLineMode) {
1314
return this.$autoNewLine;
1318
this.$autoNewLine = "\n";
1319
this.$newLineMode = "auto";
1320
this.setNewLineMode = function(newLineMode) {
1321
if (this.$newLineMode === newLineMode)
1324
this.$newLineMode = newLineMode;
1326
this.getNewLineMode = function() {
1327
return this.$newLineMode;
1329
this.isNewLine = function(text) {
1330
return (text == "\r\n" || text == "\r" || text == "\n");
1332
this.getLine = function(row) {
1333
return this.$lines[row] || "";
1335
this.getLines = function(firstRow, lastRow) {
1336
return this.$lines.slice(firstRow, lastRow + 1);
1338
this.getAllLines = function() {
1339
return this.getLines(0, this.getLength());
1341
this.getLength = function() {
1342
return this.$lines.length;
1344
this.getTextRange = function(range) {
1345
if (range.start.row == range.end.row) {
1346
return this.$lines[range.start.row].substring(range.start.column,
1350
var lines = this.getLines(range.start.row+1, range.end.row-1);
1351
lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
1352
lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
1353
return lines.join(this.getNewLineCharacter());
1357
this.$clipPosition = function(position) {
1358
var length = this.getLength();
1359
if (position.row >= length) {
1360
position.row = Math.max(0, length - 1);
1361
position.column = this.getLine(length-1).length;
1365
this.insert = function(position, text) {
1366
if (!text || text.length === 0)
1369
position = this.$clipPosition(position);
1370
if (this.getLength() <= 1)
1371
this.$detectNewLine(text);
1373
var lines = this.$split(text);
1374
var firstLine = lines.splice(0, 1)[0];
1375
var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
1377
position = this.insertInLine(position, firstLine);
1378
if (lastLine !== null) {
1379
position = this.insertNewLine(position); // terminate first line
1380
position = this.insertLines(position.row, lines);
1381
position = this.insertInLine(position, lastLine || "");
1385
this.insertLines = function(row, lines) {
1386
if (lines.length == 0)
1387
return {row: row, column: 0};
1388
if (lines.length > 0xFFFF) {
1389
var end = this.insertLines(row, lines.slice(0xFFFF));
1390
lines = lines.slice(0, 0xFFFF);
1393
var args = [row, 0];
1394
args.push.apply(args, lines);
1395
this.$lines.splice.apply(this.$lines, args);
1397
var range = new Range(row, 0, row + lines.length, 0);
1399
action: "insertLines",
1403
this._emit("change", { data: delta });
1404
return end || range.end;
1406
this.insertNewLine = function(position) {
1407
position = this.$clipPosition(position);
1408
var line = this.$lines[position.row] || "";
1410
this.$lines[position.row] = line.substring(0, position.column);
1411
this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
1414
row : position.row + 1,
1419
action: "insertText",
1420
range: Range.fromPoints(position, end),
1421
text: this.getNewLineCharacter()
1423
this._emit("change", { data: delta });
1427
this.insertInLine = function(position, text) {
1428
if (text.length == 0)
1431
var line = this.$lines[position.row] || "";
1433
this.$lines[position.row] = line.substring(0, position.column) + text
1434
+ line.substring(position.column);
1438
column : position.column + text.length
1442
action: "insertText",
1443
range: Range.fromPoints(position, end),
1446
this._emit("change", { data: delta });
1450
this.remove = function(range) {
1451
range.start = this.$clipPosition(range.start);
1452
range.end = this.$clipPosition(range.end);
1454
if (range.isEmpty())
1457
var firstRow = range.start.row;
1458
var lastRow = range.end.row;
1460
if (range.isMultiLine()) {
1461
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
1462
var lastFullRow = lastRow - 1;
1464
if (range.end.column > 0)
1465
this.removeInLine(lastRow, 0, range.end.column);
1467
if (lastFullRow >= firstFullRow)
1468
this.removeLines(firstFullRow, lastFullRow);
1470
if (firstFullRow != firstRow) {
1471
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
1472
this.removeNewLine(range.start.row);
1476
this.removeInLine(firstRow, range.start.column, range.end.column);
1480
this.removeInLine = function(row, startColumn, endColumn) {
1481
if (startColumn == endColumn)
1484
var range = new Range(row, startColumn, row, endColumn);
1485
var line = this.getLine(row);
1486
var removed = line.substring(startColumn, endColumn);
1487
var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
1488
this.$lines.splice(row, 1, newLine);
1491
action: "removeText",
1495
this._emit("change", { data: delta });
1498
this.removeLines = function(firstRow, lastRow) {
1499
var range = new Range(firstRow, 0, lastRow + 1, 0);
1500
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
1503
action: "removeLines",
1505
nl: this.getNewLineCharacter(),
1508
this._emit("change", { data: delta });
1511
this.removeNewLine = function(row) {
1512
var firstLine = this.getLine(row);
1513
var secondLine = this.getLine(row+1);
1515
var range = new Range(row, firstLine.length, row+1, 0);
1516
var line = firstLine + secondLine;
1518
this.$lines.splice(row, 2, line);
1521
action: "removeText",
1523
text: this.getNewLineCharacter()
1525
this._emit("change", { data: delta });
1527
this.replace = function(range, text) {
1528
if (text.length == 0 && range.isEmpty())
1530
if (text == this.getTextRange(range))
1535
var end = this.insert(range.start, text);
1543
this.applyDeltas = function(deltas) {
1544
for (var i=0; i<deltas.length; i++) {
1545
var delta = deltas[i];
1546
var range = Range.fromPoints(delta.range.start, delta.range.end);
1548
if (delta.action == "insertLines")
1549
this.insertLines(range.start.row, delta.lines);
1550
else if (delta.action == "insertText")
1551
this.insert(range.start, delta.text);
1552
else if (delta.action == "removeLines")
1553
this.removeLines(range.start.row, range.end.row - 1);
1554
else if (delta.action == "removeText")
1558
this.revertDeltas = function(deltas) {
1559
for (var i=deltas.length-1; i>=0; i--) {
1560
var delta = deltas[i];
1562
var range = Range.fromPoints(delta.range.start, delta.range.end);
1564
if (delta.action == "insertLines")
1565
this.removeLines(range.start.row, range.end.row - 1);
1566
else if (delta.action == "insertText")
1568
else if (delta.action == "removeLines")
1569
this.insertLines(range.start.row, delta.lines);
1570
else if (delta.action == "removeText")
1571
this.insert(range.start, delta.text);
1574
this.indexToPosition = function(index, startRow) {
1575
var lines = this.$lines || this.getAllLines();
1576
var newlineLength = this.getNewLineCharacter().length;
1577
for (var i = startRow || 0, l = lines.length; i < l; i++) {
1578
index -= lines[i].length + newlineLength;
1580
return {row: i, column: index + lines[i].length + newlineLength};
1582
return {row: l-1, column: lines[l-1].length};
1584
this.positionToIndex = function(pos, startRow) {
1585
var lines = this.$lines || this.getAllLines();
1586
var newlineLength = this.getNewLineCharacter().length;
1588
var row = Math.min(pos.row, lines.length);
1589
for (var i = startRow || 0; i < row; ++i)
1590
index += lines[i].length;
1592
return index + newlineLength * i + pos.column;
1595
}).call(Document.prototype);
1597
exports.Document = Document;
1600
define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
1602
var comparePoints = function(p1, p2) {
1603
return p1.row - p2.row || p1.column - p2.column;
1605
var Range = function(startRow, startColumn, endRow, endColumn) {
1618
this.isEqual = function(range) {
1619
return this.start.row === range.start.row &&
1620
this.end.row === range.end.row &&
1621
this.start.column === range.start.column &&
1622
this.end.column === range.end.column;
1624
this.toString = function() {
1625
return ("Range: [" + this.start.row + "/" + this.start.column +
1626
"] -> [" + this.end.row + "/" + this.end.column + "]");
1629
this.contains = function(row, column) {
1630
return this.compare(row, column) == 0;
1632
this.compareRange = function(range) {
1635
start = range.start;
1637
cmp = this.compare(end.row, end.column);
1639
cmp = this.compare(start.row, start.column);
1642
} else if (cmp == 0) {
1647
} else if (cmp == -1) {
1650
cmp = this.compare(start.row, start.column);
1653
} else if (cmp == 1) {
1660
this.comparePoint = function(p) {
1661
return this.compare(p.row, p.column);
1663
this.containsRange = function(range) {
1664
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
1666
this.intersects = function(range) {
1667
var cmp = this.compareRange(range);
1668
return (cmp == -1 || cmp == 0 || cmp == 1);
1670
this.isEnd = function(row, column) {
1671
return this.end.row == row && this.end.column == column;
1673
this.isStart = function(row, column) {
1674
return this.start.row == row && this.start.column == column;
1676
this.setStart = function(row, column) {
1677
if (typeof row == "object") {
1678
this.start.column = row.column;
1679
this.start.row = row.row;
1681
this.start.row = row;
1682
this.start.column = column;
1685
this.setEnd = function(row, column) {
1686
if (typeof row == "object") {
1687
this.end.column = row.column;
1688
this.end.row = row.row;
1691
this.end.column = column;
1694
this.inside = function(row, column) {
1695
if (this.compare(row, column) == 0) {
1696
if (this.isEnd(row, column) || this.isStart(row, column)) {
1704
this.insideStart = function(row, column) {
1705
if (this.compare(row, column) == 0) {
1706
if (this.isEnd(row, column)) {
1714
this.insideEnd = function(row, column) {
1715
if (this.compare(row, column) == 0) {
1716
if (this.isStart(row, column)) {
1724
this.compare = function(row, column) {
1725
if (!this.isMultiLine()) {
1726
if (row === this.start.row) {
1727
return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
1731
if (row < this.start.row)
1734
if (row > this.end.row)
1737
if (this.start.row === row)
1738
return column >= this.start.column ? 0 : -1;
1740
if (this.end.row === row)
1741
return column <= this.end.column ? 0 : 1;
1745
this.compareStart = function(row, column) {
1746
if (this.start.row == row && this.start.column == column) {
1749
return this.compare(row, column);
1752
this.compareEnd = function(row, column) {
1753
if (this.end.row == row && this.end.column == column) {
1756
return this.compare(row, column);
1759
this.compareInside = function(row, column) {
1760
if (this.end.row == row && this.end.column == column) {
1762
} else if (this.start.row == row && this.start.column == column) {
1765
return this.compare(row, column);
1768
this.clipRows = function(firstRow, lastRow) {
1769
if (this.end.row > lastRow)
1770
var end = {row: lastRow + 1, column: 0};
1771
else if (this.end.row < firstRow)
1772
var end = {row: firstRow, column: 0};
1774
if (this.start.row > lastRow)
1775
var start = {row: lastRow + 1, column: 0};
1776
else if (this.start.row < firstRow)
1777
var start = {row: firstRow, column: 0};
1779
return Range.fromPoints(start || this.start, end || this.end);
1781
this.extend = function(row, column) {
1782
var cmp = this.compare(row, column);
1787
var start = {row: row, column: column};
1789
var end = {row: row, column: column};
1791
return Range.fromPoints(start || this.start, end || this.end);
1794
this.isEmpty = function() {
1795
return (this.start.row === this.end.row && this.start.column === this.end.column);
1797
this.isMultiLine = function() {
1798
return (this.start.row !== this.end.row);
1800
this.clone = function() {
1801
return Range.fromPoints(this.start, this.end);
1803
this.collapseRows = function() {
1804
if (this.end.column == 0)
1805
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
1807
return new Range(this.start.row, 0, this.end.row, 0)
1809
this.toScreenRange = function(session) {
1810
var screenPosStart = session.documentToScreenPosition(this.start);
1811
var screenPosEnd = session.documentToScreenPosition(this.end);
1814
screenPosStart.row, screenPosStart.column,
1815
screenPosEnd.row, screenPosEnd.column
1818
this.moveBy = function(row, column) {
1819
this.start.row += row;
1820
this.start.column += column;
1821
this.end.row += row;
1822
this.end.column += column;
1825
}).call(Range.prototype);
1826
Range.fromPoints = function(start, end) {
1827
return new Range(start.row, start.column, end.row, end.column);
1829
Range.comparePoints = comparePoints;
1831
exports.Range = Range;
1834
define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
1837
var oop = require("./lib/oop");
1838
var EventEmitter = require("./lib/event_emitter").EventEmitter;
1840
var Anchor = exports.Anchor = function(doc, row, column) {
1841
this.document = doc;
1843
if (typeof column == "undefined")
1844
this.setPosition(row.row, row.column);
1846
this.setPosition(row, column);
1848
this.$onChange = this.onChange.bind(this);
1849
doc.on("change", this.$onChange);
1854
oop.implement(this, EventEmitter);
1856
this.getPosition = function() {
1857
return this.$clipPositionToDocument(this.row, this.column);
1860
this.getDocument = function() {
1861
return this.document;
1864
this.onChange = function(e) {
1866
var range = delta.range;
1868
if (range.start.row == range.end.row && range.start.row != this.row)
1871
if (range.start.row > this.row)
1874
if (range.start.row == this.row && range.start.column > this.column)
1878
var column = this.column;
1880
if (delta.action === "insertText") {
1881
if (range.start.row === row && range.start.column <= column) {
1882
if (range.start.row === range.end.row) {
1883
column += range.end.column - range.start.column;
1886
column -= range.start.column;
1887
row += range.end.row - range.start.row;
1890
else if (range.start.row !== range.end.row && range.start.row < row) {
1891
row += range.end.row - range.start.row;
1893
} else if (delta.action === "insertLines") {
1894
if (range.start.row <= row) {
1895
row += range.end.row - range.start.row;
1898
else if (delta.action == "removeText") {
1899
if (range.start.row == row && range.start.column < column) {
1900
if (range.end.column >= column)
1901
column = range.start.column;
1903
column = Math.max(0, column - (range.end.column - range.start.column));
1905
} else if (range.start.row !== range.end.row && range.start.row < row) {
1906
if (range.end.row == row) {
1907
column = Math.max(0, column - range.end.column) + range.start.column;
1909
row -= (range.end.row - range.start.row);
1911
else if (range.end.row == row) {
1912
row -= range.end.row - range.start.row;
1913
column = Math.max(0, column - range.end.column) + range.start.column;
1915
} else if (delta.action == "removeLines") {
1916
if (range.start.row <= row) {
1917
if (range.end.row <= row)
1918
row -= range.end.row - range.start.row;
1920
row = range.start.row;
1926
this.setPosition(row, column, true);
1929
this.setPosition = function(row, column, noClip) {
1938
pos = this.$clipPositionToDocument(row, column);
1941
if (this.row == pos.row && this.column == pos.column)
1950
this.column = pos.column;
1951
this._emit("change", {
1957
this.detach = function() {
1958
this.document.removeEventListener("change", this.$onChange);
1960
this.$clipPositionToDocument = function(row, column) {
1963
if (row >= this.document.getLength()) {
1964
pos.row = Math.max(0, this.document.getLength() - 1);
1965
pos.column = this.document.getLine(pos.row).length;
1973
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
1982
}).call(Anchor.prototype);
1986
define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
1989
exports.stringReverse = function(string) {
1990
return string.split("").reverse().join("");
1993
exports.stringRepeat = function (string, count) {
2005
var trimBeginRegexp = /^\s\s*/;
2006
var trimEndRegexp = /\s\s*$/;
2008
exports.stringTrimLeft = function (string) {
2009
return string.replace(trimBeginRegexp, '');
2012
exports.stringTrimRight = function (string) {
2013
return string.replace(trimEndRegexp, '');
2016
exports.copyObject = function(obj) {
2018
for (var key in obj) {
2019
copy[key] = obj[key];
2024
exports.copyArray = function(array){
2026
for (var i=0, l=array.length; i<l; i++) {
2027
if (array[i] && typeof array[i] == "object")
2028
copy[i] = this.copyObject( array[i] );
2035
exports.deepCopy = function (obj) {
2036
if (typeof obj != "object") {
2040
var copy = obj.constructor();
2041
for (var key in obj) {
2042
if (typeof obj[key] == "object") {
2043
copy[key] = this.deepCopy(obj[key]);
2045
copy[key] = obj[key];
2051
exports.arrayToMap = function(arr) {
2053
for (var i=0; i<arr.length; i++) {
2060
exports.createMap = function(props) {
2061
var map = Object.create(null);
2062
for (var i in props) {
2067
exports.arrayRemove = function(array, value) {
2068
for (var i = 0; i <= array.length; i++) {
2069
if (value === array[i]) {
2075
exports.escapeRegExp = function(str) {
2076
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
2079
exports.escapeHTML = function(str) {
2080
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
2083
exports.getMatchOffsets = function(string, regExp) {
2086
string.replace(regExp, function(str) {
2088
offset: arguments[arguments.length-2],
2095
exports.deferredCall = function(fcn) {
2098
var callback = function() {
2103
var deferred = function(timeout) {
2105
timer = setTimeout(callback, timeout || 0);
2109
deferred.schedule = deferred;
2111
deferred.call = function() {
2117
deferred.cancel = function() {
2118
clearTimeout(timer);
2127
exports.delayedCall = function(fcn, defaultTimeout) {
2129
var callback = function() {
2134
var _self = function(timeout) {
2135
timer && clearTimeout(timer);
2136
timer = setTimeout(callback, timeout || defaultTimeout);
2139
_self.delay = _self;
2140
_self.schedule = function(timeout) {
2142
timer = setTimeout(callback, timeout || 0);
2145
_self.call = function() {
2150
_self.cancel = function() {
2151
timer && clearTimeout(timer);
2155
_self.isPending = function() {
2162
define('ace/mode/javascript/jshint', ['require', 'exports', 'module' ], function(require, exports, module) {
2164
var JSHINT = (function () {
2167
var anonname, // The guessed name for anonymous functions.
2185
asi : true, // if automatic semicolon insertion should be tolerated
2186
bitwise : true, // if bitwise operators should not be allowed
2187
boss : true, // if advanced usage of assignments should be allowed
2188
browser : true, // if the standard browser globals should be predefined
2189
camelcase : true, // if identifiers should be required in camel case
2190
couch : true, // if CouchDB globals should be predefined
2191
curly : true, // if curly braces around all blocks should be required
2192
debug : true, // if debugger statements should be allowed
2193
devel : true, // if logging globals should be predefined (console,
2194
dojo : true, // if Dojo Toolkit globals should be predefined
2195
eqeqeq : true, // if === should be required
2196
eqnull : true, // if == null comparisons should be tolerated
2197
es5 : true, // if ES5 syntax should be allowed
2198
esnext : true, // if es.next specific syntax should be allowed
2199
evil : true, // if eval should be allowed
2200
expr : true, // if ExpressionStatement should be allowed as Programs
2201
forin : true, // if for in statements must filter
2202
funcscope : true, // if only function scope should be used for scope tests
2203
globalstrict: true, // if global should be allowed (also
2204
immed : true, // if immediate invocations must be wrapped in parens
2205
iterator : true, // if the `__iterator__` property should be allowed
2206
jquery : true, // if jQuery globals should be predefined
2207
lastsemic : true, // if semicolons may be ommitted for the trailing
2208
latedef : true, // if the use before definition should not be tolerated
2209
laxbreak : true, // if line breaks should not be checked
2210
laxcomma : true, // if line breaks should not be checked around commas
2211
loopfunc : true, // if functions should be allowed to be defined within
2212
mootools : true, // if MooTools globals should be predefined
2213
multistr : true, // allow multiline strings
2214
newcap : true, // if constructor names must be capitalized
2215
noarg : true, // if arguments.caller and arguments.callee should be
2216
node : true, // if the Node.js environment globals should be
2217
noempty : true, // if empty blocks should be disallowed
2218
nonew : true, // if using `new` for side-effects should be disallowed
2219
nonstandard : true, // if non-standard (but widely adopted) globals should
2220
nomen : true, // if names should be checked
2221
onevar : true, // if only one var statement per function should be
2222
onecase : true, // if one case switch statements should be allowed
2223
passfail : true, // if the scan should stop on first error
2224
plusplus : true, // if increment/decrement should not be allowed
2225
proto : true, // if the `__proto__` property should be allowed
2226
prototypejs : true, // if Prototype and Scriptaculous globals should be
2227
regexdash : true, // if unescaped first/last dash (-) inside brackets
2228
regexp : true, // if the . should not be allowed in regexp literals
2229
rhino : true, // if the Rhino environment globals should be predefined
2230
undef : true, // if variables should be declared before used
2231
unused : true, // if variables should be always used
2232
scripturl : true, // if script-targeted URLs should be tolerated
2233
shadow : true, // if variable shadowing should be tolerated
2234
smarttabs : true, // if smarttabs should be tolerated
2235
strict : true, // require the pragma
2236
sub : true, // if all forms of subscript notation are tolerated
2237
supernew : true, // if `new function () { ... };` and `new Object;`
2238
trailing : true, // if trailing whitespace rules apply
2239
validthis : true, // if 'this' inside a non-constructor function is valid.
2240
withstmt : true, // if with statements should be allowed
2241
white : true, // if strict whitespace rules apply
2242
worker : true, // if Web Worker script symbols should be allowed
2243
wsh : true, // if the Windows Scripting Host environment globals
2244
yui : true // YUI variables should be predefined
2251
quotmark : false, //'single'|'double'|true
2253
maxstatements: false, // {int} max statements per function
2254
maxdepth : false, // {int} max nested block depth per function
2255
maxparams : false, // {int} max params per function
2256
maxcomplexity: false // {int} max cyclomatic complexity per function
2276
ArrayBuffer : false,
2277
ArrayBufferView : false,
2280
addEventListener : false,
2281
applicationCache : false,
2285
clearInterval : false,
2286
clearTimeout : false,
2291
defaultStatus : false,
2295
Float32Array : false,
2296
Float64Array : false,
2300
getComputedStyle : false,
2301
HTMLElement : false,
2302
HTMLAnchorElement : false,
2303
HTMLBaseElement : false,
2304
HTMLBlockquoteElement : false,
2305
HTMLBodyElement : false,
2306
HTMLBRElement : false,
2307
HTMLButtonElement : false,
2308
HTMLCanvasElement : false,
2309
HTMLDirectoryElement : false,
2310
HTMLDivElement : false,
2311
HTMLDListElement : false,
2312
HTMLFieldSetElement : false,
2313
HTMLFontElement : false,
2314
HTMLFormElement : false,
2315
HTMLFrameElement : false,
2316
HTMLFrameSetElement : false,
2317
HTMLHeadElement : false,
2318
HTMLHeadingElement : false,
2319
HTMLHRElement : false,
2320
HTMLHtmlElement : false,
2321
HTMLIFrameElement : false,
2322
HTMLImageElement : false,
2323
HTMLInputElement : false,
2324
HTMLIsIndexElement : false,
2325
HTMLLabelElement : false,
2326
HTMLLayerElement : false,
2327
HTMLLegendElement : false,
2328
HTMLLIElement : false,
2329
HTMLLinkElement : false,
2330
HTMLMapElement : false,
2331
HTMLMenuElement : false,
2332
HTMLMetaElement : false,
2333
HTMLModElement : false,
2334
HTMLObjectElement : false,
2335
HTMLOListElement : false,
2336
HTMLOptGroupElement : false,
2337
HTMLOptionElement : false,
2338
HTMLParagraphElement : false,
2339
HTMLParamElement : false,
2340
HTMLPreElement : false,
2341
HTMLQuoteElement : false,
2342
HTMLScriptElement : false,
2343
HTMLSelectElement : false,
2344
HTMLStyleElement : false,
2345
HTMLTableCaptionElement : false,
2346
HTMLTableCellElement : false,
2347
HTMLTableColElement : false,
2348
HTMLTableElement : false,
2349
HTMLTableRowElement : false,
2350
HTMLTableSectionElement : false,
2351
HTMLTextAreaElement : false,
2352
HTMLTitleElement : false,
2353
HTMLUListElement : false,
2354
HTMLVideoElement : false,
2361
localStorage : false,
2363
MessageChannel : false,
2364
MessageEvent : false,
2365
MessagePort : false,
2368
MutationObserver : false,
2373
onbeforeunload : true,
2381
openDatabase : false,
2386
removeEventListener : false,
2393
sessionStorage : false,
2394
setInterval : false,
2396
SharedWorker : false,
2399
Uint16Array : false,
2400
Uint32Array : false,
2405
XMLHttpRequest : false,
2406
XMLSerializer : false,
2407
XPathEvaluator : false,
2408
XPathException : false,
2409
XPathExpression : false,
2410
XPathNamespace : false,
2411
XPathNSResolver : false,
2429
declared, // Globals that were declared using /*global ... */ syntax.
2448
funct, // The current function
2451
"closure", "exception", "global", "label",
2452
"outer", "unused", "var"
2455
functions, // All of the functions
2457
global, // The global scope
2458
implied, // Implied globals
2498
InputValidator : false,
2528
exports : true, // In Node it is ok to exports = module.exports = foo();
2535
clearTimeout : false,
2536
setInterval : false,
2537
clearInterval : false
2542
predefined, // Global variables defined by option
2554
"$continue" : false,
2566
ObjectRange : false,
2567
PeriodicalExecuter: false,
2574
Autocompleter : false,
2582
SortableObserver : false,
2584
Scriptaculous : false
2590
defineClass : false,
2591
deserialize : false,
2594
importPackage: false,
2611
scope, // The current scope
2618
decodeURIComponent : false,
2620
encodeURIComponent : false,
2625
hasOwnProperty : false,
2637
ReferenceError : false,
2641
SyntaxError : false,
2661
importScripts : true,
2667
ActiveXObject : true,
2670
ScriptEngine : true,
2671
ScriptEngineBuildVersion : true,
2672
ScriptEngineMajorVersion : true,
2673
ScriptEngineMinorVersion : true,
2677
XDomainRequest : true
2685
var ax, cx, tx, nx, nxg, lx, ix, jx, ft;
2687
ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i;
2688
cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
2689
tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/=(?!(\S*\/[gim]?))|\/(\*(jshint|jslint|members?|global)?|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;
2690
nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
2691
nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
2693
ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
2694
jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
2695
ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
2698
function F() {} // Used by Object.create
2700
function is_own(object, name) {
2701
return Object.prototype.hasOwnProperty.call(object, name);
2704
function checkOption(name, t) {
2705
if (valOptions[name] === undefined && boolOptions[name] === undefined) {
2706
warning("Bad option: '" + name + "'.", t);
2710
function isString(obj) {
2711
return Object.prototype.toString.call(obj) === "[object String]";
2714
if (typeof Array.isArray !== "function") {
2715
Array.isArray = function (o) {
2716
return Object.prototype.toString.apply(o) === "[object Array]";
2720
if (!Array.prototype.forEach) {
2721
Array.prototype.forEach = function (fn, scope) {
2722
var len = this.length;
2724
for (var i = 0; i < len; i++) {
2725
fn.call(scope || this, this[i], i, this);
2730
if (!Array.prototype.indexOf) {
2731
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
2732
if (this === null || this === undefined) {
2733
throw new TypeError();
2736
var t = new Object(this);
2737
var len = t.length >>> 0;
2744
if (arguments.length > 0) {
2745
n = Number(arguments[1]);
2746
if (n != n) { // shortcut for verifying if it's NaN
2748
} else if (n !== 0 && n != Infinity && n != -Infinity) {
2749
n = (n > 0 || -1) * Math.floor(Math.abs(n));
2757
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
2758
for (; k < len; k++) {
2759
if (k in t && t[k] === searchElement) {
2768
if (typeof Object.create !== "function") {
2769
Object.create = function (o) {
2775
if (typeof Object.keys !== "function") {
2776
Object.keys = function (o) {
2787
function isAlpha(str) {
2788
return (str >= "a" && str <= "z\uffff") ||
2789
(str >= "A" && str <= "Z\uffff");
2792
function isDigit(str) {
2793
return (str >= "0" && str <= "9");
2796
function isIdentifier(token, value) {
2800
if (!token.identifier || token.value !== value)
2806
function supplant(str, data) {
2807
return str.replace(/\{([^{}]*)\}/g, function (a, b) {
2809
return typeof r === "string" || typeof r === "number" ? r : a;
2813
function combine(t, o) {
2816
if (is_own(o, n) && !is_own(JSHINT.blacklist, n)) {
2822
function updatePredefined() {
2823
Object.keys(JSHINT.blacklist).forEach(function (key) {
2824
delete predefined[key];
2830
combine(predefined, couch);
2834
combine(predefined, rhino);
2837
if (option.prototypejs) {
2838
combine(predefined, prototypejs);
2842
combine(predefined, node);
2843
option.globalstrict = true;
2847
combine(predefined, devel);
2851
combine(predefined, dojo);
2854
if (option.browser) {
2855
combine(predefined, browser);
2858
if (option.nonstandard) {
2859
combine(predefined, nonstandard);
2862
if (option.jquery) {
2863
combine(predefined, jquery);
2866
if (option.mootools) {
2867
combine(predefined, mootools);
2870
if (option.worker) {
2871
combine(predefined, worker);
2875
combine(predefined, wsh);
2878
if (option.esnext) {
2882
if (option.globalstrict && option.strict !== false) {
2883
option.strict = true;
2887
combine(predefined, yui);
2890
function quit(message, line, chr) {
2891
var percentage = Math.floor((line / lines.length) * 100);
2894
name: "JSHintError",
2897
message: message + " (" + percentage + "% scanned).",
2902
function isundef(scope, m, t, a) {
2903
return JSHINT.undefs.push([scope, m, t, a]);
2906
function warning(m, t, a, b, c, d) {
2909
if (t.id === "(end)") { // `~
2917
evidence: lines[l - 1] || "",
2920
scope: JSHINT.scope,
2926
w.reason = supplant(m, w);
2927
JSHINT.errors.push(w);
2928
if (option.passfail) {
2929
quit("Stopping. ", l, ch);
2932
if (warnings >= option.maxerr) {
2933
quit("Too many errors.", l, ch);
2938
function warningAt(m, l, ch, a, b, c, d) {
2945
function error(m, t, a, b, c, d) {
2946
warning(m, t, a, b, c, d);
2949
function errorAt(m, l, ch, a, b, c, d) {
2955
function addInternalSrc(elem, src) {
2962
JSHINT.internals.push(i);
2966
var lex = (function lex() {
2967
var character, from, line, s;
2969
function nextLine() {
2972
tw; // trailing whitespace check
2974
if (line >= lines.length)
2980
if (option.smarttabs) {
2981
match = s.match(/(\/\/)? \t/);
2982
at = match && !match[1] ? 0 : -1;
2984
at = s.search(/ \t|\t [^\*]/);
2988
warningAt("Mixed spaces and tabs.", line, at + 1);
2990
s = s.replace(/\t/g, tab);
2994
warningAt("Unsafe character.", line, at);
2996
if (option.maxlen && option.maxlen < s.length)
2997
warningAt("Line too long.", line, s.length);
2998
tw = option.trailing && s.match(/^(.*?)\s+$/);
2999
if (tw && !/^\s+$/.test(s)) {
3000
warningAt("Trailing whitespace.", line, tw[1].length + 1);
3005
function it(type, value) {
3008
function checkName(name) {
3009
if (!option.proto && name === "__proto__") {
3010
warningAt("The '{a}' property is deprecated.", line, from, name);
3014
if (!option.iterator && name === "__iterator__") {
3015
warningAt("'{a}' is only available in JavaScript 1.7.", line, from, name);
3019
var hasDangling = /^(_+.*|.*_+)$/.test(name);
3021
if (option.nomen && hasDangling && name !== "_") {
3022
if (option.node && token.id !== "." && /^(__dirname|__filename)$/.test(name))
3025
warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", name);
3029
if (option.camelcase) {
3030
if (name.replace(/^_+/, "").indexOf("_") > -1 && !name.match(/^[A-Z0-9_]*$/)) {
3031
warningAt("Identifier '{a}' is not in camel case.", line, from, value);
3036
if (type === "(color)" || type === "(range)") {
3038
} else if (type === "(punctuator)" ||
3039
(type === "(identifier)" && is_own(syntax, value))) {
3040
t = syntax[value] || syntax["(error)"];
3045
t = Object.create(t);
3047
if (type === "(string)" || type === "(range)") {
3048
if (!option.scripturl && jx.test(value)) {
3049
warningAt("Script URL.", line, from);
3053
if (type === "(identifier)") {
3054
t.identifier = true;
3060
t.character = character;
3063
if (i !== "(endline)") {
3065
(("(,=:[!&|?{};".indexOf(i.charAt(i.length - 1)) >= 0) ||
3072
init: function (source) {
3073
if (typeof source === "string") {
3075
.replace(/\r\n/g, "\n")
3076
.replace(/\r/g, "\n")
3081
if (lines[0] && lines[0].substr(0, 2) === "#!")
3089
range: function (begin, end) {
3092
if (s.charAt(0) !== begin) {
3093
errorAt("Expected '{a}' and instead saw '{b}'.",
3094
line, character, begin, s.charAt(0));
3102
errorAt("Missing '{a}'.", line, character, c);
3107
return it("(range)", value);
3109
warningAt("Unexpected '{a}'.", line, character, c);
3115
token: function () {
3116
var b, c, captures, d, depth, high, i, l, low, q, t, isLiteral, isInRange, n;
3119
var r = x.exec(s), r1;
3126
from = character + l - r1.length;
3132
function string(x) {
3133
var c, j, r = "", allowNewLine = false;
3135
if (jsonmode && x !== "\"") {
3136
warningAt("Strings must use doublequote.",
3140
if (option.quotmark) {
3141
if (option.quotmark === "single" && x !== "'") {
3142
warningAt("Strings must use singlequote.",
3144
} else if (option.quotmark === "double" && x !== "\"") {
3145
warningAt("Strings must use doublequote.",
3147
} else if (option.quotmark === true) {
3148
quotmark = quotmark || x;
3149
if (quotmark !== x) {
3150
warningAt("Mixed double and single quotes.",
3157
var i = parseInt(s.substr(j + 1, n), 16);
3159
if (i >= 32 && i <= 126 &&
3160
i !== 34 && i !== 92 && i !== 39) {
3161
warningAt("Unnecessary escapement.", line, character);
3164
c = String.fromCharCode(i);
3171
while (j >= s.length) {
3174
var cl = line, cf = from;
3176
errorAt("Unclosed string.", cl, cf);
3177
break unclosedString;
3181
allowNewLine = false;
3183
warningAt("Unclosed string.", cl, cf);
3190
s = s.substr(j + 1);
3191
return it("(string)", r, x);
3195
if (c === "\n" || c === "\r") {
3198
warningAt("Control character in string: {a}.",
3199
line, character + j, s.slice(0, j));
3200
} else if (c === "\\") {
3204
n = s.charAt(j + 1);
3212
warningAt("Avoid \\'.", line, character);
3232
if (n >= 0 && n <= 7 && directive["use strict"]) {
3234
"Octal literals are not allowed in strict mode.",
3243
warningAt("Avoid \\v.", line, character);
3249
warningAt("Avoid \\x-.", line, character);
3254
allowNewLine = true;
3255
if (option.multistr) {
3257
warningAt("Avoid EOL escapement.", line, character);
3263
warningAt("Bad escapement of EOL. Use option multistr if needed.",
3267
if (s.charAt(j - 2) === "<")
3270
warningAt("Bad escapement.", line, character);
3281
return it(nextLine() ? "(endline)" : "(end)", "");
3289
while (s && s < "!") {
3293
errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
3298
if (isAlpha(c) || c === "_" || c === "$") {
3299
return it("(identifier)", t);
3303
if (!isFinite(Number(t))) {
3304
warningAt("Bad number '{a}'.",
3305
line, character, t);
3307
if (isAlpha(s.substr(0, 1))) {
3308
warningAt("Missing space after '{a}'.",
3309
line, character, t);
3314
if (token.id !== ".") {
3315
warningAt("Don't use extra leading zeros '{a}'.",
3316
line, character, t);
3318
} else if (jsonmode && (d === "x" || d === "X")) {
3319
warningAt("Avoid 0x-. '{a}'.",
3320
line, character, t);
3323
if (t.substr(t.length - 1) === ".") {
3325
"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
3327
return it("(number)", t);
3337
token.comment = true;
3347
errorAt("Unclosed comment.", line, character);
3350
s = s.substr(i + 2);
3351
token.comment = true;
3364
character: character,
3371
if (s.charAt(0) === "=") {
3372
errorAt("A regular expression literal can be confused with '/='.",
3386
errorAt("Unclosed regular expression.", line, from);
3387
return quit("Stopping.", line, from);
3390
warningAt("{a} unterminated regular expression " +
3391
"group(s).", line, from + l, depth);
3393
c = s.substr(0, l - 1);
3399
while (q[s.charAt(l)] === true) {
3400
q[s.charAt(l)] = false;
3406
if (q === "/" || q === "*") {
3407
errorAt("Confusing regular expression.",
3410
return it("(regexp)", c);
3415
"Unexpected control character in regular expression.", line, from + l);
3416
} else if (c === "<") {
3418
"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
3425
if (s.charAt(l) === "?") {
3427
switch (s.charAt(l)) {
3435
"Expected '{a}' and instead saw '{b}'.", line, from + l, ":", s.charAt(l));
3446
warningAt("Unescaped '{a}'.",
3447
line, from + l, ")");
3454
while (s.charAt(l) === " ") {
3460
"Spaces are hard to count. Use {{a}}.", line, from + l, q);
3467
if (s.charAt(l) === "]") {
3468
errorAt("Unescaped '{a}'.",
3469
line, from + l, "^");
3473
warningAt("Empty class.", line,
3485
warningAt("Unescaped '{a}'.",
3494
if (isLiteral && !isInRange) {
3497
} else if (isInRange) {
3499
} else if (s.charAt(l) === "]") {
3502
if (option.regexdash !== (l === 2 || (l === 3 &&
3503
s.charAt(1) === "^"))) {
3504
warningAt("Unescaped '{a}'.",
3505
line, from + l - 1, "-");
3511
if (isInRange && !option.regexdash) {
3512
warningAt("Unescaped '{a}'.",
3513
line, from + l - 1, "-");
3520
"Unexpected control character in regular expression.", line, from + l);
3521
} else if (c === "<") {
3523
"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
3526
if (/[wsd]/i.test(c)) {
3528
warningAt("Unescaped '{a}'.",
3529
line, from + l, "-");
3533
} else if (isInRange) {
3540
warningAt("Unescaped '{a}'.",
3541
line, from + l - 1, "/");
3566
if (option.regexp) {
3567
warningAt("Insecure '{a}'.", line,
3577
warningAt("Unescaped '{a}'.", line,
3581
switch (s.charAt(l)) {
3586
if (s.charAt(l) === "?") {
3593
if (c < "0" || c > "9") {
3595
"Expected a number and instead saw '{a}'.", line, from + l, c);
3596
break; // No reason to continue checking numbers.
3602
if (c < "0" || c > "9") {
3606
low = +c + (low * 10);
3613
if (c >= "0" && c <= "9") {
3618
if (c < "0" || c > "9") {
3622
high = +c + (high * 10);
3626
if (s.charAt(l) !== "}") {
3628
"Expected '{a}' and instead saw '{b}'.", line, from + l, "}", c);
3632
if (s.charAt(l) === "?") {
3637
"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
3642
c = s.substr(0, l - 1);
3645
return it("(regexp)", c);
3647
return it("(punctuator)", t);
3650
return it("(punctuator)", t);
3652
return it("(punctuator)", t);
3661
function addlabel(t, type, token) {
3662
if (t === "hasOwnProperty") {
3663
warning("'hasOwnProperty' is a really bad name.");
3665
if (type === "exception") {
3666
if (is_own(funct["(context)"], t)) {
3667
if (funct[t] !== true && !option.node) {
3668
warning("Value of '{a}' may be overwritten in IE.", nexttoken, t);
3673
if (is_own(funct, t) && !funct["(global)"]) {
3674
if (funct[t] === true) {
3676
warning("'{a}' was used before it was defined.", nexttoken, t);
3678
if (!option.shadow && type !== "exception") {
3679
warning("'{a}' is already defined.", nexttoken, t);
3687
funct["(tokens)"][t] = token;
3690
if (funct["(global)"]) {
3692
if (is_own(implied, t)) {
3694
warning("'{a}' was used before it was defined.", nexttoken, t);
3703
function doOption() {
3706
var quotmarkValue = option.quotmark;
3708
var b, obj, filter, t, tn, v, minus;
3712
error("Unbegun comment.");
3721
option.quotmark = false;
3726
filter = boolOptions;
3741
if (t.type === "special" && t.value === "*/") {
3742
breakOuterLoop = true;
3745
if (t.id !== "(endline)" && t.id !== ",") {
3753
if (o === "/*global" && t.value === "-") {
3758
if (t.type !== "(string)" && t.type !== "(identifier)" && o !== "/*members") {
3759
error("Bad option.", t);
3766
if (obj === membersOnly) {
3767
error("Expected '{a}' and instead saw '{b}'.", t, "*/", ":");
3770
if (o === "/*jshint") {
3771
checkOption(t.value, t);
3784
if (numericVals.indexOf(t.value) > -1 && (o === "/*jshint" || o === "/*jslint")) {
3787
if (typeof b !== "number" || !isFinite(b) || b <= 0 || Math.floor(b) !== b) {
3788
error("Expected a small integer and instead saw '{a}'.", v, v.value);
3791
if (t.value === "indent")
3795
} else if (t.value === "validthis") {
3796
if (funct["(global)"]) {
3797
error("Option 'validthis' can't be used in a global scope.");
3799
if (v.value === "true" || v.value === "false")
3800
obj[t.value] = v.value === "true";
3802
error("Bad option value.", v);
3804
} else if (t.value === "quotmark" && (o === "/*jshint")) {
3807
obj.quotmark = true;
3810
obj.quotmark = false;
3814
obj.quotmark = v.value;
3817
error("Bad option value.", v);
3819
} else if (v.value === "true" || v.value === "false") {
3820
if (o === "/*jslint") {
3821
tn = renamedOptions[t.value] || t.value;
3822
obj[tn] = v.value === "true";
3823
if (invertedOptions[tn] !== undefined) {
3827
obj[t.value] = v.value === "true";
3830
if (t.value === "newcap")
3831
obj["(explicitNewcap)"] = true;
3833
error("Bad option value.", v);
3837
if (o === "/*jshint" || o === "/*jslint") {
3838
error("Missing option value.", t);
3841
obj[t.value] = false;
3843
if (o === "/*global" && minus === true) {
3844
JSHINT.blacklist[t.value] = t.value;
3852
if (o === "/*members") {
3853
option.quotmark = quotmarkValue;
3856
combine(predefined, predef);
3858
for (var key in predef) {
3859
if (is_own(predef, key)) {
3870
var i = p || 0, j = 0, t;
3875
t = lookahead[j] = lex.token();
3882
function advance(id, t) {
3885
if (nexttoken.id === ".") {
3886
warning("A dot following a number can be confused with a decimal point.", token);
3890
if (nexttoken.id === "-" || nexttoken.id === "--") {
3891
warning("Confusing minusses.");
3895
if (nexttoken.id === "+" || nexttoken.id === "++") {
3896
warning("Confusing plusses.");
3901
if (token.type === "(string)" || token.identifier) {
3902
anonname = token.value;
3905
if (id && nexttoken.id !== id) {
3907
if (nexttoken.id === "(end)") {
3908
warning("Unmatched '{a}'.", t, t.id);
3910
warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
3911
nexttoken, id, t.id, t.line, nexttoken.value);
3913
} else if (nexttoken.type !== "(identifier)" ||
3914
nexttoken.value !== id) {
3915
warning("Expected '{a}' and instead saw '{b}'.",
3916
nexttoken, id, nexttoken.value);
3923
nexttoken = lookahead.shift() || lex.token();
3924
if (nexttoken.id === "(end)" || nexttoken.id === "(error)") {
3927
if (nexttoken.type === "special") {
3930
if (nexttoken.id !== "(endline)") {
3937
function expression(rbp, initial) {
3938
var left, isArray = false, isObject = false;
3940
if (nexttoken.id === "(end)")
3941
error("Unexpected early end of program.", token);
3945
anonname = "anonymous";
3946
funct["(verb)"] = token.value;
3948
if (initial === true && token.fud) {
3954
if (nexttoken.type === "(number)" && token.id === ".") {
3955
warning("A leading decimal point can be confused with a dot: '.{a}'.",
3956
token, nexttoken.value);
3960
error("Expected an identifier and instead saw '{a}'.",
3964
while (rbp < nexttoken.lbp) {
3965
isArray = token.value === "Array";
3966
isObject = token.value === "Object";
3967
if (left && (left.value || (left.first && left.first.value))) {
3968
if (left.value !== "new" ||
3969
(left.first && left.first.value && left.first.value === ".")) {
3971
if (left.value !== token.value) {
3978
if (isArray && token.id === "(" && nexttoken.id === ")")
3979
warning("Use the array literal notation [].", token);
3980
if (isObject && token.id === "(" && nexttoken.id === ")")
3981
warning("Use the object literal notation {}.", token);
3983
left = token.led(left);
3985
error("Expected an operator and instead saw '{a}'.",
3993
function adjacent(left, right) {
3994
left = left || token;
3995
right = right || nexttoken;
3997
if (left.character !== right.from && left.line === right.line) {
3998
left.from += (left.character - left.from);
3999
warning("Unexpected space after '{a}'.", left, left.value);
4004
function nobreak(left, right) {
4005
left = left || token;
4006
right = right || nexttoken;
4007
if (option.white && (left.character !== right.from || left.line !== right.line)) {
4008
warning("Unexpected space before '{a}'.", right, right.value);
4012
function nospace(left, right) {
4013
left = left || token;
4014
right = right || nexttoken;
4015
if (option.white && !left.comment) {
4016
if (left.line === right.line) {
4017
adjacent(left, right);
4022
function nonadjacent(left, right) {
4024
left = left || token;
4025
right = right || nexttoken;
4026
if (left.value === ";" && right.value === ";") {
4029
if (left.line === right.line && left.character === right.from) {
4030
left.from += (left.character - left.from);
4031
warning("Missing space after '{a}'.",
4037
function nobreaknonadjacent(left, right) {
4038
left = left || token;
4039
right = right || nexttoken;
4040
if (!option.laxbreak && left.line !== right.line) {
4041
warning("Bad line breaking before '{a}'.", right, right.id);
4042
} else if (option.white) {
4043
left = left || token;
4044
right = right || nexttoken;
4045
if (left.character === right.from) {
4046
left.from += (left.character - left.from);
4047
warning("Missing space after '{a}'.",
4053
function indentation(bias) {
4055
if (option.white && nexttoken.id !== "(end)") {
4056
i = indent + (bias || 0);
4057
if (nexttoken.from !== i) {
4059
"Expected '{a}' to have an indentation at {b} instead at {c}.",
4060
nexttoken, nexttoken.value, i, nexttoken.from);
4065
function nolinebreak(t) {
4067
if (t.line !== nexttoken.line) {
4068
warning("Line breaking error '{a}'.", t, t.value);
4074
if (token.line !== nexttoken.line) {
4075
if (!option.laxcomma) {
4077
warning("Comma warnings can be turned off with 'laxcomma'");
4078
comma.first = false;
4080
warning("Bad line breaking before '{a}'.", token, nexttoken.id);
4082
} else if (!token.comment && token.character !== nexttoken.from && option.white) {
4083
token.from += (token.character - token.from);
4084
warning("Unexpected space after '{a}'.", token, token.value);
4087
nonadjacent(token, nexttoken);
4090
function symbol(s, p) {
4092
if (!x || typeof x !== "object") {
4104
return symbol(s, 0);
4108
function stmt(s, f) {
4110
x.identifier = x.reserved = true;
4116
function blockstmt(s, f) {
4123
function reserveName(x) {
4124
var c = x.id.charAt(0);
4125
if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
4126
x.identifier = x.reserved = true;
4132
function prefix(s, f) {
4133
var x = symbol(s, 150);
4135
x.nud = (typeof f === "function") ? f : function () {
4136
this.right = expression(150);
4137
this.arity = "unary";
4138
if (this.id === "++" || this.id === "--") {
4139
if (option.plusplus) {
4140
warning("Unexpected use of '{a}'.", this, this.id);
4141
} else if ((!this.right.identifier || this.right.reserved) &&
4142
this.right.id !== "." && this.right.id !== "[") {
4143
warning("Bad operand.", this);
4152
function type(s, f) {
4160
function reserve(s, f) {
4162
x.identifier = x.reserved = true;
4167
function reservevar(s, v) {
4168
return reserve(s, function () {
4169
if (typeof v === "function") {
4177
function infix(s, f, p, w) {
4178
var x = symbol(s, p);
4180
x.led = function (left) {
4182
nobreaknonadjacent(prevtoken, token);
4183
nonadjacent(token, nexttoken);
4185
if (s === "in" && left.id === "!") {
4186
warning("Confusing use of '{a}'.", left, "!");
4188
if (typeof f === "function") {
4189
return f(left, this);
4192
this.right = expression(p);
4200
function relation(s, f) {
4201
var x = symbol(s, 100);
4202
x.led = function (left) {
4203
nobreaknonadjacent(prevtoken, token);
4204
nonadjacent(token, nexttoken);
4205
var right = expression(100);
4207
if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
4208
warning("Use the isNaN function to compare with NaN.", this);
4210
f.apply(this, [left, right]);
4212
if (left.id === "!") {
4213
warning("Confusing use of '{a}'.", left, "!");
4215
if (right.id === "!") {
4216
warning("Confusing use of '{a}'.", right, "!");
4226
function isPoorRelation(node) {
4228
((node.type === "(number)" && +node.value === 0) ||
4229
(node.type === "(string)" && node.value === "") ||
4230
(node.type === "null" && !option.eqnull) ||
4231
node.type === "true" ||
4232
node.type === "false" ||
4233
node.type === "undefined");
4237
function assignop(s) {
4238
symbol(s, 20).exps = true;
4240
return infix(s, function (left, that) {
4243
if (predefined[left.value] === false &&
4244
scope[left.value]["(global)"] === true) {
4245
warning("Read only.", left);
4246
} else if (left["function"]) {
4247
warning("'{a}' is a function.", left, left.value);
4251
if (option.esnext && funct[left.value] === "const") {
4252
warning("Attempting to override '{a}' which is a constant", left, left.value);
4255
if (left.id === "." || left.id === "[") {
4256
if (!left.left || left.left.value === "arguments") {
4257
warning("Bad assignment.", that);
4259
that.right = expression(19);
4261
} else if (left.identifier && !left.reserved) {
4262
if (funct[left.value] === "exception") {
4263
warning("Do not assign to the exception parameter.", left);
4265
that.right = expression(19);
4269
if (left === syntax["function"]) {
4271
"Expected an identifier in an assignment and instead saw a function invocation.",
4276
error("Bad assignment.", that);
4281
function bitwise(s, f, p) {
4282
var x = symbol(s, p);
4284
x.led = (typeof f === "function") ? f : function (left) {
4285
if (option.bitwise) {
4286
warning("Unexpected use of '{a}'.", this, this.id);
4289
this.right = expression(p);
4296
function bitwiseassignop(s) {
4297
symbol(s, 20).exps = true;
4298
return infix(s, function (left, that) {
4299
if (option.bitwise) {
4300
warning("Unexpected use of '{a}'.", that, that.id);
4302
nonadjacent(prevtoken, token);
4303
nonadjacent(token, nexttoken);
4305
if (left.id === "." || left.id === "[" ||
4306
(left.identifier && !left.reserved)) {
4310
if (left === syntax["function"]) {
4312
"Expected an identifier in an assignment, and instead saw a function invocation.",
4317
error("Bad assignment.", that);
4322
function suffix(s) {
4323
var x = symbol(s, 150);
4324
x.led = function (left) {
4325
if (option.plusplus) {
4326
warning("Unexpected use of '{a}'.", this, this.id);
4327
} else if ((!left.identifier || left.reserved) &&
4328
left.id !== "." && left.id !== "[") {
4329
warning("Bad operand.", this);
4336
function optionalidentifier(fnparam) {
4337
if (nexttoken.identifier) {
4339
if (token.reserved && !option.es5) {
4340
if (!fnparam || token.value !== "undefined") {
4341
warning("Expected an identifier and instead saw '{a}' (a reserved word).",
4348
function identifier(fnparam) {
4349
var i = optionalidentifier(fnparam);
4353
if (token.id === "function" && nexttoken.id === "(") {
4354
warning("Missing name in function declaration.");
4356
error("Expected an identifier and instead saw '{a}'.",
4357
nexttoken, nexttoken.value);
4362
function reachable(s) {
4364
if (nexttoken.id !== ";" || noreach) {
4372
if (t.id !== "(endline)") {
4373
if (t.id === "function") {
4374
if (!option.latedef) {
4378
"Inner functions should be listed at the top of the outer function.", t);
4381
warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
4389
function statement(noindent) {
4390
var i = indent, r, s = scope, t = nexttoken;
4397
if (t.identifier && !t.reserved && peek().id === ":") {
4400
scope = Object.create(s);
4401
addlabel(t.value, "label");
4403
if (!nexttoken.labelled && nexttoken.value !== "{") {
4404
warning("Label '{a}' on {b} statement.", nexttoken, t.value, nexttoken.value);
4407
if (jx.test(t.value + ":")) {
4408
warning("Label '{a}' looks like a javascript url.", t, t.value);
4411
nexttoken.label = t.value;
4423
r = expression(0, true);
4426
if (!option.expr && (!r || !r.exps)) {
4427
warning("Expected an assignment or function call and instead saw an expression.",
4429
} else if (option.nonew && r.id === "(" && r.left.id === "new") {
4430
warning("Do not use 'new' for side effects.", t);
4433
if (nexttoken.id === ",") {
4437
if (nexttoken.id !== ";") {
4439
if (!option.lastsemic || nexttoken.id !== "}" ||
4440
nexttoken.line !== token.line) {
4441
warningAt("Missing semicolon.", token.line, token.character);
4445
adjacent(token, nexttoken);
4447
nonadjacent(token, nexttoken);
4457
function statements(startLine) {
4460
while (!nexttoken.reach && nexttoken.id !== "(end)") {
4461
if (nexttoken.id === ";") {
4463
if (!p || p.id !== "(") {
4464
warning("Unnecessary semicolon.");
4468
a.push(statement(startLine === nexttoken.line));
4473
function directives() {
4477
if (nexttoken.id === "(string)") {
4479
if (p.id === "(endline)") {
4484
} while (pn.id === "(endline)");
4486
if (pn.id !== ";") {
4487
if (pn.id !== "(string)" && pn.id !== "(number)" &&
4488
pn.id !== "(regexp)" && pn.identifier !== true &&
4492
warning("Missing semicolon.", nexttoken);
4496
} else if (p.id === "}") {
4497
warning("Missing semicolon.", p);
4498
} else if (p.id !== ";") {
4504
if (directive[token.value]) {
4505
warning("Unnecessary directive \"{a}\".", token, token.value);
4508
if (token.value === "use strict") {
4509
if (!option["(explicitNewcap)"])
4510
option.newcap = true;
4511
option.undef = true;
4513
directive[token.value] = true;
4523
function block(ordinary, stmt, isfunc) {
4526
old_indent = indent,
4535
if (!ordinary || !option.funcscope)
4536
scope = Object.create(scope);
4538
nonadjacent(token, nexttoken);
4541
var metrics = funct["(metrics)"];
4542
metrics.nestedBlockDepth += 1;
4543
metrics.verifyMaxNestedBlockDepthPerFunction();
4545
if (nexttoken.id === "{") {
4548
if (nexttoken.id !== "}") {
4549
indent += option.indent;
4550
while (!ordinary && nexttoken.from > indent) {
4551
indent += option.indent;
4556
for (d in directive) {
4557
if (is_own(directive, d)) {
4558
m[d] = directive[d];
4563
if (option.strict && funct["(context)"]["(global)"]) {
4564
if (!m["use strict"] && !directive["use strict"]) {
4565
warning("Missing \"use strict\" statement.");
4570
a = statements(line);
4572
metrics.statementCount += a.length;
4578
indent -= option.indent;
4579
if (line !== nexttoken.line) {
4582
} else if (line !== nexttoken.line) {
4586
indent = old_indent;
4587
} else if (!ordinary) {
4588
error("Expected '{a}' and instead saw '{b}'.",
4589
nexttoken, "{", nexttoken.value);
4591
if (!stmt || option.curly)
4592
warning("Expected '{a}' and instead saw '{b}'.",
4593
nexttoken, "{", nexttoken.value);
4596
indent += option.indent;
4597
a = [statement(nexttoken.line === token.line)];
4598
indent -= option.indent;
4601
funct["(verb)"] = null;
4602
if (!ordinary || !option.funcscope) scope = s;
4604
if (ordinary && option.noempty && (!a || a.length === 0)) {
4605
warning("Empty block.");
4607
metrics.nestedBlockDepth -= 1;
4612
function countMember(m) {
4613
if (membersOnly && typeof membersOnly[m] !== "boolean") {
4614
warning("Unexpected /*member '{a}'.", token, m);
4616
if (typeof member[m] === "number") {
4624
function note_implied(token) {
4625
var name = token.value, line = token.line, a = implied[name];
4626
if (typeof a === "function") {
4633
} else if (a[a.length - 1] !== line) {
4638
type("(number)", function () {
4642
type("(string)", function () {
4646
syntax["(identifier)"] = {
4647
type: "(identifier)",
4655
if (typeof s === "function") {
4657
} else if (typeof s === "boolean") {
4659
funct = functions[0];
4670
funct[v] = "function";
4671
this["function"] = true;
4674
this["function"] = true;
4677
warning("'{a}' is a statement label.", token, v);
4680
} else if (funct["(global)"]) {
4682
if (option.undef && typeof predefined[v] !== "boolean") {
4683
if (!(anonname === "typeof" || anonname === "delete") ||
4684
(nexttoken && (nexttoken.value === "." || nexttoken.value === "["))) {
4686
isundef(funct, "'{a}' is not defined.", token, v);
4690
note_implied(token);
4698
warning("'{a}' used out of scope.", token, v);
4701
warning("'{a}' is a statement label.", token, v);
4709
} else if (s === null) {
4710
warning("'{a}' is not allowed.", token, v);
4711
note_implied(token);
4712
} else if (typeof s !== "object") {
4714
if (!(anonname === "typeof" || anonname === "delete") ||
4716
(nexttoken.value === "." || nexttoken.value === "["))) {
4718
isundef(funct, "'{a}' is not defined.", token, v);
4722
note_implied(token);
4727
this["function"] = true;
4729
funct[v] = s["(global)"] ? "global" : "outer";
4734
funct[v] = s["(global)"] ? "global" : "outer";
4737
funct[v] = s["(global)"] ? "global" : "outer";
4740
warning("'{a}' is a statement label.", token, v);
4748
error("Expected an operator and instead saw '{a}'.",
4749
nexttoken, nexttoken.value);
4753
type("(regexp)", function () {
4759
delim("(end)").reach = true;
4760
delim("</").reach = true;
4764
delim("(error)").reach = true;
4765
delim("}").reach = true;
4768
delim("\"").reach = true;
4769
delim("'").reach = true;
4771
delim(":").reach = true;
4776
reserve("case").reach = true;
4778
reserve("default").reach = true;
4780
reservevar("arguments", function (x) {
4781
if (directive["use strict"] && funct["(global)"]) {
4782
warning("Strict violation.", x);
4786
reservevar("false");
4787
reservevar("Infinity");
4789
reservevar("this", function (x) {
4790
if (directive["use strict"] && !option.validthis && ((funct["(statement)"] &&
4791
funct["(name)"].charAt(0) > "Z") || funct["(global)"])) {
4792
warning("Possible strict violation.", x);
4796
reservevar("undefined");
4797
assignop("=", "assign", 20);
4798
assignop("+=", "assignadd", 20);
4799
assignop("-=", "assignsub", 20);
4800
assignop("*=", "assignmult", 20);
4801
assignop("/=", "assigndiv", 20).nud = function () {
4802
error("A regular expression literal can be confused with '/='.");
4804
assignop("%=", "assignmod", 20);
4805
bitwiseassignop("&=", "assignbitand", 20);
4806
bitwiseassignop("|=", "assignbitor", 20);
4807
bitwiseassignop("^=", "assignbitxor", 20);
4808
bitwiseassignop("<<=", "assignshiftleft", 20);
4809
bitwiseassignop(">>=", "assignshiftright", 20);
4810
bitwiseassignop(">>>=", "assignshiftrightunsigned", 20);
4811
infix("?", function (left, that) {
4813
that.right = expression(10);
4815
that["else"] = expression(10);
4819
infix("||", "or", 40);
4820
infix("&&", "and", 50);
4821
bitwise("|", "bitor", 70);
4822
bitwise("^", "bitxor", 80);
4823
bitwise("&", "bitand", 90);
4824
relation("==", function (left, right) {
4825
var eqnull = option.eqnull && (left.value === "null" || right.value === "null");
4827
if (!eqnull && option.eqeqeq)
4828
warning("Expected '{a}' and instead saw '{b}'.", this, "===", "==");
4829
else if (isPoorRelation(left))
4830
warning("Use '{a}' to compare with '{b}'.", this, "===", left.value);
4831
else if (isPoorRelation(right))
4832
warning("Use '{a}' to compare with '{b}'.", this, "===", right.value);
4837
relation("!=", function (left, right) {
4838
var eqnull = option.eqnull &&
4839
(left.value === "null" || right.value === "null");
4841
if (!eqnull && option.eqeqeq) {
4842
warning("Expected '{a}' and instead saw '{b}'.",
4844
} else if (isPoorRelation(left)) {
4845
warning("Use '{a}' to compare with '{b}'.",
4846
this, "!==", left.value);
4847
} else if (isPoorRelation(right)) {
4848
warning("Use '{a}' to compare with '{b}'.",
4849
this, "!==", right.value);
4858
bitwise("<<", "shiftleft", 120);
4859
bitwise(">>", "shiftright", 120);
4860
bitwise(">>>", "shiftrightunsigned", 120);
4861
infix("in", "in", 120);
4862
infix("instanceof", "instanceof", 120);
4863
infix("+", function (left, that) {
4864
var right = expression(130);
4865
if (left && right && left.id === "(string)" && right.id === "(string)") {
4866
left.value += right.value;
4867
left.character = right.character;
4868
if (!option.scripturl && jx.test(left.value)) {
4869
warning("JavaScript URL.", left);
4878
prefix("+++", function () {
4879
warning("Confusing pluses.");
4880
this.right = expression(150);
4881
this.arity = "unary";
4884
infix("+++", function (left) {
4885
warning("Confusing pluses.");
4887
this.right = expression(130);
4890
infix("-", "sub", 130);
4892
prefix("---", function () {
4893
warning("Confusing minuses.");
4894
this.right = expression(150);
4895
this.arity = "unary";
4898
infix("---", function (left) {
4899
warning("Confusing minuses.");
4901
this.right = expression(130);
4904
infix("*", "mult", 140);
4905
infix("/", "div", 140);
4906
infix("%", "mod", 140);
4908
suffix("++", "postinc");
4909
prefix("++", "preinc");
4910
syntax["++"].exps = true;
4912
suffix("--", "postdec");
4913
prefix("--", "predec");
4914
syntax["--"].exps = true;
4915
prefix("delete", function () {
4916
var p = expression(0);
4917
if (!p || (p.id !== "." && p.id !== "[")) {
4918
warning("Variables should not be deleted.");
4924
prefix("~", function () {
4925
if (option.bitwise) {
4926
warning("Unexpected '{a}'.", this, "~");
4932
prefix("!", function () {
4933
this.right = expression(150);
4934
this.arity = "unary";
4935
if (bang[this.right.id] === true) {
4936
warning("Confusing use of '{a}'.", this, "!");
4940
prefix("typeof", "typeof");
4941
prefix("new", function () {
4942
var c = expression(155), i;
4943
if (c && c.id !== "function") {
4952
warning("Do not use {a} as a constructor.", prevtoken, c.value);
4956
warning("The Function constructor is eval.");
4963
if (c.id !== "function") {
4964
i = c.value.substr(0, 1);
4965
if (option.newcap && (i < "A" || i > "Z") && !is_own(global, c.value)) {
4966
warning("A constructor name should start with an uppercase letter.",
4972
if (c.id !== "." && c.id !== "[" && c.id !== "(") {
4973
warning("Bad constructor.", token);
4977
if (!option.supernew)
4978
warning("Weird construction. Delete 'new'.", this);
4980
adjacent(token, nexttoken);
4981
if (nexttoken.id !== "(" && !option.supernew) {
4982
warning("Missing '()' invoking a constructor.",
4983
token, token.value);
4988
syntax["new"].exps = true;
4990
prefix("void").exps = true;
4992
infix(".", function (left, that) {
4993
adjacent(prevtoken, token);
4995
var m = identifier();
4996
if (typeof m === "string") {
5001
if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
5003
warning("Avoid arguments.{a}.", left, m);
5004
else if (directive["use strict"])
5005
error("Strict violation.");
5006
} else if (!option.evil && left && left.value === "document" &&
5007
(m === "write" || m === "writeln")) {
5008
warning("document.write can be a form of eval.", left);
5010
if (!option.evil && (m === "eval" || m === "execScript")) {
5011
warning("eval is evil.");
5016
infix("(", function (left, that) {
5017
if (prevtoken.id !== "}" && prevtoken.id !== ")") {
5018
nobreak(prevtoken, token);
5021
if (option.immed && !left.immed && left.id === "function") {
5022
warning("Wrap an immediate function invocation in parentheses " +
5023
"to assist the reader in understanding that the expression " +
5024
"is the result of a function, and not the function itself.");
5029
if (left.type === "(identifier)") {
5030
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
5031
if ("Number String Boolean Date Object".indexOf(left.value) === -1) {
5032
if (left.value === "Math") {
5033
warning("Math is not a function.", left);
5034
} else if (option.newcap) {
5035
warning("Missing 'new' prefix when invoking a constructor.", left);
5041
if (nexttoken.id !== ")") {
5043
p[p.length] = expression(10);
5045
if (nexttoken.id !== ",") {
5052
nospace(prevtoken, token);
5053
if (typeof left === "object") {
5054
if (left.value === "parseInt" && n === 1) {
5055
warning("Missing radix parameter.", token);
5058
if (left.value === "eval" || left.value === "Function" ||
5059
left.value === "execScript") {
5060
warning("eval is evil.", left);
5062
if (p[0] && [0].id === "(string)") {
5063
addInternalSrc(left, p[0].value);
5065
} else if (p[0] && p[0].id === "(string)" &&
5066
(left.value === "setTimeout" ||
5067
left.value === "setInterval")) {
5069
"Implied eval is evil. Pass a function instead of a string.", left);
5070
addInternalSrc(left, p[0].value);
5071
} else if (p[0] && p[0].id === "(string)" &&
5072
left.value === "." &&
5073
left.left.value === "window" &&
5074
(left.right === "setTimeout" ||
5075
left.right === "setInterval")) {
5077
"Implied eval is evil. Pass a function instead of a string.", left);
5078
addInternalSrc(left, p[0].value);
5081
if (!left.identifier && left.id !== "." && left.id !== "[" &&
5082
left.id !== "(" && left.id !== "&&" && left.id !== "||" &&
5084
warning("Bad invocation.", left);
5089
}, 155, true).exps = true;
5091
prefix("(", function () {
5093
if (nexttoken.id === "function") {
5094
nexttoken.immed = true;
5096
var v = expression(0);
5098
nospace(prevtoken, token);
5099
if (option.immed && v.id === "function") {
5100
if (nexttoken.id !== "(" &&
5101
(nexttoken.id !== "." || (peek().value !== "call" && peek().value !== "apply"))) {
5103
"Do not wrap function literals in parens unless they are to be immediately invoked.",
5111
infix("[", function (left, that) {
5112
nobreak(prevtoken, token);
5114
var e = expression(0), s;
5115
if (e && e.type === "(string)") {
5116
if (!option.evil && (e.value === "eval" || e.value === "execScript")) {
5117
warning("eval is evil.", that);
5119
countMember(e.value);
5120
if (!option.sub && ix.test(e.value)) {
5121
s = syntax[e.value];
5122
if (!s || !s.reserved) {
5123
warning("['{a}'] is better written in dot notation.",
5124
prevtoken, e.value);
5129
nospace(prevtoken, token);
5135
prefix("[", function () {
5136
var b = token.line !== nexttoken.line;
5139
indent += option.indent;
5140
if (nexttoken.from === indent + option.indent) {
5141
indent += option.indent;
5144
while (nexttoken.id !== "(end)") {
5145
while (nexttoken.id === ",") {
5147
warning("Extra comma.");
5150
if (nexttoken.id === "]") {
5153
if (b && token.line !== nexttoken.line) {
5156
this.first.push(expression(10));
5157
if (nexttoken.id === ",") {
5159
if (nexttoken.id === "]" && !option.es5) {
5160
warning("Extra comma.", token);
5168
indent -= option.indent;
5176
function property_name() {
5177
var id = optionalidentifier(true);
5179
if (nexttoken.id === "(string)") {
5180
id = nexttoken.value;
5182
} else if (nexttoken.id === "(number)") {
5183
id = nexttoken.value.toString();
5191
function functionparams() {
5192
var next = nexttoken;
5199
if (nexttoken.id === ")") {
5205
ident = identifier(true);
5207
addlabel(ident, "unused", token);
5208
if (nexttoken.id === ",") {
5212
nospace(prevtoken, token);
5219
function doFunction(name, statement) {
5221
var oldOption = option;
5222
var oldScope = scope;
5224
option = Object.create(option);
5225
scope = Object.create(scope);
5228
"(name)" : name || "\"" + anonname + "\"",
5229
"(line)" : nexttoken.line,
5230
"(character)": nexttoken.character,
5231
"(context)" : funct,
5234
"(metrics)" : createMetrics(nexttoken),
5236
"(statement)": statement,
5241
token.funct = funct;
5243
functions.push(funct);
5246
addlabel(name, "function");
5249
funct["(params)"] = functionparams();
5250
funct["(metrics)"].verifyMaxParametersPerFunction(funct["(params)"]);
5252
block(false, false, true);
5254
funct["(metrics)"].verifyMaxStatementsPerFunction();
5255
funct["(metrics)"].verifyMaxComplexityPerFunction();
5259
funct["(last)"] = token.line;
5260
funct["(lastcharacter)"] = token.character;
5261
funct = funct["(context)"];
5266
function createMetrics(functionStartToken) {
5269
nestedBlockDepth: -1,
5271
verifyMaxStatementsPerFunction: function () {
5272
if (option.maxstatements &&
5273
this.statementCount > option.maxstatements) {
5274
var message = "Too many statements per function (" + this.statementCount + ").";
5275
warning(message, functionStartToken);
5279
verifyMaxParametersPerFunction: function (params) {
5280
params = params || [];
5282
if (option.maxparams && params.length > option.maxparams) {
5283
var message = "Too many parameters per function (" + params.length + ").";
5284
warning(message, functionStartToken);
5288
verifyMaxNestedBlockDepthPerFunction: function () {
5289
if (option.maxdepth &&
5290
this.nestedBlockDepth > 0 &&
5291
this.nestedBlockDepth === option.maxdepth + 1) {
5292
var message = "Blocks are nested too deeply (" + this.nestedBlockDepth + ").";
5297
verifyMaxComplexityPerFunction: function () {
5298
var max = option.maxcomplexity;
5299
var cc = this.ComplexityCount;
5300
if (max && cc > max) {
5301
var message = "Cyclomatic complexity is too high per function (" + cc + ").";
5302
warning(message, functionStartToken);
5308
function increaseComplexityCount() {
5309
funct["(metrics)"].ComplexityCount += 1;
5314
x.nud = function () {
5316
var props = {}; // All properties, including accessors
5318
function saveProperty(name, token) {
5319
if (props[name] && is_own(props, name))
5320
warning("Duplicate member '{a}'.", nexttoken, i);
5324
props[name].basic = true;
5325
props[name].basicToken = token;
5328
function saveSetter(name, token) {
5329
if (props[name] && is_own(props, name)) {
5330
if (props[name].basic || props[name].setter)
5331
warning("Duplicate member '{a}'.", nexttoken, i);
5336
props[name].setter = true;
5337
props[name].setterToken = token;
5340
function saveGetter(name) {
5341
if (props[name] && is_own(props, name)) {
5342
if (props[name].basic || props[name].getter)
5343
warning("Duplicate member '{a}'.", nexttoken, i);
5348
props[name].getter = true;
5349
props[name].getterToken = token;
5352
b = token.line !== nexttoken.line;
5354
indent += option.indent;
5355
if (nexttoken.from === indent + option.indent) {
5356
indent += option.indent;
5360
if (nexttoken.id === "}") {
5366
if (nexttoken.value === "get" && peek().id !== ":") {
5369
error("get/set are ES5 features.");
5371
i = property_name();
5373
error("Missing property name.");
5377
adjacent(token, nexttoken);
5381
warning("Unexpected parameter '{a}' in get {b} function.", t, p[0], i);
5383
adjacent(token, nexttoken);
5384
} else if (nexttoken.value === "set" && peek().id !== ":") {
5387
error("get/set are ES5 features.");
5389
i = property_name();
5391
error("Missing property name.");
5393
saveSetter(i, nexttoken);
5395
adjacent(token, nexttoken);
5398
if (!p || p.length !== 1) {
5399
warning("Expected a single parameter in set {a} function.", t, i);
5402
i = property_name();
5403
saveProperty(i, nexttoken);
5404
if (typeof i !== "string") {
5408
nonadjacent(token, nexttoken);
5413
if (nexttoken.id === ",") {
5415
if (nexttoken.id === ",") {
5416
warning("Extra comma.", token);
5417
} else if (nexttoken.id === "}" && !option.es5) {
5418
warning("Extra comma.", token);
5425
indent -= option.indent;
5430
for (var name in props) {
5431
if (is_own(props, name) && props[name].setter && !props[name].getter) {
5432
warning("Setter is defined without getter.", props[name].setterToken);
5438
x.fud = function () {
5439
error("Expected to see a statement and instead saw a block.", token);
5443
useESNextSyntax = function () {
5444
var conststatement = stmt("const", function (prefix) {
5445
var id, name, value;
5449
nonadjacent(token, nexttoken);
5451
if (funct[id] === "const") {
5452
warning("const '" + id + "' has already been declared");
5454
if (funct["(global)"] && predefined[id] === false) {
5455
warning("Redefinition of '{a}'.", token, id);
5457
addlabel(id, "const");
5462
this.first.push(token);
5464
if (nexttoken.id !== "=") {
5466
"'{a}' is initialized to 'undefined'.", token, id);
5469
if (nexttoken.id === "=") {
5470
nonadjacent(token, nexttoken);
5472
nonadjacent(token, nexttoken);
5473
if (nexttoken.id === "undefined") {
5474
warning("It is not necessary to initialize " +
5475
"'{a}' to 'undefined'.", token, id);
5477
if (peek(0).id === "=" && nexttoken.identifier) {
5478
error("Constant {a} was not declared correctly.",
5479
nexttoken, nexttoken.value);
5481
value = expression(0);
5485
if (nexttoken.id !== ",") {
5492
conststatement.exps = true;
5495
var varstatement = stmt("var", function (prefix) {
5496
var id, name, value;
5498
if (funct["(onevar)"] && option.onevar) {
5499
warning("Too many var statements.");
5500
} else if (!funct["(global)"]) {
5501
funct["(onevar)"] = true;
5507
nonadjacent(token, nexttoken);
5510
if (option.esnext && funct[id] === "const") {
5511
warning("const '" + id + "' has already been declared");
5514
if (funct["(global)"] && predefined[id] === false) {
5515
warning("Redefinition of '{a}'.", token, id);
5518
addlabel(id, "unused", token);
5525
this.first.push(token);
5527
if (nexttoken.id === "=") {
5528
nonadjacent(token, nexttoken);
5530
nonadjacent(token, nexttoken);
5531
if (nexttoken.id === "undefined") {
5532
warning("It is not necessary to initialize '{a}' to 'undefined'.", token, id);
5534
if (peek(0).id === "=" && nexttoken.identifier) {
5535
error("Variable {a} was not declared correctly.",
5536
nexttoken, nexttoken.value);
5538
value = expression(0);
5541
if (nexttoken.id !== ",") {
5548
varstatement.exps = true;
5550
blockstmt("function", function () {
5552
warning("Function declarations should not be placed in blocks. " +
5553
"Use a function expression or move the statement to the top of " +
5554
"the outer function.", token);
5557
var i = identifier();
5558
if (option.esnext && funct[i] === "const") {
5559
warning("const '" + i + "' has already been declared");
5561
adjacent(token, nexttoken);
5562
addlabel(i, "unction", token);
5564
doFunction(i, { statement: true });
5565
if (nexttoken.id === "(" && nexttoken.line === token.line) {
5567
"Function declarations are not invocable. Wrap the whole function invocation in parens.");
5572
prefix("function", function () {
5573
var i = optionalidentifier();
5575
adjacent(token, nexttoken);
5577
nonadjacent(token, nexttoken);
5580
if (!option.loopfunc && funct["(loopage)"]) {
5581
warning("Don't make functions within a loop.");
5586
blockstmt("if", function () {
5588
increaseComplexityCount();
5590
nonadjacent(this, t);
5593
if (nexttoken.id === "=") {
5595
warning("Assignment in conditional expression");
5600
nospace(prevtoken, token);
5602
if (nexttoken.id === "else") {
5603
nonadjacent(token, nexttoken);
5605
if (nexttoken.id === "if" || nexttoken.id === "switch") {
5614
blockstmt("try", function () {
5617
function doCatch() {
5618
var oldScope = scope;
5622
nonadjacent(token, nexttoken);
5625
scope = Object.create(oldScope);
5627
e = nexttoken.value;
5628
if (nexttoken.type !== "(identifier)") {
5630
warning("Expected an identifier and instead saw '{a}'.", nexttoken, e);
5637
"(name)" : "(catch)",
5638
"(line)" : nexttoken.line,
5639
"(character)": nexttoken.character,
5640
"(context)" : funct,
5641
"(breakage)" : funct["(breakage)"],
5642
"(loopage)" : funct["(loopage)"],
5644
"(statement)": false,
5645
"(metrics)" : createMetrics(nexttoken),
5651
addlabel(e, "exception");
5654
token.funct = funct;
5655
functions.push(funct);
5661
funct["(last)"] = token.line;
5662
funct["(lastcharacter)"] = token.character;
5663
funct = funct["(context)"];
5668
if (nexttoken.id === "catch") {
5669
increaseComplexityCount();
5674
if (nexttoken.id === "finally") {
5679
error("Expected '{a}' and instead saw '{b}'.",
5680
nexttoken, "catch", nexttoken.value);
5686
blockstmt("while", function () {
5688
funct["(breakage)"] += 1;
5689
funct["(loopage)"] += 1;
5690
increaseComplexityCount();
5692
nonadjacent(this, t);
5695
if (nexttoken.id === "=") {
5697
warning("Assignment in conditional expression");
5702
nospace(prevtoken, token);
5704
funct["(breakage)"] -= 1;
5705
funct["(loopage)"] -= 1;
5709
blockstmt("with", function () {
5711
if (directive["use strict"]) {
5712
error("'with' is not allowed in strict mode.", token);
5713
} else if (!option.withstmt) {
5714
warning("Don't use 'with'.", token);
5718
nonadjacent(this, t);
5722
nospace(prevtoken, token);
5728
blockstmt("switch", function () {
5731
funct["(breakage)"] += 1;
5733
nonadjacent(this, t);
5735
this.condition = expression(20);
5737
nospace(prevtoken, token);
5738
nonadjacent(token, nexttoken);
5741
nonadjacent(token, nexttoken);
5742
indent += option.indent;
5745
switch (nexttoken.id) {
5747
switch (funct["(verb)"]) {
5756
if (!ft.test(lines[nexttoken.line - 2])) {
5758
"Expected a 'break' statement before 'case'.",
5762
indentation(-option.indent);
5764
this.cases.push(expression(20));
5765
increaseComplexityCount();
5768
funct["(verb)"] = "case";
5771
switch (funct["(verb)"]) {
5778
if (!ft.test(lines[nexttoken.line - 2])) {
5780
"Expected a 'break' statement before 'default'.",
5784
indentation(-option.indent);
5790
indent -= option.indent;
5793
if (this.cases.length === 1 || this.condition.id === "true" ||
5794
this.condition.id === "false") {
5795
if (!option.onecase)
5796
warning("This 'switch' should be an 'if'.", this);
5798
funct["(breakage)"] -= 1;
5799
funct["(verb)"] = undefined;
5802
error("Missing '{a}'.", nexttoken, "}");
5808
error("Each value should have its own case label.");
5815
error("Missing ':' on a case clause.", token);
5819
if (token.id === ":") {
5821
error("Unexpected '{a}'.", token, ":");
5824
error("Expected '{a}' and instead saw '{b}'.",
5825
nexttoken, "case", nexttoken.value);
5833
stmt("debugger", function () {
5834
if (!option.debug) {
5835
warning("All 'debugger' statements should be removed.");
5841
var x = stmt("do", function () {
5842
funct["(breakage)"] += 1;
5843
funct["(loopage)"] += 1;
5844
increaseComplexityCount();
5846
this.first = block(true);
5849
nonadjacent(token, t);
5853
if (nexttoken.id === "=") {
5855
warning("Assignment in conditional expression");
5860
nospace(prevtoken, token);
5861
funct["(breakage)"] -= 1;
5862
funct["(loopage)"] -= 1;
5869
blockstmt("for", function () {
5870
var s, t = nexttoken;
5871
funct["(breakage)"] += 1;
5872
funct["(loopage)"] += 1;
5873
increaseComplexityCount();
5875
nonadjacent(this, t);
5877
if (peek(nexttoken.id === "var" ? 1 : 0).id === "in") {
5878
if (nexttoken.id === "var") {
5880
varstatement.fud.call(varstatement, true);
5882
switch (funct[nexttoken.value]) {
5884
funct[nexttoken.value] = "var";
5889
warning("Bad for in variable '{a}'.",
5890
nexttoken, nexttoken.value);
5897
s = block(true, true);
5898
if (option.forin && s && (s.length > 1 || typeof s[0] !== "object" ||
5899
s[0].value !== "if")) {
5900
warning("The body of a for in should be wrapped in an if statement to filter " +
5901
"unwanted properties from the prototype.", this);
5903
funct["(breakage)"] -= 1;
5904
funct["(loopage)"] -= 1;
5907
if (nexttoken.id !== ";") {
5908
if (nexttoken.id === "var") {
5910
varstatement.fud.call(varstatement);
5913
expression(0, "for");
5914
if (nexttoken.id !== ",") {
5923
if (nexttoken.id !== ";") {
5925
if (nexttoken.id === "=") {
5927
warning("Assignment in conditional expression");
5934
if (nexttoken.id === ";") {
5935
error("Expected '{a}' and instead saw '{b}'.",
5936
nexttoken, ")", ";");
5938
if (nexttoken.id !== ")") {
5940
expression(0, "for");
5941
if (nexttoken.id !== ",") {
5948
nospace(prevtoken, token);
5950
funct["(breakage)"] -= 1;
5951
funct["(loopage)"] -= 1;
5957
stmt("break", function () {
5958
var v = nexttoken.value;
5960
if (funct["(breakage)"] === 0)
5961
warning("Unexpected '{a}'.", nexttoken, this.value);
5966
if (nexttoken.id !== ";") {
5967
if (token.line === nexttoken.line) {
5968
if (funct[v] !== "label") {
5969
warning("'{a}' is not a statement label.", nexttoken, v);
5970
} else if (scope[v] !== funct) {
5971
warning("'{a}' is out of scope.", nexttoken, v);
5973
this.first = nexttoken;
5982
stmt("continue", function () {
5983
var v = nexttoken.value;
5985
if (funct["(breakage)"] === 0)
5986
warning("Unexpected '{a}'.", nexttoken, this.value);
5991
if (nexttoken.id !== ";") {
5992
if (token.line === nexttoken.line) {
5993
if (funct[v] !== "label") {
5994
warning("'{a}' is not a statement label.", nexttoken, v);
5995
} else if (scope[v] !== funct) {
5996
warning("'{a}' is out of scope.", nexttoken, v);
5998
this.first = nexttoken;
6001
} else if (!funct["(loopage)"]) {
6002
warning("Unexpected '{a}'.", nexttoken, this.value);
6004
reachable("continue");
6009
stmt("return", function () {
6010
if (this.line === nexttoken.line) {
6011
if (nexttoken.id === "(regexp)")
6012
warning("Wrap the /regexp/ literal in parens to disambiguate the slash operator.");
6014
if (nexttoken.id !== ";" && !nexttoken.reach) {
6015
nonadjacent(token, nexttoken);
6016
if (peek().value === "=" && !option.boss) {
6017
warningAt("Did you mean to return a conditional instead of an assignment?",
6018
token.line, token.character + 1);
6020
this.first = expression(0);
6022
} else if (!option.asi) {
6023
nolinebreak(this); // always warn (Line breaking error)
6025
reachable("return");
6030
stmt("throw", function () {
6032
nonadjacent(token, nexttoken);
6033
this.first = expression(20);
6048
reserve("implements");
6049
reserve("interface");
6052
reserve("protected");
6056
function jsonValue() {
6058
function jsonObject() {
6059
var o = {}, t = nexttoken;
6061
if (nexttoken.id !== "}") {
6063
if (nexttoken.id === "(end)") {
6064
error("Missing '}' to match '{' from line {a}.",
6066
} else if (nexttoken.id === "}") {
6067
warning("Unexpected comma.", token);
6069
} else if (nexttoken.id === ",") {
6070
error("Unexpected comma.", nexttoken);
6071
} else if (nexttoken.id !== "(string)") {
6072
warning("Expected a string and instead saw {a}.",
6073
nexttoken, nexttoken.value);
6075
if (o[nexttoken.value] === true) {
6076
warning("Duplicate key '{a}'.",
6077
nexttoken, nexttoken.value);
6078
} else if ((nexttoken.value === "__proto__" &&
6079
!option.proto) || (nexttoken.value === "__iterator__" &&
6080
!option.iterator)) {
6081
warning("The '{a}' key may produce unexpected results.",
6082
nexttoken, nexttoken.value);
6084
o[nexttoken.value] = true;
6089
if (nexttoken.id !== ",") {
6098
function jsonArray() {
6101
if (nexttoken.id !== "]") {
6103
if (nexttoken.id === "(end)") {
6104
error("Missing ']' to match '[' from line {a}.",
6106
} else if (nexttoken.id === "]") {
6107
warning("Unexpected comma.", token);
6109
} else if (nexttoken.id === ",") {
6110
error("Unexpected comma.", nexttoken);
6113
if (nexttoken.id !== ",") {
6122
switch (nexttoken.id) {
6138
if (token.character !== nexttoken.from) {
6139
warning("Unexpected space after '-'.", token);
6141
adjacent(token, nexttoken);
6142
advance("(number)");
6145
error("Expected a JSON value.", nexttoken);
6148
var itself = function (s, o, g) {
6151
var newOptionObj = {};
6154
JSHINT.scope = o.scope;
6158
JSHINT.internals = [];
6159
JSHINT.blacklist = {};
6160
JSHINT.scope = "(main)";
6163
predefined = Object.create(standard);
6164
declared = Object.create(null);
6165
combine(predefined, g || {});
6170
if (!Array.isArray(a) && typeof a === "object") {
6173
a.forEach(function (item) {
6175
if (item[0] === "-") {
6176
slice = item.slice(1);
6177
JSHINT.blacklist[slice] = slice;
6179
predefined[item] = true;
6184
optionKeys = Object.keys(o);
6185
for (x = 0; x < optionKeys.length; x++) {
6186
newOptionObj[optionKeys[x]] = o[optionKeys[x]];
6188
if (optionKeys[x] === "newcap" && o[optionKeys[x]] === false)
6189
newOptionObj["(explicitNewcap)"] = true;
6191
if (optionKeys[x] === "indent")
6192
newOptionObj.white = true;
6196
option = newOptionObj;
6198
option.indent = option.indent || 4;
6199
option.maxerr = option.maxerr || 50;
6202
for (i = 0; i < option.indent; i += 1) {
6206
global = Object.create(predefined);
6210
"(name)": "(global)",
6215
"(metrics)": createMetrics(nexttoken)
6217
functions = [funct];
6230
if (!isString(s) && !Array.isArray(s)) {
6231
errorAt("Input is neither a string nor an array of strings.", 0);
6235
if (isString(s) && /^\s*$/g.test(s)) {
6236
errorAt("Input is an empty string.", 0);
6240
if (s.length === 0) {
6241
errorAt("Input is an empty array.", 0);
6250
prevtoken = token = nexttoken = syntax["(begin)"];
6251
for (var name in o) {
6252
if (is_own(o, name)) {
6253
checkOption(name, token);
6258
combine(predefined, g || {});
6260
quotmark = undefined;
6264
switch (nexttoken.id) {
6267
option.laxbreak = true;
6273
if (directive["use strict"] && !option.globalstrict) {
6274
warning("Use the function form of \"use strict\".", prevtoken);
6279
advance((nexttoken && nexttoken.value !== ".") ? "(end)" : undefined);
6281
var markDefined = function (name, context) {
6283
if (typeof context[name] === "string") {
6285
if (context[name] === "unused")
6286
context[name] = "var";
6287
else if (context[name] === "unction")
6288
context[name] = "closure";
6293
context = context["(context)"];
6299
var clearImplied = function (name, line) {
6303
var newImplied = [];
6304
for (var i = 0; i < implied[name].length; i += 1) {
6305
if (implied[name][i] !== line)
6306
newImplied.push(implied[name][i]);
6309
if (newImplied.length === 0)
6310
delete implied[name];
6312
implied[name] = newImplied;
6315
var warnUnused = function (name, token) {
6316
var line = token.line;
6317
var chr = token.character;
6320
warningAt("'{a}' is defined but never used.", line, chr, name);
6329
var checkUnused = function (func, key) {
6330
var type = func[key];
6331
var token = func["(tokens)"][key];
6333
if (key.charAt(0) === "(")
6336
if (type !== "unused" && type !== "unction")
6338
if (func["(params)"] && func["(params)"].indexOf(key) !== -1)
6341
warnUnused(key, token);
6343
for (i = 0; i < JSHINT.undefs.length; i += 1) {
6344
k = JSHINT.undefs[i].slice(0);
6346
if (markDefined(k[2].value, k[0])) {
6347
clearImplied(k[2].value, k[2].line);
6349
warning.apply(warning, k.slice(1));
6353
functions.forEach(function (func) {
6354
for (var key in func) {
6355
if (is_own(func, key)) {
6356
checkUnused(func, key);
6360
if (!func["(params)"])
6363
var params = func["(params)"].slice();
6364
var param = params.pop();
6370
if (param === "undefined")
6373
if (type !== "unused" && type !== "unction")
6376
warnUnused(param, func["(tokens)"][param]);
6377
param = params.pop();
6381
for (var key in declared) {
6382
if (is_own(declared, key) && !is_own(global, key)) {
6383
warnUnused(key, declared[key]);
6388
var nt = nexttoken || {};
6389
JSHINT.errors.push({
6392
line : e.line || nt.line,
6393
character : e.character || nt.from
6398
if (JSHINT.scope === "(main)") {
6401
for (i = 0; i < JSHINT.internals.length; i += 1) {
6402
k = JSHINT.internals[i];
6404
itself(k.value, o, g);
6408
return JSHINT.errors.length === 0;
6410
itself.data = function () {
6417
var fu, f, i, j, n, globals;
6419
if (itself.errors.length) {
6420
data.errors = itself.errors;
6427
for (n in implied) {
6428
if (is_own(implied, n)) {
6436
if (implieds.length > 0) {
6437
data.implieds = implieds;
6440
if (urls.length > 0) {
6444
globals = Object.keys(scope);
6445
if (globals.length > 0) {
6446
data.globals = globals;
6449
for (i = 1; i < functions.length; i += 1) {
6453
for (j = 0; j < functionicity.length; j += 1) {
6454
fu[functionicity[j]] = [];
6457
for (j = 0; j < functionicity.length; j += 1) {
6458
if (fu[functionicity[j]].length === 0) {
6459
delete fu[functionicity[j]];
6463
fu.name = f["(name)"];
6464
fu.param = f["(params)"];
6465
fu.line = f["(line)"];
6466
fu.character = f["(character)"];
6467
fu.last = f["(last)"];
6468
fu.lastcharacter = f["(lastcharacter)"];
6469
data.functions.push(fu);
6472
if (unuseds.length > 0) {
6473
data.unused = unuseds;
6478
if (typeof member[n] === "number") {
6479
data.member = member;
6487
itself.jshint = itself;
6491
if (typeof exports === "object" && exports) {
6492
exports.JSHINT = JSHINT;
b'\\ No newline at end of file'