postaction()

in web/jslint/src/main/resources/data/jslint-2020-03-28.js [4027:4094]


postaction("binary", "(", function (thing) {
  var left = thing.expression[0];
  var the_new;
  var arg;

  if (left.id === "new") {
    the_new = left;
    left = left.expression;
  }

  if (left.id === "function") {
    if (!thing.wrapped) {
      warn("wrap_immediate", thing);
    }
  } else if (left.identifier) {
    if (the_new !== undefined) {
      if (left.id[0] > "Z" || left.id === "Boolean" || left.id === "Number" || left.id === "String" || left.id === "Symbol") {
        warn("unexpected_a", the_new);
      } else if (left.id === "Function") {
        if (!option.eval) {
          warn("unexpected_a", left, "new Function");
        }
      } else if (left.id === "Array") {
        arg = thing.expression;

        if (arg.length !== 2 || arg[1].id === "(string)") {
          warn("expected_a_b", left, "[]", "new Array");
        }
      } else if (left.id === "Object") {
        warn("expected_a_b", left, "Object.create(null)", "new Object");
      }
    } else {
      if (left.id[0] >= "A" && left.id[0] <= "Z" && left.id !== "Boolean" && left.id !== "Number" && left.id !== "String" && left.id !== "Symbol") {
        warn("expected_a_before_b", left, "new", artifact(left));
      }
    }
  } else if (left.id === ".") {
    var cack = the_new !== undefined;

    if (left.expression.id === "Date" && left.name.id === "UTC") {
      cack = !cack;
    }

    if (rx_cap.test(left.name.id) !== cack) {
      if (the_new !== undefined) {
        warn("unexpected_a", the_new);
      } else {
        warn("expected_a_before_b", left.expression, "new", left.name.id);
      }
    }

    if (left.name.id === "getTime") {
      var paren = left.expression;

      if (paren.id === "(") {
        var array = paren.expression;

        if (array.length === 1) {
          var new_date = array[0];

          if (new_date.id === "new" && new_date.expression.id === "Date") {
            warn("expected_a_b", new_date, "Date.now()", "new Date().getTime()");
          }
        }
      }
    }
  }
});