Skip to content

Commit

Permalink
Merge 900adb9 into 02fef82
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Apr 18, 2019
2 parents 02fef82 + 900adb9 commit 31ed47d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/jshint.js
Expand Up @@ -744,6 +744,7 @@ var JSHINT = (function() {
state.option[tn] = !state.option[tn];
}
} else if (directiveToken.type === "jshint.unstable") {
/* istanbul ignore next */
state.option.unstable[key] = (val === "true");
} else {
state.option[key] = (val === "true");
Expand Down Expand Up @@ -1549,6 +1550,7 @@ var JSHINT = (function() {
warning("W121", left, nativeObject);
}
if (checkPunctuator(left, "...")) {
/* istanbul ignore next */
left = left.right;
}

Expand Down Expand Up @@ -1734,6 +1736,7 @@ var JSHINT = (function() {
}

if (val === "undefined") {
/* istanbul ignore next */
return val;
}

Expand Down Expand Up @@ -2258,6 +2261,7 @@ var JSHINT = (function() {
},

led: function() {
/* istanbul ignore next */
error("E033", state.tokens.next, state.tokens.next.value);
}
};
Expand Down Expand Up @@ -2345,6 +2349,7 @@ var JSHINT = (function() {
assignop("-=", "assignsub", 20);
assignop("*=", "assignmult", 20);
assignop("/=", "assigndiv", 20).nud = function() {
/* istanbul ignore next */
error("E014");
};
assignop("%=", "assignmod", 20);
Expand Down Expand Up @@ -2381,6 +2386,7 @@ var JSHINT = (function() {
}
while (true) {
if (!(expr = expression(context, 10))) {
/* istanbul ignore next */
break;
}
that.exprs.push(expr);
Expand Down Expand Up @@ -2441,7 +2447,9 @@ var JSHINT = (function() {
warning("W116", this, "===", "==");
break;
case isTypoTypeof(right, left, state):
/* istanbul ignore next */
warning("W122", this, right.value);
/* istanbul ignore next */
break;
case isTypoTypeof(left, right, state):
warning("W122", this, left.value);
Expand All @@ -2454,6 +2462,7 @@ var JSHINT = (function() {
if (isTypoTypeof(right, left, state)) {
warning("W122", this, right.value);
} else if (isTypoTypeof(left, right, state)) {
/* istanbul ignore next */
warning("W122", this, left.value);
}
return this;
Expand All @@ -2466,6 +2475,7 @@ var JSHINT = (function() {
this.from = this.character;
warning("W116", this, "!==", "!=");
} else if (isTypoTypeof(right, left, state)) {
/* istanbul ignore next */
warning("W122", this, right.value);
} else if (isTypoTypeof(left, right, state)) {
warning("W122", this, left.value);
Expand All @@ -2476,6 +2486,7 @@ var JSHINT = (function() {
if (isTypoTypeof(right, left, state)) {
warning("W122", this, right.value);
} else if (isTypoTypeof(left, right, state)) {
/* istanbul ignore next */
warning("W122", this, left.value);
}
return this;
Expand Down Expand Up @@ -2622,10 +2633,12 @@ var JSHINT = (function() {
this.right = expression(context, 150);

if (!this.right) { // '!' followed by nothing? Give up.
/* istanbul ignore next */
quit("E041", this);
}

if (bang[this.right.id] === true) {
/* istanbul ignore next */
warning("W018", this, "!");
}
return this;
Expand Down Expand Up @@ -2698,6 +2711,7 @@ var JSHINT = (function() {
}
} else {
if (c.id !== "." && c.id !== "[" && c.id !== "(") {
/* istanbul ignore next */
warning("W056", state.tokens.curr);
}
}
Expand Down Expand Up @@ -2804,7 +2818,9 @@ var JSHINT = (function() {
if (state.tokens.next.value === "{") {
advance("{");
} else {
/* istanbul ignore next */
warning("W116", state.tokens.curr, "identifier", state.tokens.next.type); //?
/* istanbul ignore next */
advance();
}

Expand Down Expand Up @@ -2849,6 +2865,7 @@ var JSHINT = (function() {

if ((token.value === "set" || token.value === "get") && !checkPunctuator(peek(), "(")) {
if (inGenerator) {
/* istanbul ignore next */
error("E024", token, token.value);
}
accessorType = token.value;
Expand Down Expand Up @@ -2879,6 +2896,7 @@ var JSHINT = (function() {
if (inGenerator || context & prodParams.preAsync) {
error("E024", token, token.value);
} else if (hasConstructor) {
/* istanbul ignore next */
error("E024", token, token.value);
} else {
hasConstructor = !accessorType && !isStatic;
Expand Down Expand Up @@ -2941,6 +2959,7 @@ var JSHINT = (function() {
identifier(context);
advance();
}
/* istanbul ignore next */
return;
} else {
while (state.tokens.next.value !== "(") {
Expand Down Expand Up @@ -3008,6 +3027,7 @@ var JSHINT = (function() {
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
if (left.value === "Math") {
/* istanbul ignore next */
warning("W063", left);
} else if (state.option.newcap) {
warning("W064", left);
Expand Down Expand Up @@ -3294,6 +3314,7 @@ var JSHINT = (function() {
if (_.includes(["in", "of"], state.tokens.next.value)) {
advance();
} else {
/* istanbul ignore next */
error("E045", state.tokens.curr);
}
state.funct["(comparray)"].setState("generate");
Expand Down Expand Up @@ -3337,6 +3358,7 @@ var JSHINT = (function() {
if (b) {
indent += state.option.indent;
if (state.tokens.next.from === indent + state.option.indent) {
/* istanbul ignore next */
indent += state.option.indent;
}
}
Expand Down Expand Up @@ -3394,6 +3416,7 @@ var JSHINT = (function() {
var id;
var preserve = true;
if (typeof preserveOrToken === "object") {
/* istanbul ignore next */
id = preserveOrToken;
} else {
preserve = preserveOrToken;
Expand All @@ -3413,7 +3436,9 @@ var JSHINT = (function() {
}
}
} else if (typeof id === "object") {
/* istanbul ignore next */
if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
/* istanbul ignore next */
else if (id.id === "(number)") id = id.value.toString();
}

Expand Down Expand Up @@ -3639,6 +3664,7 @@ var JSHINT = (function() {

function end() {
if (state.tokens.curr.template && state.tokens.curr.tail &&
/* istanbul ignore next */
state.tokens.curr.context === ctx) return true;
var complete = (state.tokens.next.template && state.tokens.next.tail &&
state.tokens.next.context === ctx);
Expand Down Expand Up @@ -3906,6 +3932,7 @@ var JSHINT = (function() {
if (b) {
indent += state.option.indent;
if (state.tokens.next.from === indent + state.option.indent) {
/* istanbul ignore next */
indent += state.option.indent;
}
}
Expand Down Expand Up @@ -4038,6 +4065,7 @@ var JSHINT = (function() {
if (state.tokens.next.id === ",") {
parseComma({ allowTrailing: true, property: true });
if (state.tokens.next.id === ",") {
/* istanbul ignore next */
warning("W070", state.tokens.curr);
} else if (state.tokens.next.id === "}" && !state.inES5()) {
warning("W070", state.tokens.curr);
Expand All @@ -4060,6 +4088,7 @@ var JSHINT = (function() {
return this;
};
x.fud = function() {
/* istanbul ignore next */
error("E036", state.tokens.curr);
};
}(delim("{")));
Expand Down Expand Up @@ -4194,6 +4223,7 @@ var JSHINT = (function() {
}
if (!isRest && checkPunctuator(state.tokens.next, "=")) {
if (checkPunctuator(state.tokens.prev, "...")) {
/* istanbul ignore next */
advance("]");
} else {
advance("=");
Expand Down Expand Up @@ -4254,6 +4284,7 @@ var JSHINT = (function() {
if (token && value)
token.first = value;
else if (token && token.first && !value)
/* istanbul ignore next */
warning("W080", token.first, token.first.value);
});
}
Expand Down Expand Up @@ -4307,6 +4338,7 @@ var JSHINT = (function() {
// It is a Syntax Error if the BoundNames of BindingList contains
// "let".
if (t.id === "let") {
/* istanbul ignore next */
warning("W024", t.token, t.id);
}

Expand Down Expand Up @@ -4605,6 +4637,7 @@ var JSHINT = (function() {
}

if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
/* istanbul ignore next */
error("E039");
}
return this;
Expand Down Expand Up @@ -4878,21 +4911,27 @@ var JSHINT = (function() {
state.funct["(verb)"] = undefined;
return;
case "(end)":
/* istanbul ignore next */
error("E023", state.tokens.next, "}");
/* istanbul ignore next */
return;
default:
indent += state.option.indent;
if (g) {
switch (state.tokens.curr.id) {
case ",":
/* istanbul ignore next */
error("E040");
/* istanbul ignore next */
return;
case ":":
g = false;
statements(context);
break;
default:
/* istanbul ignore next */
error("E025", state.tokens.curr);
/* istanbul ignore next */
return;
}
} else {
Expand All @@ -4901,7 +4940,9 @@ var JSHINT = (function() {
error("E024", state.tokens.curr, ":");
statements(context);
} else {
/* istanbul ignore next */
error("E021", state.tokens.next, "case", state.tokens.next.value);
/* istanbul ignore next */
return;
}
}
Expand Down Expand Up @@ -5522,7 +5563,9 @@ var JSHINT = (function() {
advance("}");
break;
} else {
/* istanbul ignore next */
error("E024", state.tokens.next, state.tokens.next.value);
/* istanbul ignore next */
break;
}
}
Expand Down Expand Up @@ -5608,6 +5651,7 @@ var JSHINT = (function() {
var exportedTokens = [];
while (!checkPunctuator(state.tokens.next, "}")) {
if (!state.tokens.next.identifier) {
/* istanbul ignore next */
error("E030", state.tokens.next, state.tokens.next.value);
}
advance();
Expand All @@ -5617,6 +5661,7 @@ var JSHINT = (function() {
if (state.tokens.next.value === "as") {
advance("as");
if (!state.tokens.next.identifier) {
/* istanbul ignore next */
error("E030", state.tokens.next, state.tokens.next.value);
}
advance();
Expand Down Expand Up @@ -5676,6 +5721,7 @@ var JSHINT = (function() {
advance("class");
state.syntax["class"].fud(context);
} else {
/* istanbul ignore next */
error("E024", state.tokens.next, state.tokens.next.value);
}

Expand Down Expand Up @@ -5955,6 +6001,7 @@ var JSHINT = (function() {
var block = lookupBlockType();
if (block.notJson) {
if (!state.inES6() && block.isDestAssign) {
/* istanbul ignore next */
warning("W104", state.tokens.curr, "destructuring assignment", "6");
}
statements(context);
Expand Down Expand Up @@ -6061,10 +6108,12 @@ var JSHINT = (function() {
// we check whether current variable has been declared
if (use(v)) {
// if not we warn about it
/* istanbul ignore next */
state.funct["(scope)"].block.use(v, state.tokens.curr);
}
return true;
}
/* istanbul ignore next */
return false;
}
};
Expand Down Expand Up @@ -6274,6 +6323,7 @@ var JSHINT = (function() {
});

scopeManagerInst.on("error", function(ev) {
/* istanbul ignore next */
error.apply(null, [ ev.code, ev.token ].concat(ev.data));
});

Expand All @@ -6298,6 +6348,7 @@ var JSHINT = (function() {

api = {
get isJSON() {
/* istanbul ignore next */
return state.jsonMode;
},

Expand Down Expand Up @@ -6333,6 +6384,7 @@ var JSHINT = (function() {
if (o && o.ignoreDelimiters) {

if (!Array.isArray(o.ignoreDelimiters)) {
/* istanbul ignore next */
o.ignoreDelimiters = [o.ignoreDelimiters];
}

Expand Down Expand Up @@ -6438,6 +6490,7 @@ var JSHINT = (function() {
character : err.character || nt.from
});
} else {
/* istanbul ignore next */
throw err;
}
}
Expand Down Expand Up @@ -6471,6 +6524,7 @@ var JSHINT = (function() {
}

if (state.jsonMode) {
/* istanbul ignore next */
data.json = true;
}

Expand All @@ -6480,6 +6534,7 @@ var JSHINT = (function() {
}

if (urls.length > 0) {
/* istanbul ignore next */
data.urls = urls;
}

Expand Down Expand Up @@ -6532,3 +6587,4 @@ var JSHINT = (function() {
if (typeof exports === "object" && exports) {
exports.JSHINT = JSHINT;
}

0 comments on commit 31ed47d

Please sign in to comment.