Skip to content

Commit

Permalink
[[CHORE]] Revert parser improvements
Browse files Browse the repository at this point in the history
JSHint's validation for assignment within conditional clauses is derived
from code first contributed by GitHub user "usrbincc." That user could
not be reached to sign JSHint's Contributor License Agreement. Revert
the user's contribution to the application logic (preserving the
corresponding MIT-licensed test code) so that it may be re-written under
the terms of the Contributor License Agreement.

Revert the changes introduced by
b3d054e
  • Loading branch information
jugglinmike authored and rwaldron committed Aug 21, 2019
1 parent d72ce61 commit e63dbc7
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/jshint.js
Expand Up @@ -3171,9 +3171,11 @@ var JSHINT = (function() {
if (!exprs.length) {
return;
}

exprs[exprs.length - 1].parent = true;

if (exprs.length > 1) {
ret = Object.create(state.syntax[","]);
ret.exprs = exprs;
ret = Object.create(state.syntax[","], { exprs: { value: exprs } });

first = exprs[0];
last = exprs[exprs.length - 1];
Expand Down Expand Up @@ -3230,8 +3232,6 @@ var JSHINT = (function() {
if (!isNecessary) {
warning("W126", opening);
}

ret.paren = true;
}

return ret;
Expand Down Expand Up @@ -3866,14 +3866,10 @@ var JSHINT = (function() {
// For example: if (a = 1) { ... }

function checkCondAssignment(expr) {
var id, paren;
if (expr) {
var id = expr.id;
if (id === ",") {
expr = expr.exprs[expr.exprs.length - 1];
id = expr.id;
paren = expr.paren;
if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
id = expr.id;
paren = paren || expr.paren;
}
}
switch (id) {
case "=":
Expand All @@ -3885,7 +3881,7 @@ var JSHINT = (function() {
case "|=":
case "^=":
case "/=":
if (!paren && !state.option.boss) {
if (!expr.paren && !state.option.boss) {
warning("W084");
}
}
Expand Down Expand Up @@ -5226,7 +5222,7 @@ var JSHINT = (function() {
if (!state.option.asi)
nolinebreak(this);

if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
if (state.tokens.next.id !== ";" &&
state.tokens.curr.line === startLine(state.tokens.next)) {
if (!state.funct["(scope)"].funct.hasLabel(v)) {
warning("W090", state.tokens.next, v);
Expand Down Expand Up @@ -5254,7 +5250,7 @@ var JSHINT = (function() {
if (!state.option.asi)
nolinebreak(this);

if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
if (state.tokens.next.id !== ";") {
if (state.tokens.curr.line === startLine(state.tokens.next)) {
if (!state.funct["(scope)"].funct.hasLabel(v)) {
warning("W090", state.tokens.next, v);
Expand Down

0 comments on commit e63dbc7

Please sign in to comment.