Repository: jshint/jshint
Pull request #3415 (2019-07-13 08:23:45)

[[CHORE]] Improve CI configuration
Use the "build matrix" feature offered by TravisCI in order to simplify
the "script" parameter and to create distinct jobs for the "test-262"
and "test-browser" commands (these were previously run as part of the
job scheduled to run the project's unit tests in Node.js version 10).

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24547025/badge)](https://coveralls.io/builds/24547025)

Coverage remained the same at 100.0% when pulling **b389f6c279b1a837e4e543f4207dc0bf0463199b on jugglinmike:simplify-travis** into **2366c92b852adeb963ecb812bc32b258288663dc on jshint:master**.

jugglinmike: Well that was kinda frustrating. Anyhoo, this is good to go (with a squash merge, please).

Patch:
diff --git a/.travis.yml b/.travis.yml
index 5d9805cf..825ee0c3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,16 +9,26 @@ before_install:
     fi
 script:
   - npm run pretest
-  - npm run test-node
-  - if [[ $(node --version) == v10* ]] ; then npm run test-262; fi
-  - if [[ $(node --version) == v10* ]] ; then npm run test-browser; fi
-node_js:
-  - "0.10"
-  - "0.12"
-  - 4
-  - 6
-  - 8
-  - 10
+  - npm run $CMD
+cache:
+  npm: false
 matrix:
+  include:
+    - node_js: "0.10"
+      env: CMD=test-node
+    - node_js: "0.12"
+      env: CMD=test-node
+    - node_js: 4
+      env: CMD=test-node
+    - node_js: 6
+      env: CMD=test-node
+    - node_js: 8
+      env: CMD=test-node
+    - node_js: 10
+      env: CMD=test-node
+    - node_js: 10
+      env: CMD=test-262
+    - node_js: 10
+      env: CMD=test-browser
   fast_finish: true
 sudo: false
diff --git a/src/jshint.js b/src/jshint.js
index baf95692..dd2ff862 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -2829,7 +2829,8 @@ var JSHINT = (function() {
       inGenerator = false;
       context &= ~prodParams.preAsync;
 
-      if (state.tokens.next.value === "static") {
+      if (state.tokens.next.value === "static" &&
+        !checkPunctuator(peek(), "(")) {
         isStatic = true;
         advance();
       }
@@ -4372,11 +4373,13 @@ var JSHINT = (function() {
         }
         var id = state.tokens.prev;
         value = expression(context, 10);
-        if (value && value.identifier && value.value === "undefined") {
-          warning("W080", id, id.value);
-        }
-        if (!lone) {
-          destructuringPatternMatch(names, value);
+        if (value) {
+          if (value.identifier && value.value === "undefined") {
+            warning("W080", id, id.value);
+          }
+          if (!lone) {
+            destructuringPatternMatch(names, value);
+          }
         }
       }
 
@@ -4558,12 +4561,14 @@ var JSHINT = (function() {
         }
         id = state.tokens.prev;
         value = expression(context, 10);
-        if (value && !state.funct["(loopage)"] && value.identifier &&
-          value.value === "undefined") {
-          warning("W080", id, id.value);
-        }
-        if (!lone) {
-          destructuringPatternMatch(names, value);
+        if (value) {
+          if (!state.funct["(loopage)"] && value.identifier &&
+            value.value === "undefined") {
+            warning("W080", id, id.value);
+          }
+          if (!lone) {
+            destructuringPatternMatch(names, value);
+          }
         }
       }
 
@@ -4828,6 +4833,7 @@ var JSHINT = (function() {
     var t = state.tokens.next;
     var g = false;
     var noindent = false;
+    var seenCase = false;
 
     state.funct["(breakage)"] += 1;
     advance("(");
@@ -4843,8 +4849,6 @@ var JSHINT = (function() {
     if (!noindent)
       indent += state.option.indent;
 
-    this.cases = [];
-
     for (;;) {
       switch (state.tokens.next.id) {
       case "case":
@@ -4873,7 +4877,8 @@ var JSHINT = (function() {
         }
 
         advance("case");
-        this.cases.push(expression(context, 0));
+        expression(context, 0);
+        seenCase = true;
         increaseComplexityCount();
         g = true;
         advance(":");
@@ -4896,10 +4901,8 @@ var JSHINT = (function() {
         default:
           // Do not display a warning if 'default' is the first statement or if
           // there is a special /* falls through */ comment.
-          if (this.cases.length) {
-            if (!state.tokens.curr.caseFallsThrough) {
-              warning("W086", state.tokens.curr, "default");
-            }
+          if (seenCase && !state.tokens.curr.caseFallsThrough) {
+            warning("W086", state.tokens.curr, "default");
           }
         }
 


Test patch:
diff --git a/tests/unit/parser.js b/tests/unit/parser.js
index b3fd37b4..28c96c0c 100644
--- a/tests/unit/parser.js
+++ b/tests/unit/parser.js
@@ -2493,6 +2493,25 @@ exports["destructuring assignment of valid simple assignment targets"] = functio
   test.done();
 };
 
+exports["regression test for GH-3408"] = function (test) {
+  TestRun(test, "var statement")
+    .addError(1, 9, "Expected an identifier and instead saw ';'.")
+    .addError(1, 10, "Missing semicolon.")
+    .test("var [x]=;", { esversion: 6 });
+
+  TestRun(test, "let statement")
+    .addError(1, 9, "Expected an identifier and instead saw ';'.")
+    .addError(1, 10, "Missing semicolon.")
+    .test("let [x]=;", { esversion: 6 });
+
+  TestRun(test, "const statement")
+    .addError(1, 11, "Expected an identifier and instead saw ';'.")
+    .addError(1, 12, "Missing semicolon.")
+    .test("const [x]=;", { esversion: 6 });
+
+  test.done();
+};
+
 exports["non-identifier PropertyNames in object destructuring"] = function (test) {
   var code = [
     "var { ['x' + 2]: a = 3, 0: b } = { x2: 1, 0: 2 };",
@@ -6825,6 +6844,28 @@ exports["class and method naming"] = function (test) {
       "};"
     ], {esversion: 6});
 
+  TestRun(test, "valid uses of name `static`")
+    .test([
+      "void class {",
+      "  static() {}",
+      "  static static() {}",
+      "  static ['static']() {}",
+      "};",
+      "void class {",
+      "  * static() { yield; }",
+      "  static * static() { yield; }",
+      "  static * ['static']() { yield; }",
+      "};",
+      "void class {",
+      "  get static() {}",
+      "  set static(x) {}",
+      "  static get static() {}",
+      "  static set static(x) {}",
+      "  static get ['static']() {}",
+      "  static set ['static'](x) {}",
+      "};"
+    ], {esversion: 6});
+
   TestRun(test, "invalid use of name `prototype`: static method")
     .addError(2, 10, "A static class method cannot be named 'prototype'.")
     .test([