Bug 1256772 - Fix ESLint issues in devtools/client/webconsole/jsterm.js; r?linclark draft
authorgasolin <gasolin@gmail.com>
Thu, 07 Apr 2016 14:43:39 +0800
changeset 352375 6559e9c2e4d6d46804f0ee4662588f063cc8637e
parent 352373 61de4a9de8a3cc5fe40da166d611a9c5b221dca6
child 518648 f3a0fc54804db8341be61fae033b98d4702495d7
push id15689
push userbmo:gasolin@mozilla.com
push dateMon, 18 Apr 2016 02:41:25 +0000
reviewerslinclark
bugs1256772
milestone48.0a1
Bug 1256772 - Fix ESLint issues in devtools/client/webconsole/jsterm.js; r?linclark MozReview-Commit-ID: 4fS6PsBGORI
.eslintignore
devtools/client/webconsole/jsterm.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -100,16 +100,17 @@ devtools/client/promisedebugger/**
 devtools/client/responsivedesign/**
 devtools/client/scratchpad/**
 devtools/client/shadereditor/**
 devtools/client/shared/**
 devtools/client/sourceeditor/**
 devtools/client/webaudioeditor/**
 devtools/client/webconsole/**
 !devtools/client/webconsole/panel.js
+!devtools/client/webconsole/jsterm.js
 devtools/client/webide/**
 devtools/server/**
 devtools/shared/*.js
 devtools/shared/*.jsm
 devtools/shared/apps/**
 devtools/shared/client/**
 devtools/shared/discovery/**
 devtools/shared/gcli/**
--- a/devtools/client/webconsole/jsterm.js
+++ b/devtools/client/webconsole/jsterm.js
@@ -1,19 +1,19 @@
 /* -*- 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/. */
 
 "use strict";
 
-const {Cc, Ci, Cu} = require("chrome");
+const {Ci, Cu} = require("chrome");
 
-const {Utils: WebConsoleUtils, CONSOLE_WORKER_IDS} =
+const {Utils: WebConsoleUtils} =
   require("devtools/shared/webconsole/utils");
 const promise = require("promise");
 const Debugger = require("Debugger");
 const Services = require("Services");
 
 loader.lazyServiceGetter(this, "clipboardHelper",
                          "@mozilla.org/widget/clipboardhelper;1",
                          "nsIClipboardHelper");
@@ -310,28 +310,28 @@ JSTerm.prototype = {
     let errorMessage = response.exceptionMessage;
     let errorDocURL = response.exceptionDocURL;
 
     let errorDocLink;
     if (errorDocURL) {
       errorMessage += " ";
       errorDocLink = this.hud.document.createElementNS(XHTML_NS, "a");
       errorDocLink.className = "learn-more-link webconsole-learn-more-link";
-      errorDocLink.textContent = "[" + l10n.getStr("webConsoleMoreInfoLabel") + "]";
+      errorDocLink.textContent = `[${l10n.getStr("webConsoleMoreInfoLabel")}]`;
       errorDocLink.title = errorDocURL;
       errorDocLink.href = "#";
       errorDocLink.draggable = false;
       errorDocLink.addEventListener("click", () => {
         this.hud.owner.openLink(errorDocURL);
       });
     }
 
     // Wrap thrown strings in Error objects, so `throw "foo"` outputs
     // "Error: foo"
-    if (typeof(response.exception) === "string") {
+    if (typeof response.exception === "string") {
       errorMessage = new Error(errorMessage).toString();
     }
     let result = response.result;
     let helperResult = response.helperResult;
     let helperHasRawOutput = !!(helperResult || {}).rawOutput;
 
     if (helperResult && helperResult.type) {
       switch (helperResult.type) {
@@ -367,17 +367,18 @@ JSTerm.prototype = {
     // Hide undefined results coming from JSTerm helper functions.
     if (!errorMessage && result && typeof result == "object" &&
         result.type == "undefined" &&
         helperResult && !helperHasRawOutput) {
       callback && callback();
       return;
     }
 
-    let msg = new Messages.JavaScriptEvalOutput(response, errorMessage, errorDocLink);
+    let msg = new Messages.JavaScriptEvalOutput(response,
+                                                errorMessage, errorDocLink);
     this.hud.output.addMessage(msg);
 
     if (callback) {
       let oldFlushCallback = this.hud._flushCallback;
       this.hud._flushCallback = () => {
         callback(msg.element);
         if (oldFlushCallback) {
           oldFlushCallback();
@@ -419,17 +420,17 @@ JSTerm.prototype = {
       if (callback) {
         callback(msg);
       }
     };
 
     // attempt to execute the content of the inputNode
     executeString = executeString || this.getInputValue();
     if (!executeString) {
-      return;
+      return null;
     }
 
     let selectedNodeActor = null;
     let inspectorSelection = this.hud.owner.getInspectorSelection();
     if (inspectorSelection && inspectorSelection.nodeFront) {
       selectedNodeActor = inspectorSelection.nodeFront.actorID;
     }
 
@@ -1017,16 +1018,17 @@ JSTerm.prototype = {
    * @private
    */
   _blurEventHandler: function() {
     if (this.autocompletePopup) {
       this.clearCompletion();
     }
   },
 
+  /* eslint-disable complexity */
   /**
    * The inputNode "keypress" event handler.
    *
    * @private
    * @param nsIDOMEvent event
    */
   _keyPress: function(event) {
     let inputNode = this.inputNode;
@@ -1208,17 +1210,17 @@ JSTerm.prototype = {
         break;
 
       case Ci.nsIDOMKeyEvent.DOM_VK_LEFT:
         if (this.autocompletePopup.isOpen || this.lastCompletion.value) {
           this.clearCompletion();
         }
         break;
 
-      case Ci.nsIDOMKeyEvent.DOM_VK_RIGHT: {
+      case Ci.nsIDOMKeyEvent.DOM_VK_RIGHT:
         let cursorAtTheEnd = this.inputNode.selectionStart ==
                              this.inputNode.selectionEnd &&
                              this.inputNode.selectionStart ==
                              inputValue.length;
         let haveSuggestion = this.autocompletePopup.isOpen ||
                              this.lastCompletion.value;
         let useCompletion = cursorAtTheEnd || this._autocompletePopupNavigated;
         if (haveSuggestion && useCompletion &&
@@ -1226,32 +1228,33 @@ JSTerm.prototype = {
             this.lastCompletion.value &&
             this.acceptProposedCompletion()) {
           event.preventDefault();
         }
         if (this.autocompletePopup.isOpen) {
           this.clearCompletion();
         }
         break;
-      }
+
       case Ci.nsIDOMKeyEvent.DOM_VK_TAB:
         // Generate a completion and accept the first proposed value.
         if (this.complete(this.COMPLETE_HINT_ONLY) &&
             this.lastCompletion &&
             this.acceptProposedCompletion()) {
           event.preventDefault();
         } else if (this._inputChanged) {
           this.updateCompleteNode(l10n.getStr("Autocomplete.blank"));
           event.preventDefault();
         }
         break;
       default:
         break;
     }
   },
+  /* eslint-enable complexity */
 
   /**
    * The inputNode "focus" event handler.
    * @private
    */
   _focusEventHandler: function() {
     this._inputChanged = false;
   },