Bug 1170757-Enabled eslint dot-location + no-empty rules for Hello, r=dmose
authorFernando R. Sela <frsela@tid.es>
Wed, 05 Aug 2015 11:40:53 -0700
changeset 288057 e72e9e0222d830f7b0672b39fd749cfd1b5c55c9
parent 288056 fc9cae9a0f604881f1e6157dc72c250870e13a01
child 288058 0f956bd768d7584f6fdee77936ec069b573ddfbe
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmose
bugs1170757
milestone42.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 1170757-Enabled eslint dot-location + no-empty rules for Hello, r=dmose
browser/components/loop/.eslintrc
browser/components/loop/content/js/roomStore.js
browser/components/loop/modules/CardDavImporter.jsm
browser/components/loop/modules/GoogleImporter.jsm
browser/components/loop/modules/MozLoopPushHandler.jsm
browser/components/loop/test/desktop-local/panel_test.js
browser/components/loop/test/desktop-local/roomViews_test.js
browser/components/loop/test/mochitest/browser_loop_fxa_server.js
browser/components/loop/test/mochitest/head.js
browser/components/loop/test/shared/activeRoomStore_test.js
browser/components/loop/test/shared/otSdkDriver_test.js
browser/components/loop/test/standalone/standaloneRoomViews_test.js
browser/components/loop/test/xpcshell/test_loopservice_token_save.js
--- a/browser/components/loop/.eslintrc
+++ b/browser/components/loop/.eslintrc
@@ -37,31 +37,31 @@
 
     // Eslint built-in rules are documented at <http://eslint.org/docs/rules/>
     "callback-return": 0,         // TBD
     "camelcase": 0,               // TODO: set to 2
     "comma-spacing": 2,
     "computed-property-spacing": [2, "never"],
     "consistent-return": 0,       // TODO: set to 2
     "curly": [2, "all"],
-    dot-location: 0,              // [2, property],
+    "dot-location": [2, "property"],
     "eol-last": 2,
     "eqeqeq": 0,                  // TBD. Might need to be separate for content & chrome
     "key-spacing": [2, {"beforeColon": false, "afterColon": true }],
     "linebreak-style": [2, "unix"],
     "new-cap": 0,                 // TODO: set to 2
     "new-parens": 2,
     "no-alert": 2,
     "no-array-constructor": 2,
     "no-caller": 2,
     "no-catch-shadow": 0,         // TODO: set to 2
     "no-class-assign": 2,
     "no-const-assign": 2,
     "no-console": 0,              // Leave as 0. We use console logging in content code.
-    "no-empty": 0,                // TODO: set to 2
+    "no-empty": 2,
     "no-empty-label": 2,
     "no-eval": 2,
     "no-extend-native": 2, // XXX
     "no-extra-bind": 0,           // Leave as 0
     "no-extra-parens": 0,         // TODO: (bug?) [2, "functions"],
     "no-implied-eval": 2,
     "no-invalid-this": 0,         // TBD
     "no-iterator": 2,
--- a/browser/components/loop/content/js/roomStore.js
+++ b/browser/components/loop/content/js/roomStore.js
@@ -514,17 +514,19 @@ loop.store = loop.store || {};
         // 2) a new URL is provided as of now,
         // 3) the URL data has changed.
         var diff = loop.shared.utils.objectDiff(oldRoomURL, newRoomURL);
         if (diff.added.length || diff.updated.length) {
           newRoomURL = _.extend(oldRoomURL || {}, newRoomURL);
           var isValidURL = false;
           try {
             isValidURL = new URL(newRoomURL.location);
-          } catch(ex) {}
+          } catch(ex) {
+            // URL may throw, default to false;
+          }
           if (isValidURL) {
             roomData.urls = [newRoomURL];
           }
         }
         // TODO: there currently is no clear UX defined on what to do when all
         // context data was cleared, e.g. when diff.removed contains all the
         // context properties. Until then, we can't deal with context removal here.
 
--- a/browser/components/loop/modules/CardDavImporter.jsm
+++ b/browser/components/loop/modules/CardDavImporter.jsm
@@ -104,18 +104,18 @@ this.CardDavImporter.prototype = {
 
       // Get list of contact URLs
       let body = "<d:propfind xmlns:d='DAV:'><d:prop><d:getetag />" +
                  "</d:prop></d:propfind>";
       let abook = yield this._davPromise("PROPFIND", startURL, auth,
                                          DEPTH_RESOURCE_AND_CHILDREN, body);
 
       // Build multiget REPORT body from URLs in PROPFIND result
-      let contactElements = abook.responseXML.
-                            getElementsByTagNameNS("DAV:", "href");
+      let contactElements = abook.responseXML.getElementsByTagNameNS(
+                            "DAV:", "href");
 
       body = "<c:addressbook-multiget xmlns:d='DAV:' " +
              "xmlns:c='urn:ietf:params:xml:ns:carddav'>" +
              "<d:prop><d:getetag /> <c:address-data /></d:prop>\n";
 
       for (let element of contactElements) {
         let href = element.textContent;
         if (href.substr(-1) == "/") {
@@ -425,18 +425,18 @@ this.CardDavImporter.prototype = {
    * @param {String} body   Body to include in the WebDAV (HTTP) request
    *
    * @return {Object} Promise representing the request operation outcome.
    *                  If resolved, the resolution value is the XMLHttpRequest
    *                  that was used to perform the request.
    */
   _davPromise: function(method, url, auth, depth, body) {
     return new Promise((resolve, reject) => {
-      let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+      let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+                Ci.nsIXMLHttpRequest);
       let user = "";
       let password = "";
 
       if (auth.method == "basic") {
         user = auth.user;
         password = auth.password;
       }
 
--- a/browser/components/loop/modules/GoogleImporter.jsm
+++ b/browser/components/loop/modules/GoogleImporter.jsm
@@ -542,24 +542,28 @@ this.GoogleImporter.prototype = {
         } else if ("givenName" in contact) {
           contact.name = [contact.givenName[0]];
         } else if ("org" in contact) {
           contact.name = [contact.org[0]];
         } else {
           let email;
           try {
             email = getPreferred(contact);
-          } catch (ex) {}
+          } catch (ex) {
+            // Do nothing
+          }
           if (email) {
             contact.name = [email.value];
           } else {
             let tel;
             try {
               tel = getPreferred(contact, "tel");
-            } catch (ex) {}
+            } catch (ex) {
+              // Do nothing
+            }
             if (tel) {
               contact.name = [tel.value];
             }
           }
         }
       }
     }
 
--- a/browser/components/loop/modules/MozLoopPushHandler.jsm
+++ b/browser/components/loop/modules/MozLoopPushHandler.jsm
@@ -201,17 +201,19 @@ PushSocket.prototype = {
     // Do not pass through any callbacks after this point.
     this._onStart = function() {};
     this._onMsg = this._onStart;
     this._onClose = this._onStart;
 
     try {
       this._websocket.close(this._websocket.CLOSE_NORMAL);
     }
-    catch (e) {}
+    catch (e) {
+      // Do nothing
+    }
   }
 };
 
 
 /**
  * Create a RetryManager object. Class to handle retrying a UserAgent
  * to PushServer request following a retry back-off scheme managed by
  * this class. The current delay mechanism is to double the delay
@@ -778,23 +780,25 @@ let MozLoopPushHandler = {
       this._pushSocket = undefined;
       this._retryManager.retry(() => this._openSocket());
       return;
     };
 
     try {
       this.pushServerUri = Services.prefs.getCharPref("loop.debug.pushserver");
     }
-    catch (e) {}
+    catch (e) {
+      // Do nothing
+    }
 
     if (!this.pushServerUri) {
       // Get push server to use from the Loop server
       let pushUrlEndpoint = Services.prefs.getCharPref("loop.server") + "/push-server-config";
-      let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                  createInstance(Ci.nsIXMLHttpRequest);
+      let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+                Ci.nsIXMLHttpRequest);
       req.open("GET", pushUrlEndpoint);
       req.onload = () => {
         if (req.status >= 200 && req.status < 300) {
           let pushServerConfig;
           try {
             pushServerConfig = JSON.parse(req.responseText);
           } catch (e) {
             consoleLog.warn("PushHandler: Error parsing JSON response for push server URL");
--- a/browser/components/loop/test/desktop-local/panel_test.js
+++ b/browser/components/loop/test/desktop-local/panel_test.js
@@ -494,34 +494,38 @@ describe("loop.panel", function() {
         navigator.mozLoop.getLoopPref = function() {
           return true;
         };
         var view = createTestPanelView();
 
         try {
           TestUtils.findRenderedComponentWithType(view, loop.panel.GettingStartedView);
           sinon.assert.fail("Should not find the GettingStartedView if it has been seen");
-        } catch (ex) {}
+        } catch (ex) {
+          // Do nothing
+        }
       });
 
       it("should render a SignInRequestView when mozLoop.hasEncryptionKey is false", function() {
         fakeMozLoop.hasEncryptionKey = false;
 
         var view = createTestPanelView();
 
         TestUtils.findRenderedComponentWithType(view, loop.panel.SignInRequestView);
       });
 
       it("should render a SignInRequestView when mozLoop.hasEncryptionKey is true", function() {
         var view = createTestPanelView();
 
         try {
           TestUtils.findRenderedComponentWithType(view, loop.panel.SignInRequestView);
           sinon.assert.fail("Should not find the GettingStartedView if it has been seen");
-        } catch (ex) {}
+        } catch (ex) {
+          // Do nothing
+        }
       });
     });
   });
 
   describe("loop.panel.RoomEntry", function() {
     var dispatcher, roomData;
 
     beforeEach(function() {
--- a/browser/components/loop/test/desktop-local/roomViews_test.js
+++ b/browser/components/loop/test/desktop-local/roomViews_test.js
@@ -254,18 +254,18 @@ describe("loop.roomViews", function () {
         expect(view.refs.menu.props.show).to.eql(true);
       });
     });
 
     describe("Edit Context", function() {
       it("should show the 'Add some context' link", function() {
         view = mountTestComponent();
 
-        expect(view.getDOMNode().querySelector(".room-invitation-addcontext")).
-          to.not.eql(null);
+        expect(view.getDOMNode().querySelector(
+          ".room-invitation-addcontext")).to.not.eql(null);
       });
 
       it("should call a callback when the link is clicked", function() {
         var onAddContextClick = sinon.stub();
         view = mountTestComponent({
           onAddContextClick: onAddContextClick
         });
 
--- a/browser/components/loop/test/mochitest/browser_loop_fxa_server.js
+++ b/browser/components/loop/test/mochitest/browser_loop_fxa_server.js
@@ -88,33 +88,33 @@ add_task(function* token_request_invalid
   is(request.response, null, "Check token response body");
 });
 
 
 // Helper methods
 
 function promiseParams() {
   return new Promise((resolve, reject) => {
-    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+              Ci.nsIXMLHttpRequest);
     xhr.open("POST", BASE_URL + "/fxa-oauth/params", true);
     xhr.responseType = "json";
     xhr.addEventListener("load", () => {
       info("/fxa-oauth/params response:\n" + JSON.stringify(xhr.response, null, 4));
       resolve(xhr);
     });
     xhr.addEventListener("error", reject);
     xhr.send();
   });
 }
 
 function promiseToken(code, state) {
   return new Promise((resolve, reject) => {
-    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+              Ci.nsIXMLHttpRequest);
     xhr.open("POST", BASE_URL + "/fxa-oauth/token", true);
     xhr.setRequestHeader("Authorization", "Hawk ...");
     xhr.responseType = "json";
     xhr.addEventListener("load", () => {
       info("/fxa-oauth/token response:\n" + JSON.stringify(xhr.response, null, 4));
       resolve(xhr);
     });
     xhr.addEventListener("error", reject);
--- a/browser/components/loop/test/mochitest/head.js
+++ b/browser/components/loop/test/mochitest/head.js
@@ -126,18 +126,18 @@ function loadLoopPanel(aOverrideOptions 
   loopPanel.setAttribute("animate", "false");
 
   // Now get the actual API loaded into gMozLoopAPI.
   return promiseGetMozLoopAPI();
 }
 
 function promiseOAuthParamsSetup(baseURL, params) {
   return new Promise((resolve, reject) => {
-    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+              Ci.nsIXMLHttpRequest);
     xhr.open("POST", baseURL + "/setup_params", true);
     xhr.setRequestHeader("X-Params", JSON.stringify(params));
     xhr.addEventListener("load", () => resolve(xhr));
     xhr.addEventListener("error", error => reject(error));
     xhr.send();
   });
 }
 
@@ -168,18 +168,18 @@ function checkLoggedOutState() {
   checkFxAOAuthTokenData(null);
   const fxASessionPref = MozLoopServiceInternal.getSessionTokenPrefName(LOOP_SESSION_TYPE.FXA);
   is(Services.prefs.getPrefType(fxASessionPref), Services.prefs.PREF_INVALID,
      "FxA hawk session should be cleared anyways");
 }
 
 function promiseDeletedOAuthParams(baseURL) {
   return new Promise((resolve, reject) => {
-    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+              Ci.nsIXMLHttpRequest);
     xhr.open("DELETE", baseURL + "/setup_params", true);
     xhr.addEventListener("load", () => resolve(xhr));
     xhr.addEventListener("error", reject);
     xhr.send();
   });
 }
 
 function promiseObserverNotified(aTopic, aExpectedData = null) {
@@ -192,18 +192,18 @@ function promiseObserverNotified(aTopic,
   });
 }
 
 /**
  * Get the last registration on the test server.
  */
 function promiseOAuthGetRegistration(baseURL) {
   return new Promise((resolve, reject) => {
-    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                createInstance(Ci.nsIXMLHttpRequest);
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(
+              Ci.nsIXMLHttpRequest);
     xhr.open("GET", baseURL + "/get_registration", true);
     xhr.responseType = "json";
     xhr.addEventListener("load", () => resolve(xhr));
     xhr.addEventListener("error", reject);
     xhr.send();
   });
 }
 
--- a/browser/components/loop/test/shared/activeRoomStore_test.js
+++ b/browser/components/loop/test/shared/activeRoomStore_test.js
@@ -313,35 +313,34 @@ describe("loop.store.ActiveRoomStore", f
         roomOwner: "Alfred",
         roomUrl: "http://invalid"
       };
 
       store = new loop.store.ActiveRoomStore(dispatcher, {
         mozLoop: fakeMozLoop,
         sdkDriver: {}
       });
-      fakeMozLoop.rooms.get.
-        withArgs(fakeToken).
-        callsArgOnWith(1, // index of callback argument
+      fakeMozLoop.rooms.get.withArgs(fakeToken).callsArgOnWith(
+        1, // index of callback argument
         store, // |this| to call it on
         null, // args to call the callback with...
         fakeRoomData
       );
     });
 
     it("should set the state to `GATHER`",
       function() {
         store.setupWindowData(new sharedActions.SetupWindowData({
           windowId: "42",
           type: "room",
           roomToken: fakeToken
         }));
 
-        expect(store.getStoreState()).
-          to.have.property("roomState", ROOM_STATES.GATHER);
+        expect(store.getStoreState()).to.have.property(
+          "roomState", ROOM_STATES.GATHER);
       });
 
     it("should dispatch an SetupRoomInfo action if the get is successful",
       function() {
         store.setupWindowData(new sharedActions.SetupWindowData({
           windowId: "42",
           type: "room",
           roomToken: fakeToken
@@ -372,19 +371,18 @@ describe("loop.store.ActiveRoomStore", f
         sinon.assert.calledWithExactly(dispatcher.dispatch,
           new sharedActions.JoinRoom());
       });
 
     it("should dispatch a RoomFailure action if the get fails",
       function() {
 
         var fakeError = new Error("fake error");
-        fakeMozLoop.rooms.get.
-          withArgs(fakeToken).
-          callsArgOnWith(1, // index of callback argument
+        fakeMozLoop.rooms.get.withArgs(fakeToken).callsArgOnWith(
+          1, // index of callback argument
           store, // |this| to call it on
           fakeError); // args to call the callback with...
 
         store.setupWindowData(new sharedActions.SetupWindowData({
           windowId: "42",
           type: "room",
           roomToken: fakeToken
         }));
--- a/browser/components/loop/test/shared/otSdkDriver_test.js
+++ b/browser/components/loop/test/shared/otSdkDriver_test.js
@@ -333,18 +333,18 @@ describe("loop.OTSdkDriver", function ()
       sinon.assert.calledWith(session.connect, "1234567890", "1357924680");
     });
 
     it("should set the two-way media start time to 'uninitialized' " +
        "when sessionData.sendTwoWayMediaTelemetry is true'", function() {
       driver.connectSession(_.extend(sessionData,
                                      {sendTwoWayMediaTelemetry: true}));
 
-      expect(driver._getTwoWayMediaStartTime()).to.
-        eql(driver.CONNECTION_START_TIME_UNINITIALIZED);
+      expect(driver._getTwoWayMediaStartTime()).to.eql(
+        driver.CONNECTION_START_TIME_UNINITIALIZED);
     });
 
     describe("On connection complete", function() {
       beforeEach(function() {
         sandbox.stub(window.console, "error");
       });
 
       it("should publish the stream if the publisher is ready", function() {
@@ -451,35 +451,35 @@ describe("loop.OTSdkDriver", function ()
       var startTime = 1;
       driver._sendTwoWayMediaTelemetry = true;
       driver._setTwoWayMediaStartTime(startTime);
       sandbox.stub(performance, "now");
       sandbox.stub(driver, "_noteConnectionLengthIfNeeded");
 
       driver.disconnectSession();
 
-      expect(driver._getTwoWayMediaStartTime()).to.
-        eql(driver.CONNECTION_START_TIME_UNINITIALIZED);
+      expect(driver._getTwoWayMediaStartTime()).to.eql(
+        driver.CONNECTION_START_TIME_UNINITIALIZED);
     });
   });
 
   describe("#_noteConnectionLengthIfNeeded", function() {
     var startTimeMS;
     beforeEach(function() {
       startTimeMS = 1;
       driver._sendTwoWayMediaTelemetry = true;
       driver._setTwoWayMediaStartTime(startTimeMS);
     });
 
     it("should set two-way media start time to CONNECTION_START_TIME_ALREADY_NOTED", function() {
       var endTimeMS = 3;
       driver._noteConnectionLengthIfNeeded(startTimeMS, endTimeMS);
 
-      expect(driver._getTwoWayMediaStartTime()).to.
-        eql(driver.CONNECTION_START_TIME_ALREADY_NOTED);
+      expect(driver._getTwoWayMediaStartTime()).to.eql(
+        driver.CONNECTION_START_TIME_ALREADY_NOTED);
     });
 
     it("should call mozLoop.noteConnectionLength with SHORTER_THAN_10S for calls less than 10s", function() {
       var endTimeMS = 9000;
 
       driver._noteConnectionLengthIfNeeded(startTimeMS, endTimeMS);
 
       sinon.assert.calledOnce(mozLoop.telemetryAddValue);
--- a/browser/components/loop/test/standalone/standaloneRoomViews_test.js
+++ b/browser/components/loop/test/standalone/standaloneRoomViews_test.js
@@ -553,18 +553,18 @@ describe("loop.standaloneRoomViews", fun
         it("should render a local avatar if the room HAS_PARTICIPANTS and" +
           " .videoMuted is true",
           function() {
             activeRoomStore.setStoreState({
               roomState: ROOM_STATES.HAS_PARTICIPANTS,
               videoMuted: true
             });
 
-            expect(view.getDOMNode().querySelector(".local .avatar")).
-              not.eql(null);
+            expect(view.getDOMNode().querySelector(".local .avatar")).not.eql(
+              null);
           });
       });
 
       describe("Marketplace hidden iframe", function() {
 
         it("should set src when the store state change",
            function(done) {
 
--- a/browser/components/loop/test/xpcshell/test_loopservice_token_save.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_token_save.js
@@ -18,16 +18,17 @@ add_test(function test_registration_retu
     response.finish();
   });
 
   MozLoopService.promiseRegisteredWithServers().then(() => {
     var hawkSessionPref;
     try {
       hawkSessionPref = Services.prefs.getCharPref("loop.hawk-session-token");
     } catch (ex) {
+      // Do nothing
     }
     Assert.equal(hawkSessionPref, fakeSessionToken, "Should store" +
       " Hawk-Session-Token header contents in loop.hawk-session-token pref");
 
     run_next_test();
   }, err => {
     do_throw("shouldn't error on a successful request");
   });