Bug 1242689 - Fix eslint errors in devtools/client/*.js and un-ignore the files; r=tromey draft
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 25 Jan 2016 21:38:28 +0100
changeset 325549 b8ab20a08648924fe8d508efed76ae46a0d99b1a
parent 325512 cd75145fe6d740ff0f77e867c6c03b0b1867e26a
child 513463 32b958abc9bf0a8fbf6b1b8786e8060cd73b9fb0
push id9994
push userpbrosset@mozilla.com
push dateMon, 25 Jan 2016 20:41:06 +0000
reviewerstromey
bugs1242689
milestone46.0a1
Bug 1242689 - Fix eslint errors in devtools/client/*.js and un-ignore the files; r=tromey
.eslintignore
devtools/client/definitions.js
devtools/client/devtools-clhandler.js
devtools/client/main.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -80,17 +80,16 @@ browser/extensions/shumway/**
 browser/fuel/**
 browser/locales/**
 
 # Ignore all of loop since it is imported from github and checked at source.
 browser/extensions/loop/**
 
 # devtools/ exclusions
 devtools/*.js
-devtools/client/*.js
 devtools/client/aboutdebugging/**
 devtools/client/animationinspector/**
 devtools/client/canvasdebugger/**
 devtools/client/commandline/**
 devtools/client/debugger/**
 devtools/client/eyedropper/**
 devtools/client/framework/**
 # devtools/client/inspector/shared/*.js files are eslint-clean, so they aren't
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -1,15 +1,15 @@
 /* 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";
 
-const {Cc, Ci, Cu} = require("chrome");
+const {Cc, Ci} = require("chrome");
 
 const { Services } = require("resource://gre/modules/Services.jsm");
 
 loader.lazyGetter(this, "osString", () => Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS);
 
 // Panels
 loader.lazyGetter(this, "OptionsPanel", () => require("devtools/client/framework/toolbox-options").OptionsPanel);
 loader.lazyGetter(this, "InspectorPanel", () => require("devtools/client/inspector/inspector-panel").InspectorPanel);
@@ -36,17 +36,17 @@ const canvasDebuggerProps = "chrome://de
 const webAudioEditorProps = "chrome://devtools/locale/webaudioeditor.properties";
 const performanceProps = "chrome://devtools/locale/performance.properties";
 const netMonitorProps = "chrome://devtools/locale/netmonitor.properties";
 const storageProps = "chrome://devtools/locale/storage.properties";
 const scratchpadProps = "chrome://devtools/locale/scratchpad.properties";
 const memoryProps = "chrome://devtools/locale/memory.properties";
 
 loader.lazyGetter(this, "toolboxStrings", () => Services.strings.createBundle(toolboxProps));
-loader.lazyGetter(this, "performanceStrings",() => Services.strings.createBundle(performanceProps));
+loader.lazyGetter(this, "performanceStrings", () => Services.strings.createBundle(performanceProps));
 loader.lazyGetter(this, "webConsoleStrings", () => Services.strings.createBundle(webConsoleProps));
 loader.lazyGetter(this, "debuggerStrings", () => Services.strings.createBundle(debuggerProps));
 loader.lazyGetter(this, "styleEditorStrings", () => Services.strings.createBundle(styleEditorProps));
 loader.lazyGetter(this, "shaderEditorStrings", () => Services.strings.createBundle(shaderEditorProps));
 loader.lazyGetter(this, "canvasDebuggerStrings", () => Services.strings.createBundle(canvasDebuggerProps));
 loader.lazyGetter(this, "webAudioEditorStrings", () => Services.strings.createBundle(webAudioEditorProps));
 loader.lazyGetter(this, "inspectorStrings", () => Services.strings.createBundle(inspectorProps));
 loader.lazyGetter(this, "netMonitorStrings", () => Services.strings.createBundle(netMonitorProps));
@@ -66,39 +66,39 @@ Tools.options = {
   invertIconForLightTheme: true,
   bgTheme: "theme-body",
   label: l10n("options.label", toolboxStrings),
   iconOnly: true,
   panelLabel: l10n("options.panelLabel", toolboxStrings),
   tooltip: l10n("optionsButton.tooltip", toolboxStrings),
   inMenu: false,
 
-  isTargetSupported: function(target) {
+  isTargetSupported: function() {
     return true;
   },
 
   build: function(iframeWindow, toolbox) {
     return new OptionsPanel(iframeWindow, toolbox);
   }
-}
+};
 
 Tools.inspector = {
   id: "inspector",
   accesskey: l10n("inspector.accesskey", inspectorStrings),
   key: l10n("inspector.commandkey", inspectorStrings),
   ordinal: 1,
   modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
   icon: "chrome://devtools/skin/images/tool-inspector.svg",
   invertIconForLightTheme: true,
   url: "chrome://devtools/content/inspector/inspector.xul",
   label: l10n("inspector.label", inspectorStrings),
   panelLabel: l10n("inspector.panelLabel", inspectorStrings),
   get tooltip() {
     return l10n("inspector.tooltip2", inspectorStrings,
-    ( osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+" ) + this.key);
+    (osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") + this.key);
   },
   inMenu: true,
   commands: [
     "devtools/client/responsivedesign/resize-commands",
     "devtools/client/inspector/inspector-commands",
     "devtools/client/eyedropper/commands.js"
   ],
 
@@ -122,30 +122,31 @@ Tools.webConsole = {
   icon: "chrome://devtools/skin/images/tool-webconsole.svg",
   invertIconForLightTheme: true,
   url: "chrome://devtools/content/webconsole/webconsole.xul",
   label: l10n("ToolboxTabWebconsole.label", webConsoleStrings),
   menuLabel: l10n("MenuWebconsole.label", webConsoleStrings),
   panelLabel: l10n("ToolboxWebConsole.panelLabel", webConsoleStrings),
   get tooltip() {
     return l10n("ToolboxWebconsole.tooltip2", webConsoleStrings,
-    ( osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+" ) + this.key);
+    (osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") + this.key);
   },
   inMenu: true,
   commands: "devtools/client/webconsole/console-commands",
 
   preventClosingOnKey: true,
   onkey: function(panel, toolbox) {
-    if (toolbox.splitConsole)
+    if (toolbox.splitConsole) {
       return toolbox.focusConsoleInput();
+    }
 
     panel.focusInput();
   },
 
-  isTargetSupported: function(target) {
+  isTargetSupported: function() {
     return true;
   },
 
   build: function(iframeWindow, toolbox) {
     return new WebConsolePanel(iframeWindow, toolbox);
   }
 };
 
@@ -158,22 +159,22 @@ Tools.jsdebugger = {
   icon: "chrome://devtools/skin/images/tool-debugger.svg",
   invertIconForLightTheme: true,
   highlightedicon: "chrome://devtools/skin/images/tool-debugger-paused.svg",
   url: "chrome://devtools/content/debugger/debugger.xul",
   label: l10n("ToolboxDebugger.label", debuggerStrings),
   panelLabel: l10n("ToolboxDebugger.panelLabel", debuggerStrings),
   get tooltip() {
     return l10n("ToolboxDebugger.tooltip2", debuggerStrings,
-    ( osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+" ) + this.key);
+    (osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") + this.key);
   },
   inMenu: true,
   commands: "devtools/client/debugger/debugger-commands",
 
-  isTargetSupported: function(target) {
+  isTargetSupported: function() {
     return true;
   },
 
   build: function(iframeWindow, toolbox) {
     return new DebuggerPanel(iframeWindow, toolbox);
   }
 };
 
@@ -236,17 +237,17 @@ Tools.canvasDebugger = {
   tooltip: l10n("ToolboxCanvasDebugger.tooltip", canvasDebuggerStrings),
 
   // Hide the Canvas Debugger in the Add-on Debugger and Browser Toolbox
   // (bug 1047520).
   isTargetSupported: function(target) {
     return target.hasActor("canvas") && !target.chrome;
   },
 
-  build: function (iframeWindow, toolbox) {
+  build: function(iframeWindow, toolbox) {
     return new CanvasDebuggerPanel(iframeWindow, toolbox);
   }
 };
 
 Tools.performance = {
   id: "performance",
   ordinal: 7,
   icon: "chrome://devtools/skin/images/tool-profiler.svg",
@@ -260,42 +261,42 @@ Tools.performance = {
     return l10n("performance.tooltip", performanceStrings,
     "Shift+" + functionkey(this.key));
   },
   accesskey: l10n("performance.accesskey", performanceStrings),
   key: l10n("performance.commandkey", performanceStrings),
   modifiers: "shift",
   inMenu: true,
 
-  isTargetSupported: function (target) {
+  isTargetSupported: function(target) {
     return target.hasActor("profiler");
   },
 
-  build: function (frame, target) {
+  build: function(frame, target) {
     return new PerformancePanel(frame, target);
   }
 };
 
 Tools.memory = {
   id: "memory",
   ordinal: 8,
   icon: "chrome://devtools/skin/images/tool-memory.svg",
   invertIconForLightTheme: true,
   highlightedicon: "chrome://devtools/skin/images/tool-memory-active.svg",
   url: "chrome://devtools/content/memory/memory.xhtml",
   visibilityswitch: "devtools.memory.enabled",
   label: l10n("memory.label", memoryStrings),
   panelLabel: l10n("memory.panelLabel", memoryStrings),
   tooltip: l10n("memory.tooltip", memoryStrings),
 
-  isTargetSupported: function (target) {
+  isTargetSupported: function(target) {
     return target.getTrait("heapSnapshots");
   },
 
-  build: function (frame, target) {
+  build: function(frame, target) {
     return new MemoryPanel(frame, target);
   }
 };
 
 Tools.netMonitor = {
   id: "netmonitor",
   accesskey: l10n("netmonitor.accesskey", netMonitorStrings),
   key: l10n("netmonitor.commandkey", netMonitorStrings),
@@ -304,17 +305,17 @@ Tools.netMonitor = {
   visibilityswitch: "devtools.netmonitor.enabled",
   icon: "chrome://devtools/skin/images/tool-network.svg",
   invertIconForLightTheme: true,
   url: "chrome://devtools/content/netmonitor/netmonitor.xul",
   label: l10n("netmonitor.label", netMonitorStrings),
   panelLabel: l10n("netmonitor.panelLabel", netMonitorStrings),
   get tooltip() {
     return l10n("netmonitor.tooltip2", netMonitorStrings,
-    ( osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+" ) + this.key);
+    (osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") + this.key);
   },
   inMenu: true,
 
   isTargetSupported: function(target) {
     return target.getTrait("networkMonitor");
   },
 
   build: function(iframeWindow, toolbox) {
@@ -338,18 +339,17 @@ Tools.storage = {
   get tooltip() {
     return l10n("storage.tooltip3", storageStrings,
     "Shift+" + functionkey(this.key));
   },
   inMenu: true,
 
   isTargetSupported: function(target) {
     return target.isLocalTab ||
-           ( target.hasActor("storage") &&
-             target.getTrait("storageInspector") );
+           (target.hasActor("storage") && target.getTrait("storageInspector"));
   },
 
   build: function(iframeWindow, toolbox) {
     return new StoragePanel(iframeWindow, toolbox);
   }
 };
 
 Tools.webAudioEditor = {
@@ -437,23 +437,21 @@ exports.defaultThemes = [
  * Lookup l10n string from a string bundle.
  *
  * @param {string} name
  *        The key to lookup.
  * @param {StringBundle} bundle
  *        The key to lookup.
  * @returns A localized version of the given key.
  */
-function l10n(name, bundle, arg)
-{
+function l10n(name, bundle, arg) {
   try {
     return arg ? bundle.formatStringFromName(name, [arg], 1)
     : bundle.GetStringFromName(name);
   } catch (ex) {
     Services.console.logStringMessage("Error reading '" + name + "'");
     throw new Error("l10n error with " + name);
   }
 }
 
-function functionkey(shortkey)
-{
+function functionkey(shortkey) {
   return shortkey.split("_")[1];
 }
--- a/devtools/client/devtools-clhandler.js
+++ b/devtools/client/devtools-clhandler.js
@@ -1,22 +1,25 @@
 /* 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/. */
+/* globals BrowserToolboxProcess */
 
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+"use strict";
+
+const { interfaces: Ci, utils: Cu } = Components;
 const kDebuggerPrefs = [
   "devtools.debugger.remote-enabled",
   "devtools.chrome.enabled"
 ];
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
 
-function devtoolsCommandlineHandler() {
-}
+function devtoolsCommandlineHandler() {}
+
 devtoolsCommandlineHandler.prototype = {
   handle: function(cmdLine) {
     let consoleFlag = cmdLine.handleFlag("jsconsole", false);
     let debuggerFlag = cmdLine.handleFlag("jsdebugger", false);
     let devtoolsFlag = cmdLine.handleFlag("devtools", false);
 
     if (consoleFlag) {
       this.handleConsoleFlag(cmdLine);
@@ -26,17 +29,17 @@ devtoolsCommandlineHandler.prototype = {
     }
     if (devtoolsFlag) {
       this.handleDevToolsFlag();
     }
     let debuggerServerFlag;
     try {
       debuggerServerFlag =
         cmdLine.handleFlagWithParam("start-debugger-server", false);
-    } catch(e) {
+    } catch (e) {
       // We get an error if the option is given but not followed by a value.
       // By catching and trying again, the value is effectively optional.
       debuggerServerFlag = cmdLine.handleFlag("start-debugger-server", false);
     }
     if (debuggerServerFlag) {
       this.handleDebuggerServerFlag(cmdLine, debuggerServerFlag);
     }
   },
@@ -46,46 +49,50 @@ devtoolsCommandlineHandler.prototype = {
     if (!window) {
       let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
       // Load the browser devtools main module as the loader's main module.
       Cu.import("resource://devtools/client/framework/gDevTools.jsm");
       let hudservice = require("devtools/client/webconsole/hudservice");
       let { console } = Cu.import("resource://gre/modules/Console.jsm", {});
       hudservice.toggleBrowserConsole().then(null, console.error);
     } else {
-      window.focus(); // the Browser Console was already open
+      // the Browser Console was already open
+      window.focus();
     }
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
       cmdLine.preventDefault = true;
     }
   },
 
   // Open the toolbox on the selected tab once the browser starts up.
   handleDevToolsFlag: function() {
     Services.obs.addObserver(function onStartup(window) {
-      Services.obs.removeObserver(onStartup, "browser-delayed-startup-finished");
+      Services.obs.removeObserver(onStartup,
+                                  "browser-delayed-startup-finished");
       const {gDevTools} = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
       const {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
       let target = devtools.TargetFactory.forTab(window.gBrowser.selectedTab);
       gDevTools.showToolbox(target);
     }, "browser-delayed-startup-finished", false);
   },
 
   _isRemoteDebuggingEnabled() {
     let remoteDebuggingEnabled = false;
     try {
-      remoteDebuggingEnabled = kDebuggerPrefs.every((pref) => Services.prefs.getBoolPref(pref));
+      remoteDebuggingEnabled = kDebuggerPrefs.every(pref => {
+        return Services.prefs.getBoolPref(pref);
+      });
     } catch (ex) {
       Cu.reportError(ex);
       return false;
     }
     if (!remoteDebuggingEnabled) {
-      let errorMsg = "Could not run chrome debugger! You need the following prefs " +
-                     "to be set to true: " + kDebuggerPrefs.join(", ");
+      let errorMsg = "Could not run chrome debugger! You need the following " +
+                     "prefs to be set to true: " + kDebuggerPrefs.join(", ");
       Cu.reportError(errorMsg);
       // Dump as well, as we're doing this from a commandline, make sure people
       // don't miss it:
       dump(errorMsg + "\n");
     }
     return remoteDebuggingEnabled;
   },
 
@@ -126,29 +133,30 @@ devtoolsCommandlineHandler.prototype = {
       debuggerServer.init();
       debuggerServer.addBrowserActors();
       debuggerServer.allowChromeProcess = true;
 
       let listener = debuggerServer.createListener();
       listener.portOrPath = portOrPath;
       listener.open();
       dump("Started debugger server on " + portOrPath + "\n");
-    } catch(e) {
+    } catch (e) {
       dump("Unable to start debugger server on " + portOrPath + ": " + e);
     }
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
       cmdLine.preventDefault = true;
     }
   },
 
-  helpInfo : "  --jsconsole        Open the Browser Console.\n" +
-             "  --jsdebugger       Open the Browser Toolbox.\n" +
-             "  --devtools         Open DevTools on initial load.\n" +
-             "  --start-debugger-server [port|path] " +
-             "Start the debugger server on a TCP port or " +
-             "Unix domain socket path.  Defaults to TCP port 6000.\n",
+  helpInfo: "  --jsconsole        Open the Browser Console.\n" +
+            "  --jsdebugger       Open the Browser Toolbox.\n" +
+            "  --devtools         Open DevTools on initial load.\n" +
+            "  --start-debugger-server [port|path] " +
+            "Start the debugger server on a TCP port or " +
+            "Unix domain socket path.  Defaults to TCP port 6000.\n",
 
   classID: Components.ID("{9e9a9283-0ce9-4e4a-8f1c-ba129a032c32}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
 };
 
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([devtoolsCommandlineHandler]);
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory(
+  [devtoolsCommandlineHandler]);
--- a/devtools/client/main.js
+++ b/devtools/client/main.js
@@ -22,17 +22,17 @@ exports.Tools = require("devtools/client
 Object.defineProperty(exports, "Toolbox", {
   get: () => require("devtools/client/framework/toolbox").Toolbox
 });
 Object.defineProperty(exports, "TargetFactory", {
   get: () => require("devtools/client/framework/target").TargetFactory
 });
 
 const unloadObserver = {
-  observe: function(subject, topic, data) {
+  observe: function(subject) {
     if (subject.wrappedJSObject === require("@loader/unload")) {
       Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy");
       for (let definition of gDevTools.getToolDefinitionArray()) {
         gDevTools.unregisterTool(definition.id);
       }
       for (let definition of gDevTools.getThemeDefinitionArray()) {
         gDevTools.unregisterTheme(definition.id);
       }