From 0456b4d6ebb3b3d339a70b48f12ee5de332db089 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Thu, 27 Apr 2017 17:19:17 +0200 Subject: [PATCH] Bug 1360237 - Fix eslint issues for devtools/client/framework/devtools.js. r=pbro MozReview-Commit-ID: 8mWiLTsH4Sb --HG-- extra : rebase_source : af636828a21a8bfa11287a5eeae4ade08de45056 --- .eslintignore | 1 + devtools/client/framework/devtools.js | 55 ++++++++++++--------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9e35caacbf5a..e4f61c9eaae5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -83,6 +83,7 @@ devtools/client/canvasdebugger/** devtools/client/commandline/** devtools/client/debugger/** devtools/client/framework/** +!devtools/client/framework/devtools.js !devtools/client/framework/selection.js !devtools/client/framework/target* !devtools/client/framework/toolbox* diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index ed4c60d8f763..2c0c513de0ae 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -6,8 +6,6 @@ const {Cu} = require("chrome"); const Services = require("Services"); -const promise = require("promise"); -const defer = require("devtools/shared/defer"); // Load gDevToolsBrowser toolbox lazily as they need gDevTools to be fully initialized loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true); @@ -46,7 +44,7 @@ function DevTools() { // start registering all default tools and themes: create menuitems, keys, emit // related events. this.registerDefaults(); -}; +} DevTools.prototype = { // The windowtype of the main window, used in various tools. This may be set @@ -100,7 +98,7 @@ DevTools.prototype = { * markup from |url|, and also the toolbox containing the panel. * And returns an instance of ToolPanel (function|required) */ - registerTool: function DT_registerTool(toolDefinition) { + registerTool(toolDefinition) { let toolId = toolDefinition.id; if (!toolId || FORBIDDEN_IDS.has(toolId)) { @@ -130,17 +128,16 @@ DevTools.prototype = { * true to indicate that the call is due to app quit, so we should not * cause a cascade of costly events */ - unregisterTool: function DT_unregisterTool(tool, isQuitApplication) { + unregisterTool(tool, isQuitApplication) { let toolId = null; if (typeof tool == "string") { toolId = tool; tool = this._tools.get(tool); - } - else { + } else { let {Deprecated} = Cu.import("resource://gre/modules/Deprecated.jsm", {}); - Deprecated.warning("Deprecation WARNING: gDevTools.unregisterTool(tool) is deprecated. " + - "You should unregister a tool using its toolId: " + - "gDevTools.unregisterTool(toolId)."); + Deprecated.warning("Deprecation WARNING: gDevTools.unregisterTool(tool) is " + + "deprecated. You should unregister a tool using its toolId: " + + "gDevTools.unregisterTool(toolId)."); toolId = tool.id; } this._tools.delete(toolId); @@ -153,19 +150,19 @@ DevTools.prototype = { /** * Sorting function used for sorting tools based on their ordinals. */ - ordinalSort: function DT_ordinalSort(d1, d2) { + ordinalSort(d1, d2) { let o1 = (typeof d1.ordinal == "number") ? d1.ordinal : MAX_ORDINAL; let o2 = (typeof d2.ordinal == "number") ? d2.ordinal : MAX_ORDINAL; return o1 - o2; }, - getDefaultTools: function DT_getDefaultTools() { + getDefaultTools() { return DefaultTools.sort(this.ordinalSort); }, - getAdditionalTools: function DT_getAdditionalTools() { + getAdditionalTools() { let tools = []; - for (let [key, value] of this._tools) { + for (let [, value] of this._tools) { if (DefaultTools.indexOf(value) == -1) { tools.push(value); } @@ -186,7 +183,7 @@ DevTools.prototype = { * @return {ToolDefinition|null} tool * The ToolDefinition for the id or null. */ - getToolDefinition: function DT_getToolDefinition(toolId) { + getToolDefinition(toolId) { let tool = this._tools.get(toolId); if (!tool) { return null; @@ -206,7 +203,7 @@ DevTools.prototype = { * @return {Map} tools * A map of the the tool definitions registered in this instance */ - getToolDefinitionMap: function DT_getToolDefinitionMap() { + getToolDefinitionMap() { let tools = new Map(); for (let [id, definition] of this._tools) { @@ -226,7 +223,7 @@ DevTools.prototype = { * @return {Array} tools * A sorted array of the tool definitions registered in this instance */ - getToolDefinitionArray: function DT_getToolDefinitionArray() { + getToolDefinitionArray() { let definitions = []; for (let [id, definition] of this._tools) { @@ -260,7 +257,7 @@ DevTools.prototype = { * is unapplied. The function takes the current iframe window * and the new theme id as arguments (function) */ - registerTheme: function DT_registerTheme(themeDefinition) { + registerTheme(themeDefinition) { let themeId = themeDefinition.id; if (!themeId) { @@ -283,13 +280,12 @@ DevTools.prototype = { * @param {string|object} theme * Definition or the id of the theme to unregister. */ - unregisterTheme: function DT_unregisterTheme(theme) { + unregisterTheme(theme) { let themeId = null; if (typeof theme == "string") { themeId = theme; theme = this._themes.get(theme); - } - else { + } else { themeId = theme.id; } @@ -323,7 +319,7 @@ DevTools.prototype = { * @return {ThemeDefinition|null} theme * The ThemeDefinition for the id or null. */ - getThemeDefinition: function DT_getThemeDefinition(themeId) { + getThemeDefinition(themeId) { let theme = this._themes.get(themeId); if (!theme) { return null; @@ -337,7 +333,7 @@ DevTools.prototype = { * @return {Map} themes * A map of the the theme definitions registered in this instance */ - getThemeDefinitionMap: function DT_getThemeDefinitionMap() { + getThemeDefinitionMap() { let themes = new Map(); for (let [id, definition] of this._themes) { @@ -355,7 +351,7 @@ DevTools.prototype = { * @return {Array} themes * A sorted array of the theme definitions registered in this instance */ - getThemeDefinitionArray: function DT_getThemeDefinitionArray() { + getThemeDefinitionArray() { let definitions = []; for (let [id, definition] of this._themes) { @@ -390,7 +386,6 @@ DevTools.prototype = { showToolbox: Task.async(function* (target, toolId, hostType, hostOptions) { let toolbox = this._toolboxes.get(target); if (toolbox) { - if (hostType != null && toolbox.hostType != hostType) { yield toolbox.switchHost(hostType); } @@ -449,7 +444,7 @@ DevTools.prototype = { * @return {Toolbox} toolbox * The toolbox that is debugging the given target */ - getToolbox: function DT_getToolbox(target) { + getToolbox(target) { return this._toolboxes.get(target); }, @@ -482,17 +477,17 @@ DevTools.prototype = { * some cleanups to speed it up. Otherwise everything need to be * cleaned up in order to be able to load devtools again. */ - destroy: function ({ shuttingDown }) { + destroy({ shuttingDown }) { // Do not cleanup everything during firefox shutdown, but only when // devtools are reloaded via the add-on contribution workflow. if (!shuttingDown) { - for (let [target, toolbox] of this._toolboxes) { + for (let [, toolbox] of this._toolboxes) { toolbox.destroy(); } AboutDevTools.unregister(); } - for (let [key, tool] of this.getToolDefinitionMap()) { + for (let [key, ] of this.getToolDefinitionMap()) { this.unregisterTool(key, true); } @@ -508,7 +503,7 @@ DevTools.prototype = { /** * Iterator that yields each of the toolboxes. */ - *[Symbol.iterator ]() { + * [Symbol.iterator ]() { for (let toolbox of this._toolboxes) { yield toolbox; }