Bug 1434869 - Automatically mark EXPORTED_SYMBOLS as used, so that we don't need to ignore it in ESLint's no-unused-vars rule. r=florian.
authorMark Banner <standard8@mozilla.com>
Tue, 06 Mar 2018 12:01:59 +0000
changeset 461758 54052450edd98c152261c2db0456f9dcc7b737ce
parent 461750 031b19788dfcff8743238dd46416333060f64245
child 461759 dc1a57e1430e18392d59e30c75d5cb5f69943e73
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1434869
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434869 - Automatically mark EXPORTED_SYMBOLS as used, so that we don't need to ignore it in ESLint's no-unused-vars rule. r=florian. MozReview-Commit-ID: IVMeZHGdVBk
browser/components/migration/.eslintrc.js
browser/experiments/.eslintrc.js
browser/experiments/test/xpcshell/.eslintrc.js
browser/extensions/formautofill/.eslintrc.js
browser/tools/mozscreenshots/.eslintrc.js
toolkit/components/extensions/.eslintrc.js
toolkit/components/payments/.eslintrc.js
toolkit/components/payments/test/browser/head.js
toolkit/components/reader/.eslintrc.js
toolkit/components/satchel/.eslintrc.js
toolkit/components/satchel/test/satchel_common.js
toolkit/components/satchel/test/unit/head_satchel.js
toolkit/mozapps/extensions/.eslintrc.js
toolkit/mozapps/extensions/test/browser/.eslintrc.js
toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js
--- a/browser/components/migration/.eslintrc.js
+++ b/browser/components/migration/.eslintrc.js
@@ -10,16 +10,16 @@ module.exports = {
     "new-parens": "error",
     "no-extend-native": "error",
     "no-fallthrough": ["error", { "commentPattern": ".*[Ii]ntentional(?:ly)?\\s+fall(?:ing)?[\\s-]*through.*" }],
     "no-multi-str": "error",
     "no-return-assign": "error",
     "no-sequences": "error",
     "no-shadow": "error",
     "no-throw-literal": "error",
-    "no-unused-vars": ["error", { "args": "after-used", "varsIgnorePattern": "^EXPORTED_SYMBOLS$", "vars": "all" }],
+    "no-unused-vars": ["error", { "args": "after-used", "vars": "all" }],
     "padded-blocks": ["error", "never"],
     "semi-spacing": ["error", {"before": false, "after": true}],
     "space-in-parens": ["error", "never"],
     "strict": ["error", "global"],
     "yoda": "error"
   }
 };
--- a/browser/experiments/.eslintrc.js
+++ b/browser/experiments/.eslintrc.js
@@ -1,11 +1,10 @@
 "use strict";
 
 module.exports = {
   "rules": {
     "no-unused-vars": ["error", {
       "args": "none",
-      "vars": "all",
-      "varsIgnorePattern": "^EXPORTED_SYMBOLS$",
+      "vars": "all"
     }]
   }
 };
--- a/browser/experiments/test/xpcshell/.eslintrc.js
+++ b/browser/experiments/test/xpcshell/.eslintrc.js
@@ -3,13 +3,12 @@
 module.exports = {
   "extends": [
     "plugin:mozilla/xpcshell-test"
   ],
 
   "rules": {
     "no-unused-vars": ["error", {
       "vars": "all",
-      "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
       "args": "none"
     }]
   }
 };
--- a/browser/extensions/formautofill/.eslintrc.js
+++ b/browser/extensions/formautofill/.eslintrc.js
@@ -40,17 +40,17 @@ module.exports = {
     // Always require parenthesis for new calls
     "new-parens": "error",
 
     // No expressions where a statement is expected
     "no-unused-expressions": "error",
 
     // No declaring variables that are never used
     "no-unused-vars": ["error", {
-      "args": "none", "vars": "all", "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
+      "args": "none", "vars": "all"
     }],
 
     // No using variables before defined
     "no-use-before-define": "error",
 
     // Disallow using variables outside the blocks they are defined (especially
     // since only let and const are used, see "no-var").
     "block-scoped-var": "error",
--- a/browser/tools/mozscreenshots/.eslintrc.js
+++ b/browser/tools/mozscreenshots/.eslintrc.js
@@ -3,13 +3,12 @@
 module.exports = {
   "extends": [
     "plugin:mozilla/browser-test"
   ],
 
   "rules": {
     "no-unused-vars": ["error", {
       "args": "none",
-      "vars": "all",
-      "varsIgnorePattern": "^EXPORTED_SYMBOLS$",
+      "vars": "all"
     }]
   }
 };
--- a/toolkit/components/extensions/.eslintrc.js
+++ b/toolkit/components/extensions/.eslintrc.js
@@ -88,17 +88,17 @@ module.exports = {
     // much benefit.
     "no-multi-spaces": "error",
 
     // No expressions where a statement is expected
     "no-unused-expressions": "error",
 
     // No declaring variables that are never used
     "no-unused-vars": ["error", {
-      "args": "none", "vars": "all", "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
+      "args": "none", "vars": "all"
     }],
 
     // No using variables before defined
     "no-use-before-define": "error",
 
     // Never use spaces before function parentheses
     "space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}],
 
--- a/toolkit/components/payments/.eslintrc.js
+++ b/toolkit/components/payments/.eslintrc.js
@@ -36,18 +36,17 @@ module.exports = {
     "no-multiple-empty-lines": ["error", {
       max: 2,
     }],
     "no-proto": "error",
     "no-throw-literal": "error",
     "no-unused-expressions": "error",
     "no-unused-vars": ["error", {
       args: "none",
-      vars: "all",
-      varsIgnorePattern: "^EXPORTED_SYMBOLS$",
+      vars: "all"
     }],
     "no-use-before-define": ["error", {
       functions: false,
     }],
     "padded-blocks": ["error", "never"],
     radix: "error",
     "semi-spacing": ["error", {"before": false, "after": true}],
     "space-in-parens": ["error", "never"],
--- a/toolkit/components/payments/test/browser/head.js
+++ b/toolkit/components/payments/test/browser/head.js
@@ -1,15 +1,14 @@
 "use strict";
 
 /* eslint
   "no-unused-vars": ["error", {
     vars: "local",
     args: "none",
-    varsIgnorePattern: "^(EXPORTED_SYMBOLS)$",
   }],
 */
 
 
 const BLANK_PAGE_PATH = "/browser/toolkit/components/payments/test/browser/blank_page.html";
 const BLANK_PAGE_URL = "https://example.com" + BLANK_PAGE_PATH;
 
 const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"]
--- a/toolkit/components/reader/.eslintrc.js
+++ b/toolkit/components/reader/.eslintrc.js
@@ -1,11 +1,11 @@
 "use strict";
 
 module.exports = {
   "rules": {
     "indent-legacy": ["error", 2, { "SwitchCase": 1 }],
     "new-parens": "error",
     "no-inner-declarations": "error",
     "no-shadow": "error",
-    "no-unused-vars": ["error", {"vars": "all", "varsIgnorePattern": "^EXPORTED_SYMBOLS$", "args": "none"}],
+    "no-unused-vars": ["error", {"vars": "all", "args": "none"}],
   },
 }
--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -38,17 +38,16 @@ module.exports = {
       max: 2,
     }],
     "no-proto": "error",
     "no-throw-literal": "error",
     "no-unused-expressions": "error",
     "no-unused-vars": ["error", {
       args: "none",
       vars: "all",
-      varsIgnorePattern: "^EXPORTED_SYMBOLS$",
     }],
     "no-use-before-define": ["error", {
       functions: false,
     }],
     "padded-blocks": ["error", "never"],
     radix: "error",
     semi: ["error", "always"],
     "semi-spacing": ["error", {"before": false, "after": true}],
--- a/toolkit/components/satchel/test/satchel_common.js
+++ b/toolkit/components/satchel/test/satchel_common.js
@@ -1,17 +1,16 @@
 /* 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;
--- a/toolkit/components/satchel/test/unit/head_satchel.js
+++ b/toolkit/components/satchel/test/unit/head_satchel.js
@@ -1,17 +1,16 @@
 /* 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 CURRENT_SCHEMA = 4;
 const PR_HOURS = 60 * 60 * 1000000;
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
--- a/toolkit/mozapps/extensions/.eslintrc.js
+++ b/toolkit/mozapps/extensions/.eslintrc.js
@@ -5,12 +5,11 @@ module.exports = {
     // Warn about cyclomatic complexity in functions.
     // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
     "complexity": ["error", {"max": 68}],
 
     "no-unused-vars": ["error", {
       "args": "none",
       "vars": "all",
-      "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
     }],
   }
 };
--- a/toolkit/mozapps/extensions/test/browser/.eslintrc.js
+++ b/toolkit/mozapps/extensions/test/browser/.eslintrc.js
@@ -1,11 +1,11 @@
 "use strict";
 
 module.exports = {
   "extends": [
     "plugin:mozilla/browser-test"
   ],
 
   "rules": {
-    "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS|end_test)$"}],
+    "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^end_test$"}],
   }
 };
--- a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
@@ -1,10 +1,10 @@
 "use strict";
 
 module.exports = {
   "extends": [
     "plugin:mozilla/xpcshell-test"
   ],
   "rules": {
-    "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS|end_test)$"}],
+    "no-unused-vars": ["error", {"args": "none", "varsIgnorePattern": "^end_test$"}],
   }
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -73,18 +73,17 @@ module.exports = {
       "browser": false,
       "mozilla/jsm": true
     },
     "files": "**/*.jsm",
     "rules": {
       "mozilla/mark-exported-symbols-as-used": "error",
       "no-unused-vars": ["error", {
         "args": "none",
-        "vars": "all",
-        "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
+        "vars": "all"
       }]
     }
   }],
 
   "parserOptions": {
     "ecmaVersion": 9
   },
 
@@ -350,18 +349,17 @@ module.exports = {
     // No unsanitized use of innerHTML=, document.write() etc.
     // cf. https://github.com/mozilla/eslint-plugin-no-unsanitized#rule-details
     "no-unsanitized/method": "error",
     "no-unsanitized/property": "error",
 
     // No declaring variables that are never used
     "no-unused-vars": ["error", {
       "args": "none",
-      "vars": "local",
-      "varsIgnorePattern": "^EXPORTED_SYMBOLS$"
+      "vars": "local"
     }],
 
     // No using variables before defined
     // "no-use-before-define": ["error", "nofunc"],
 
     // Disallow unnecessary .call() and .apply()
     "no-useless-call": "error",
 
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js
@@ -16,16 +16,18 @@ function markArrayElementsAsUsed(context
       message: "Unexpected assignment of non-Array to EXPORTED_SYMBOLS"
     });
     return;
   }
 
   for (let element of expression.elements) {
     context.markVariableAsUsed(element.value);
   }
+  // Also mark EXPORTED_SYMBOLS as used.
+  context.markVariableAsUsed("EXPORTED_SYMBOLS");
 }
 
 // -----------------------------------------------------------------------------
 // Rule Definition
 // -----------------------------------------------------------------------------
 
 module.exports = function(context) {
   // Ignore assignments not in the global scope, e.g. where special module