Bug 1455581 - Enable ESLint rules no-undef and no-unused-vars for devtools/client/framework/. r=jdescottes
authorMark Banner <standard8@mozilla.com>
Fri, 20 Apr 2018 12:17:40 +0100
changeset 468470 e38dafe679416fcf85c2bf6cb19ebc4fe9088547
parent 468377 6a2fca281629f3cc53a98267b1bbff406b32e501
child 468471 fe56c460afa17c87fff965d13bfb1e336f4367e4
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1455581
milestone61.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 1455581 - Enable ESLint rules no-undef and no-unused-vars for devtools/client/framework/. r=jdescottes MozReview-Commit-ID: IGwI0JkIDkf
devtools/.eslintrc.js
devtools/client/framework/attach-thread.js
devtools/client/framework/components/toolbox-toolbar.js
devtools/client/framework/connect/connect.js
devtools/client/framework/gDevTools.jsm
devtools/client/framework/test/browser_browser_toolbox.js
devtools/client/framework/test/browser_browser_toolbox_debugger.js
devtools/client/framework/test/browser_ignore_toolbox_network_requests.js
devtools/client/framework/test/browser_new_activation_workflow.js
devtools/client/framework/test/browser_target_support.js
devtools/client/framework/test/browser_toolbox_options_disable_cache-01.js
devtools/client/framework/test/browser_toolbox_options_disable_cache-02.js
devtools/client/framework/test/browser_toolbox_options_disable_js.html
devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html
devtools/client/framework/test/browser_toolbox_options_enable_serviceworkers_testing_frame_script.js
devtools/client/framework/test/browser_toolbox_races.js
devtools/client/framework/test/browser_toolbox_remoteness_change.js
devtools/client/framework/test/browser_toolbox_sidebar.js
devtools/client/framework/test/browser_toolbox_tool_remote_reopen.js
devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_width.js
devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js
devtools/client/framework/test/helper_disable_cache.js
devtools/client/framework/test/test_browser_toolbox_debugger.js
--- a/devtools/.eslintrc.js
+++ b/devtools/.eslintrc.js
@@ -11,31 +11,29 @@ module.exports = {
     "module": true,
     "reportError": true,
     "require": true,
   },
   "overrides": [{
     // XXX Bug 1230193. We're still working on enabling no-undef for these test
     // directories.
     "files": [
-      "client/framework/test/**",
       "client/scratchpad/**",
       "server/tests/mochitest/**",
       "shared/tests/unit/**",
     ],
     "rules": {
       "no-undef": "off",
     }
   }, {
     "files": [
       "client/framework/**",
     ],
     "rules": {
       "no-return-assign": "off",
-      "no-unused-vars": "off",
     }
   }, {
     "files": [
       "client/scratchpad/scratchpad-manager.jsm",
       "client/scratchpad/scratchpad.js",
       "client/shared/*.jsm",
     ],
     "rules": {
--- a/devtools/client/framework/attach-thread.js
+++ b/devtools/client/framework/attach-thread.js
@@ -1,15 +1,14 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* 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/. */
 
-const {Cc, Ci, Cu} = require("chrome");
 const Services = require("Services");
 const defer = require("devtools/shared/defer");
 
 const {LocalizationHelper} = require("devtools/shared/l10n");
 const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
 
 function handleThreadState(toolbox, event, packet) {
   // Suppress interrupted events by default because the thread is
--- a/devtools/client/framework/components/toolbox-toolbar.js
+++ b/devtools/client/framework/components/toolbox-toolbar.js
@@ -6,17 +6,16 @@
 const { Component, createFactory } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const {div, button} = dom;
 const {openWebLink} = require("devtools/client/shared/link");
 
 const Menu = require("devtools/client/framework/menu");
 const MenuItem = require("devtools/client/framework/menu-item");
-const ToolboxTab = createFactory(require("devtools/client/framework/components/toolbox-tab"));
 const ToolboxTabs = createFactory(require("devtools/client/framework/components/toolbox-tabs"));
 
 /**
  * This is the overall component for the toolbox toolbar. It is designed to not know how
  * the state is being managed, and attempts to be as pure as possible. The
  * ToolboxController component controls the changing state, and passes in everything as
  * props.
  */
--- a/devtools/client/framework/connect/connect.js
+++ b/devtools/client/framework/connect/connect.js
@@ -42,16 +42,17 @@ window.addEventListener("DOMContentLoade
       showError("unexpected");
     });
   });
 }, {capture: true, once: true});
 
 /**
  * Called when the "connect" button is clicked.
  */
+/* exported submit */
 var submit = async function() {
   // Show the "connecting" screen
   document.body.classList.add("connecting");
 
   let host = document.getElementById("host").value;
   let port = document.getElementById("port").value;
 
   // Save the host/port values
--- a/devtools/client/framework/gDevTools.jsm
+++ b/devtools/client/framework/gDevTools.jsm
@@ -10,18 +10,16 @@
  * This JSM is here to keep some compatibility with existing add-ons.
  * Please now use the modules:
  * - devtools/client/framework/devtools for gDevTools
  * - devtools/client/framework/devtools-browser for gDevToolsBrowser
  */
 
 this.EXPORTED_SYMBOLS = [ "gDevTools", "gDevToolsBrowser" ];
 
-const { loader } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-
 /**
  * Do not directly map to the commonjs modules so that callsites of
  * gDevTools.jsm do not have to do anything to access to the very last version
  * of the module. The `devtools` and `browser` getter are always going to
  * retrieve the very last version of the modules.
  */
 Object.defineProperty(this, "require", {
   get() {
--- a/devtools/client/framework/test/browser_browser_toolbox.js
+++ b/devtools/client/framework/test/browser_browser_toolbox.js
@@ -33,16 +33,17 @@ add_task(async function() {
       Services.obs.removeObserver(listener, "browser-toolbox-console-works");
       done(data === "true");
     }, "browser-toolbox-console-works");
   });
 
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+  /* global toolbox */
   let testScript = function() {
     toolbox.selectTool("webconsole")
       .then(console => {
         // This is for checking Browser Toolbox doesn't have a close button.
         let hasCloseButton = !!toolbox.doc.getElementById("toolbox-close");
         let { jsterm } = console.hud;
         let js = "Services.obs.notifyObservers(null, 'browser-toolbox-console-works', " +
             hasCloseButton + ");";
--- a/devtools/client/framework/test/browser_browser_toolbox_debugger.js
+++ b/devtools/client/framework/test/browser_browser_toolbox_debugger.js
@@ -58,16 +58,17 @@ add_task(async function runTest() {
   let interval = setInterval(s.plop, 1000);
 
   // Be careful, this JS function is going to be executed in the browser toolbox,
   // which lives in another process. So do not try to use any scope variable!
   let env = Cc["@mozilla.org/process/environment;1"]
               .getService(Ci.nsIEnvironment);
   // First inject a very minimal head, with simplest assertion methods
   // and very common globals
+  /* eslint-disable no-unused-vars */
   let testHead = (function() {
     const info = msg => dump(msg + "\n");
     const is = (a, b, description) => {
       let msg = "'" + JSON.stringify(a) + "' is equal to '" + JSON.stringify(b) + "'";
       if (description) {
         msg += " - " + description;
       }
       if (a !== b) {
@@ -111,19 +112,19 @@ add_task(async function runTest() {
         // TODO: fixme.
         // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
         setTimeout(function() {
           waitUntil(predicate, interval).then(() => resolve(true));
         }, interval);
       });
     }
   }).toSource().replace(/^\(function\(\) \{|\}\)$/g, "");
+  /* eslint-enable no-unused-vars */
   // Stringify testHead's function and remove `(function {` prefix and `})` suffix
   // to ensure inner symbols gets exposed to next pieces of code
-
   // Then inject new debugger head file
   let { content } = await fetch(debuggerHeadURL);
   let debuggerHead = content;
   // We remove its import of shared-head, which isn't available in browser toolbox process
   // And isn't needed thanks to testHead's symbols
   debuggerHead = debuggerHead.replace(/Services.scriptloader.loadSubScript[^\)]*\);/, "");
 
   // Finally, fetch the debugger test script that is going to be execute in the browser
--- a/devtools/client/framework/test/browser_ignore_toolbox_network_requests.js
+++ b/devtools/client/framework/test/browser_ignore_toolbox_network_requests.js
@@ -17,16 +17,16 @@ add_task(async function() {
   let tab = await addTab(URL_ROOT + "doc_viewsource.html");
   let target = TargetFactory.forTab(tab);
   let toolbox = await gDevTools.showToolbox(target, "styleeditor");
   let panel = toolbox.getPanel("styleeditor");
 
   is(panel.UI.editors.length, 1, "correct number of editors opened");
 
   let monitor = await toolbox.selectTool("netmonitor");
-  let { store, windowRequire } = monitor.panelWin;
+  let { store } = monitor.panelWin;
 
   is(store.getState().requests.requests.size, 0, "No network requests appear in the network panel");
 
   await gDevTools.closeToolbox(target);
   tab = target = toolbox = panel = null;
   gBrowser.removeCurrentTab();
 });
--- a/devtools/client/framework/test/browser_new_activation_workflow.js
+++ b/devtools/client/framework/test/browser_new_activation_workflow.js
@@ -2,18 +2,16 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests devtools API
 
 var toolbox, target;
 
-var tempScope = {};
-
 function test() {
   addTab("about:blank").then(function(aTab) {
     target = TargetFactory.forTab(gBrowser.selectedTab);
     loadWebConsole(aTab).then(function() {
       console.log("loaded");
     });
   });
 }
--- a/devtools/client/framework/test/browser_target_support.js
+++ b/devtools/client/framework/test/browser_target_support.js
@@ -11,17 +11,17 @@ var { WebAudioFront } =
 
 async function testTarget(client, target) {
   await target.makeRemote();
 
   is(target.hasActor("timeline"), true, "target.hasActor() true when actor exists.");
   is(target.hasActor("webaudio"), true, "target.hasActor() true when actor exists.");
   is(target.hasActor("notreal"), false, "target.hasActor() false when actor does not exist.");
   // Create a front to ensure the actor is loaded
-  let front = new WebAudioFront(target.client, target.form);
+  new WebAudioFront(target.client, target.form);
 
   let desc = await target.getActorDescription("webaudio");
   is(desc.typeName, "webaudio",
     "target.getActorDescription() returns definition data for corresponding actor");
   is(desc.events["start-context"].type, "startContext",
     "target.getActorDescription() returns event data for corresponding actor");
 
   desc = await target.getActorDescription("nope");
--- a/devtools/client/framework/test/browser_toolbox_options_disable_cache-01.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_cache-01.js
@@ -4,16 +4,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 requestLongerTimeout(2);
 
 // Tests that disabling the cache for a tab works as it should when toolboxes
 // are not toggled.
+/* import-globals-from helper_disable_cache.js */
 loadHelperScript("helper_disable_cache.js");
 
 add_task(async function() {
   // Disable rcwn to make cache behavior deterministic.
   await pushPref("network.http.rcwn.enabled", false);
 
   // Ensure that the setting is cleared after the test.
   registerCleanupFunction(() => {
--- a/devtools/client/framework/test/browser_toolbox_options_disable_cache-02.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_cache-02.js
@@ -4,16 +4,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 requestLongerTimeout(2);
 
 // Tests that disabling the cache for a tab works as it should when toolboxes
 // are toggled.
+/* import-globals-from helper_disable_cache.js */
 loadHelperScript("helper_disable_cache.js");
 
 add_task(async function() {
   // Disable rcwn to make cache behavior deterministic.
   await pushPref("network.http.rcwn.enabled", false);
 
   // Ensure that the setting is cleared after the test.
   registerCleanupFunction(() => {
--- a/devtools/client/framework/test/browser_toolbox_options_disable_js.html
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_js.html
@@ -16,16 +16,17 @@
         border: 1px solid #000;
       }
 
       h1 {
         font-size: 20px
       }
     </style>
     <script type="application/javascript">
+      /* exported log */
       function log(msg) {
         let output = document.getElementById("output");
 
         // eslint-disable-next-line no-unsanitized/property
         output.innerHTML = msg;
       }
     </script>
   </head>
--- a/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html
@@ -6,16 +6,17 @@
       div {
         width: 260px;
         height: 24px;
         border: 1px solid #000;
         margin-top: 10px;
       }
     </style>
     <script type="application/javascript">
+      /* exported log */
       function log(msg) {
         let output = document.getElementById("output");
 
         // eslint-disable-next-line no-unsanitized/property
         output.innerHTML = msg;
       }
     </script>
   </head>
--- a/devtools/client/framework/test/browser_toolbox_options_enable_serviceworkers_testing_frame_script.js
+++ b/devtools/client/framework/test/browser_toolbox_options_enable_serviceworkers_testing_frame_script.js
@@ -1,15 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // A helper frame-script for devtools/client/framework service worker tests.
 
+/* eslint-env mozilla/frame-script */
+
 "use strict";
 
 addMessageListener("devtools:sw-test:register", function(msg) {
   content.navigator.serviceWorker.register("serviceworker.js")
     .then(swr => {
       sendAsyncMessage("devtools:sw-test:register", {success: true});
     }, error => {
       sendAsyncMessage("devtools:sw-test:register", {success: false});
--- a/devtools/client/framework/test/browser_toolbox_races.js
+++ b/devtools/client/framework/test/browser_toolbox_races.js
@@ -13,17 +13,17 @@ requestLongerTimeout(2);
 const URL = "data:text/html;charset=utf-8,Toggling devtools quickly";
 const {gDevToolsBrowser} = require("devtools/client/framework/devtools-browser");
 
 add_task(async function() {
   // Make sure this test starts with the selectedTool pref cleared. Previous
   // tests select various tools, and that sets this pref.
   Services.prefs.clearUserPref("devtools.toolbox.selectedTool");
 
-  let tab = await addTab(URL);
+  await addTab(URL);
 
   let created = 0, ready = 0, destroy = 0, destroyed = 0;
   let onCreated = () => {
     created++;
   };
   let onReady = () => {
     ready++;
   };
--- a/devtools/client/framework/test/browser_toolbox_remoteness_change.js
+++ b/devtools/client/framework/test/browser_toolbox_remoteness_change.js
@@ -1,13 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-var {Toolbox} = require("devtools/client/framework/toolbox");
-
 const URL_1 = "about:robots";
 const URL_2 = "data:text/html;charset=UTF-8," +
   encodeURIComponent("<div id=\"remote-page\">foo</div>");
 
 add_task(async function() {
   info("Open a tab on a URL supporting only running in parent process");
   let tab = await addTab(URL_1);
   is(tab.linkedBrowser.currentURI.spec, URL_1, "We really are on the expected document");
--- a/devtools/client/framework/test/browser_toolbox_sidebar.js
+++ b/devtools/client/framework/test/browser_toolbox_sidebar.js
@@ -5,17 +5,16 @@
 
 function test() {
   let {ToolSidebar} = require("devtools/client/framework/sidebar");
 
   const tab1URL = "data:text/html;charset=utf8,<title>1</title><p>1</p>";
   const tab2URL = "data:text/html;charset=utf8,<title>2</title><p>2</p>";
   const tab3URL = "data:text/html;charset=utf8,<title>3</title><p>3</p>";
 
-  let panelDoc;
   let tab1Selected = false;
   let registeredTabs = {};
   let readyTabs = {};
 
   let toolDefinition = {
     id: "fakeTool4242",
     visibilityswitch: "devtools.fakeTool4242.enabled",
     url: CHROME_URL_ROOT + "browser_toolbox_sidebar_toolURL.xul",
--- a/devtools/client/framework/test/browser_toolbox_tool_remote_reopen.js
+++ b/devtools/client/framework/test/browser_toolbox_tool_remote_reopen.js
@@ -56,18 +56,16 @@ function runTools(target) {
       ok(panel.isReady, toolId + " panel should be ready");
     }
 
     await toolbox.destroy();
   })();
 }
 
 function getClient() {
-  let deferred = defer();
-
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
   let transport = DebuggerServer.connectPipe();
   let client = new DebuggerClient(transport);
 
   return client.connect().then(() => client);
 }
--- a/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_width.js
+++ b/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_width.js
@@ -18,17 +18,17 @@ let { Toolbox } = require("devtools/clie
 
 add_task(async function() {
   let tab = await addTab("about:blank");
 
   info("Open devtools on the Storage in a sidebar.");
   let toolbox = await openToolboxForTab(tab, "storage", Toolbox.HostType.BOTTOM);
 
   info("Waiting for the window to be resized");
-  let {hostWin, originalWidth, originalHeight} = await resizeWindow(toolbox, 800);
+  let {originalWidth, originalHeight} = await resizeWindow(toolbox, 800);
 
   info("Wait until the tools menu button is available");
   await waitUntil(() => toolbox.doc.querySelector(".tools-chevron-menu"));
 
   let toolsMenuButton = toolbox.doc.querySelector(".tools-chevron-menu");
   ok(toolsMenuButton, "The tools menu button is displayed");
 
   info("Confirm that selected tab is not hidden.");
@@ -40,17 +40,17 @@ add_task(async function() {
 
 add_task(async function() {
   let tab = await addTab("about:blank");
 
   info("Open devtools on the Storage in a sidebar.");
   let toolbox = await openToolboxForTab(tab, "storage", Toolbox.HostType.BOTTOM);
 
   info("Resize devtools window to a width that should trigger an overflow");
-  let {hostWin, originalWidth, originalHeight} = await resizeWindow(toolbox, 800);
+  let {originalWidth, originalHeight} = await resizeWindow(toolbox, 800);
 
   info("Regist a new tab");
   let onRegistered = toolbox.once("tool-registered");
   gDevTools.registerTool({
     id: "test-tools",
     label: "Test Tools",
     isMenu: true,
     isTargetSupported: () => true,
--- a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js
+++ b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js
@@ -35,18 +35,16 @@ var waitForToolInstanceBuild = new Promi
 var resolveToolInstanceDestroyed;
 var waitForToolInstanceDestroyed = new Promise((resolve) => {
   resolveToolInstanceDestroyed = resolve;
 });
 
 function toolboxRegister(aToolbox) {
   toolbox = aToolbox;
 
-  var resolveToolInstanceBuild;
-
   waitForToolInstanceBuild = new Promise((resolve) => {
     resolveToolInstanceBuild = resolve;
   });
 
   info("add per-toolbox tool in the opened toolbox.");
 
   toolbox.addAdditionalTool({
     id: TOOL_ID,
--- a/devtools/client/framework/test/helper_disable_cache.js
+++ b/devtools/client/framework/test/helper_disable_cache.js
@@ -1,15 +1,21 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+// This file assumes we have head.js globals for the scope where this is loaded.
+/* import-globals-from head.js */
+
+/* exported initTab, checkCacheStateForAllTabs, setDisableCacheCheckboxChecked,
+            finishUp */
+
 // Common code shared by browser_toolbox_options_disable_cache-*.js
 const TEST_URI = URL_ROOT + "browser_toolbox_options_disable_cache.sjs";
 var tabs = [
   {
     title: "Tab 0",
     desc: "Toggles cache on.",
     startToolbox: true
   },
--- a/devtools/client/framework/test/test_browser_toolbox_debugger.js
+++ b/devtools/client/framework/test/test_browser_toolbox_debugger.js
@@ -1,9 +1,11 @@
-/* global toolbox */
+/* global toolbox, createDebuggerContext, waitForSources, testUrl,
+          waitForPaused, addBreakpoint, assertPausedLocation, stepIn,
+          findSource, removeBreakpoint, resume */
 
 info(`START: ${new Error().lineNumber}`);
 
 (async function() {
   Services.prefs.clearUserPref("devtools.debugger.tabs");
   Services.prefs.clearUserPref("devtools.debugger.pending-selected-location");
 
   info("Waiting for debugger load");