Repository: jshint/jshint
Pull request #3619 (2022-06-12 23:56:56)

[[CHORE]] Remove unused script


Patch:
diff --git a/bin/land b/bin/land
deleted file mode 100755
index f5c3cdcf..00000000
--- a/bin/land
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env node
-
-"use strict";
-
-var child_process = require("child_process");
-var url   = "https://github.com/jshint/jshint/pull/" + process.argv[2] + ".patch";
-var https = require("https");
-var opts  = require("url").parse(url);
-var msg   = process.argv[3];
-
-opts.rejectUnauthorized = false;
-opts.agent = new https.Agent(opts);
-
-https.get(opts, succ).on("error", err);
-
-function succ(res) {
-  if (res.statusCode !== 200)
-    return void console.log("error:", res.statusCode);
-
-  var data = "";
-  res.on("data", function (chunk) {
-    data += chunk.toString();
-  });
-
-  res.on("end", function () {
-    data = data.split("\n");
-    data = data[1].replace(/^From\:\s/, "");
-    data = data.replace(/"/g, "");
-
-    child_process.execSync("git commit -s --author=\"" + data + "\" --message=\"" + msg + "\"");
-  });
-}
-
-function err(res) {
-  console.log("error:", res.message);
-}
diff --git a/src/jshint.js b/src/jshint.js
index 4d599b0b..480a21b8 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -1850,8 +1850,9 @@ var JSHINT = (function() {
       if (t.reach) {
         return;
       }
+
       if (t.id !== "(endline)") {
-        if (t.id === "function") {
+        if (isFunction(t, i)) {
           if (state.option.latedef === true) {
             warning("W026", t);
           }
@@ -1862,6 +1863,16 @@ var JSHINT = (function() {
         break;
       }
     }
+
+    function isFunction(t, i) {
+      if (t.id === "function") {
+        return true;
+      }
+      if (t.id === "async") {
+        t = peek(i);
+        return t.id === "function";
+      }
+    }
   }
 
   /**


Test patch:
diff --git a/tests/unit/parser.js b/tests/unit/parser.js
index 30d50b1f..5cfbef0e 100644
--- a/tests/unit/parser.js
+++ b/tests/unit/parser.js
@@ -8268,7 +8268,53 @@ exports.unreachable = {
       .test(src);
 
     test.done();
-  }
+  },
+  'async function': function (test) {
+    var src = [
+      "(function() {",
+      "  return f(4);",
+      "  async function f(p) {",
+      "    return p + 1;",
+      "  }",
+      "}());"
+    ];
+
+    TestRun(test)
+      .test(src, { esversion: 8, latedef: 'nofunc' });
+
+    test.done();
+  },
+  "async identifier": function (test) {
+    var src = [
+      "(function() {",
+      "  return f(4);",
+      "  async();",
+      "}());"
+    ];
+
+    TestRun(test)
+      .addError(3, 3, "Unreachable 'async' after 'return'.")
+      .test(src, { esversion: 8, latedef: "nofunc" });
+
+    test.done();
+  },
+   "async asi": function (test) {
+    var src = [
+      "(function() {",
+      "  return f(4);",
+      "  async",
+      "  function f(p) {",
+      "    return p + 1;",
+      "  }",
+      "}());"
+    ];
+
+    TestRun(test)
+      .addError(3, 3, "Unreachable 'async' after 'return'.")
+      .test(src, { esversion: 8, latedef: "nofunc", asi: true, expr: true });
+
+    test.done();
+  },
 };
 
 exports["test for 'break' in switch case + curly braces"] = function (test) {