Bug 1478572 - Turn on ESLint in mail/components/devtools. r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 01 Aug 2018 17:46:29 +1200
changeset 32727 970e484cd96223466694de43611a99b9be6e2e51
parent 32726 a0852e1d7ad8f8f4e4404ccc826ac82f2dad6dfa
child 32728 98f869c1bcd5f0594e22b98c19d8ed8790cb517a
push id386
push userclokep@gmail.com
push dateTue, 23 Oct 2018 00:48:12 +0000
reviewersaceman
bugs1478572
Bug 1478572 - Turn on ESLint in mail/components/devtools. r=aceman
.eslintignore
mail/components/devtools/devtools-loader.js
mail/components/devtools/tb-root-actor.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -37,16 +37,17 @@ mail/installer/**
 mail/locales/**
 mail/test/**
 mail/themes/**
 
 # mail/components exclusions
 mail/components/*
 !mail/components/about-support
 !mail/components/accountcreation
+!mail/components/devtools
 !mail/components/extensions
 
 # calendar/ exclusions
 
 # prefs files
 calendar/lightning/content/lightning.js
 calendar/locales/en-US/lightning-l10n.js
 
--- a/mail/components/devtools/devtools-loader.js
+++ b/mail/components/devtools/devtools-loader.js
@@ -9,40 +9,39 @@ ChromeUtils.defineModuleGetter(this, "Se
 
 function DevToolsStartup() {}
 
 DevToolsStartup.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsICommandLineHandler]),
   classID: Components.ID("{089694e9-106a-4704-abf7-62a88545e194}"),
 
   helpInfo: "",
-  handle: function (cmdLine) {
+  handle(cmdLine) {
     this.initialize();
 
     // We want to overwrite the -devtools flag and open the toolbox instead
     let devtoolsFlag = cmdLine.handleFlag("devtools", false);
     if (devtoolsFlag) {
         this.handleDevToolsFlag(cmdLine);
     }
   },
 
-  handleDevToolsFlag: function (cmdLine) {
+  handleDevToolsFlag(cmdLine) {
     ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm");
     BrowserToolboxProcess.init();
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
       cmdLine.preventDefault = true;
     }
   },
 
-  initialize: function() {
+  initialize() {
     var { devtools, require, DevToolsLoader } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
     var { DebuggerServer } = require("devtools/server/main");
     var { gDevTools } = require("devtools/client/framework/devtools");
-    var { HUDService } = require("devtools/client/webconsole/hudservice");
 
     if (DebuggerServer.chromeWindowType != "mail:3pane") {
       // Set up the server chrome window type, make sure it can't be set
       Object.defineProperty(DebuggerServer, "chromeWindowType", {
         get: () => "mail:3pane",
         set: () => {},
         configurable: true
       });
--- a/mail/components/devtools/tb-root-actor.js
+++ b/mail/components/devtools/tb-root-actor.js
@@ -1,21 +1,22 @@
 /* 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 require, exports */
+
 /**
  * Actors for Thunderbird Developer Tools, for example the root actor or tab
  * list actor.
  */
 
-var { Ci, Cc } = require("chrome");
 var Services = require("Services");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
-var promise = require('promise');
+var promise = require("promise");
 var { RootActor } = require("devtools/server/actors/root");
 var { DebuggerServer } = require("devtools/server/main");
 var { BrowserTabList, BrowserTabActor, BrowserAddonList } = require("devtools/server/actors/webbrowser");
 
 /**
  * Create the root actor for Thunderbird.
  *
  * @param aConnection       The debugger connection to create the actor for.
@@ -74,17 +75,17 @@ function getChromeWindowTypes() {
   });
 }
 
 /**
  * Returns the window type of the passed window.
  */
 function appShellDOMWindowType(aWindow) {
   // This is what nsIWindowMediator's enumerator checks.
-  return aWindow.document.documentElement.getAttribute('windowtype');
+  return aWindow.document.documentElement.getAttribute("windowtype");
 }
 
 /**
  * Send a debugger shutdown event to all main windows.
  */
 function sendShutdownEvent() {
   let windowTypes = getChromeWindowTypes();
   for (let type of windowTypes) {
@@ -122,55 +123,55 @@ TBTabList.prototype = {
   _mustNotify: false,
   _listeningToMediator: false,
 
   get onListChanged() {
     return this._onListChanged;
   },
 
   set onListChanged(v) {
-    if (v !== null && typeof v !== 'function') {
+    if (v !== null && typeof v !== "function") {
       throw Error("onListChanged property may only be set to 'null' or a function");
     }
     this._onListChanged = v;
     this._checkListening();
   },
 
-  _checkListening: function() {
+  _checkListening() {
     let shouldListenToMediator =
         ((this._onListChanged && this._mustNotify) ||
          this._actorByBrowser.size > 0);
 
     if (this._listeningToMediator !== shouldListenToMediator) {
       let op = shouldListenToMediator ? "addListener" : "removeListener";
       Services.wm[op](this);
       this._listeningToMediator = shouldListenToMediator;
     }
   },
 
-  _notifyListChanged: function() {
+  _notifyListChanged() {
     if (this._onListChanged && this._mustNotify) {
       this._onListChanged();
       this._mustNotify = false;
     }
   },
 
-  _getTopWindow: function() {
+  _getTopWindow() {
     let winIter = Services.wm.getZOrderDOMWindowEnumerator(null, true);
     while (winIter.hasMoreElements()) {
       let win = winIter.getNext();
       if (this._checkedWindows.has(appShellDOMWindowType(win))) {
         // This is one of our windows, return it
         return win;
       }
     }
     return null;
   },
 
-  getList: function() {
+  getList() {
     let topWindow = this._getTopWindow();
 
     // Look for all browser elements in all the windows we care about
     for (let winName of this._checkedWindows) {
       let winIter = Services.wm.getEnumerator(winName);
       while (winIter.hasMoreElements()) {
         let win = winIter.getNext();
         let foundSelected = false;
@@ -238,31 +239,31 @@ TBTabList.prototype = {
     // a nsIWindowMediatorListener's onCloseWindow hook (bug 873589), so
     // handle the close in a different tick.
     Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
       let shouldNotify = false;
 
       // Scan the whole map for browsers that were in this window.
       for (let [browser, actor] of this._actorByBrowser) {
         // The browser document of a closed window has no default view.
-        if (!browser.ownerDocument.defaultView) {
+        if (!browser.ownerGlobal) {
           this._actorByBrowser.delete(browser);
           actor.exit();
           shouldNotify = true;
         }
       }
 
       if (shouldNotify) {
         this._notifyListChanged();
       }
       this._checkListening();
     }, "TBTabList.prototype.onCloseWindow's delayed body"), 0);
   }, "TBTabList.prototype.onCloseWindow"),
 
-  onWindowTitleChange: function() {}
+  onWindowTitleChange() {}
 };
 
 exports.register = function(handle) {
   handle.setRootActor(createRootActor);
 };
 
 exports.unregister = function(handle) {
   handle.setRootActor(null);