Bug 1372427 - add "no-unused-vars" rule, with laxist variation in head_satchel + satchel_common. r=mattn draft
authorJonathan Guillotte-Blouin <jguillotteblouin@mozilla.com>
Thu, 15 Jun 2017 16:39:50 -0700
changeset 597801 9f7e43bc2bfaaddc3872083a6b23f831070d2858
parent 597800 7921e6500579492281a42afe296cb12c051b4bf4
child 597802 4d524379de87cf943ec035ae11506a9510e66a38
push id65027
push userbmo:jguillotteblouin@mozilla.com
push dateTue, 20 Jun 2017 23:30:25 +0000
reviewersmattn
bugs1372427
milestone56.0a1
Bug 1372427 - add "no-unused-vars" rule, with laxist variation in head_satchel + satchel_common. r=mattn MozReview-Commit-ID: 9HBxDyUF01Q
toolkit/components/satchel/.eslintrc.js
toolkit/components/satchel/test/satchel_common.js
toolkit/components/satchel/test/subtst_form_submission_1.html
toolkit/components/satchel/test/subtst_privbrowsing.html
toolkit/components/satchel/test/test_form_submission.html
toolkit/components/satchel/test/test_form_submission_cap.html
toolkit/components/satchel/test/test_form_submission_cap2.html
toolkit/components/satchel/test/unit/head_satchel.js
toolkit/components/satchel/test/unit/test_async_expire.js
toolkit/components/satchel/test/unit/test_autocomplete.js
--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -63,10 +63,14 @@ module.exports = {
     "generator-star-spacing": ["error", "after"],
     "new-parens": "error",
     "no-unused-expressions": "error",
     "no-console": "error",
     "no-proto": "error",
     "no-unneeded-ternary": "error",
     yoda: "error",
     "no-new-wrappers": "error",
+    "no-unused-vars": ["error", {
+      args: "none",
+      varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
+    }],
   },
 };
--- a/toolkit/components/satchel/test/satchel_common.js
+++ b/toolkit/components/satchel/test/satchel_common.js
@@ -1,12 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* eslint
+  "no-unused-vars": ["error", {
+    vars: "local",
+    args: "none",
+    varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
+  }],
+*/
+
 /* import-globals-from ../../../../testing/mochitest/tests/SimpleTest/SimpleTest.js */
 
 var gPopupShownExpected = false;
 var gPopupShownListener;
 var gLastAutoCompleteResults;
 var gChromeScript;
 
 /*
--- a/toolkit/components/satchel/test/subtst_form_submission_1.html
+++ b/toolkit/components/satchel/test/subtst_form_submission_1.html
@@ -7,16 +7,17 @@
 <body>
 
 <form id="subform2" onsubmit="return checkSubmit(100)">
   <input id="subtest2" type="text" name="subtest2">
   <button type="submit">Submit</button>
 </form>
 
 <script>
+  /* exported checkSubmit clickButton */
   function checkSubmit(num) {
     return SpecialPowers.wrap(parent).wrappedJSObject.checkSubmit(num);
   }
 
   function clickButton(num) {
     if (num == 100) {
       document.querySelectorAll("button")[0].click();
     }
--- a/toolkit/components/satchel/test/subtst_privbrowsing.html
+++ b/toolkit/components/satchel/test/subtst_privbrowsing.html
@@ -1,13 +1,14 @@
 <html>
 <head>
   <meta charset=UTF-8>
   <title>Subtest for bug 472396</title>
   <script>
+  /* exported submitForm */
   function submitForm() {
     if (location.search.indexOf("field") == -1) {
       let form  = document.getElementById("form");
       let field = document.getElementById("field");
       field.value = "value";
       form.submit();
     }
   }
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -350,16 +350,17 @@ function startTest() {
   $_(109, "test9").value = "savedValue";
 
   // submit the first form.
   let button = getFormSubmitButton(1);
   button.click();
 }
 
 
+/* exported checkSubmit */
 // Called by each form's onsubmit handler.
 function checkSubmit(formNum) {
   ok(true, "form " + formNum + " submitted");
   numSubmittedForms++;
 
   // Check for expected storage state.
   switch (formNum) {
     // Test 1-24 should not save anything.
--- a/toolkit/components/satchel/test/test_form_submission_cap.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap.html
@@ -53,17 +53,17 @@ function startTest() {
     $_(1, "test" + i).value = i;
   }
 
   // submit the first form.
   let button = getFormSubmitButton(1);
   button.click();
 }
 
-
+/* exported checkSubmit */
 // Called by each form's onsubmit handler.
 function checkSubmit(formNum) {
   ok(true, "form " + formNum + " submitted");
   numSubmittedForms++;
 
   // check that the first (numInputFields - 1) CHANGED fields are saved
   for (let i = 1; i < numInputFields; i++) { // check all but last
     checkForSave("test" + i, i, "checking saved value " + i);
--- a/toolkit/components/satchel/test/test_form_submission_cap2.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap2.html
@@ -155,16 +155,17 @@ function checkCountEntries(formNum, inde
                  if (index < numInputFields) {
                    checkCountEntries(formNum, index + 1, done);
                  } else {
                    done(formNum);
                  }
                });
 }
 
+/* exported checkSubmit */
 // Called by each form's onsubmit handler.
 function checkSubmit(formNum) {
   ok(true, "form " + formNum + " submitted");
   numSubmittedForms++;
 
   // make sure that the field # numInputFields was saved
   checkForSave("test" + numInputFields,
                numInputFields + " changed",
--- a/toolkit/components/satchel/test/unit/head_satchel.js
+++ b/toolkit/components/satchel/test/unit/head_satchel.js
@@ -1,12 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* eslint
+  "no-unused-vars": ["error", {
+    vars: "local",
+    args: "none",
+    varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
+  }],
+*/
+
 const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 const CURRENT_SCHEMA = 4;
 const PR_HOURS = 60 * 60 * 1000000;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FormHistory.jsm");
 
--- a/toolkit/components/satchel/test/unit/test_async_expire.js
+++ b/toolkit/components/satchel/test/unit/test_async_expire.js
@@ -1,14 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var dbFile, oldSize;
-var currentTestIndex = 0;
+var dbFile;
 
 function triggerExpiration() {
   // We can't easily fake a "daily idle" event, so for testing purposes form
   // history listens for another notification to trigger an immediate
   // expiration.
   Services.obs.notifyObservers(null, "formhistory-expire-now");
 }
 
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ b/toolkit/components/satchel/test/unit/test_autocomplete.js
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-var testnum = 0;
 var fac;
 var prefs;
 
 var numRecords, timeGroupingSize, now;
 
 const DEFAULT_EXPIRE_DAYS = 180;
 
 function padLeft(number, length) {