Bug 1181825 - Enable eslint rules for Loop: no-extra-boolean cast, no-redeclare, r=dmose
authorFernando Rodriguez Sela <frsela@tid.es>
Wed, 22 Jul 2015 21:47:04 -0700
changeset 254178 6940314afe11efbe5700629b2e74407513849625
parent 254177 4c5da00ecca14b8091c07c3515c0e92ee745e2ff
child 254179 1f77b78797d64fff20d2b1f2cf81b7abe7355c0c
child 254252 c442588b5ab5a0e5e020c015faa853a54f2cd738
push id29093
push usercbook@mozilla.com
push dateThu, 23 Jul 2015 09:53:14 +0000
treeherdermozilla-central@1f77b78797d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmose
bugs1181825
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 1181825 - Enable eslint rules for Loop: no-extra-boolean cast, no-redeclare, r=dmose
browser/components/loop/.eslintrc
browser/components/loop/content/js/contacts.js
browser/components/loop/content/js/contacts.jsx
browser/components/loop/content/shared/js/mixins.js
browser/components/loop/modules/MozLoopService.jsm
browser/components/loop/ui/ui-showcase.js
browser/components/loop/ui/ui-showcase.jsx
--- a/browser/components/loop/.eslintrc
+++ b/browser/components/loop/.eslintrc
@@ -42,20 +42,18 @@
     "eqeqeq": 0,                  // TBD. Might need to be separate for content & chrome
     "global-strict": 0,           // Leave as zero (this will be unsupported in eslint 1.0.0)
     "linebreak-style": [2, "unix"],
     "new-cap": 0,                 // TODO: Remove (use default)
     "no-catch-shadow": 0,         // TODO: Remove (use default)
     "no-console": 0,              // Leave as 0. We use console logging in content code.
     "no-empty": 0,                // TODO: Remove (use default)
     "no-extra-bind": 0,           // Leave as 0
-    "no-extra-boolean-cast": 0,   // TODO: Remove (use default)
     "no-multi-spaces": 0,         // TBD.
     "no-new": 0,                  // TODO: Remove (use default)
-    "no-redeclare": 0,            // TODO: Remove (use default)
     "no-return-assign": 0,        // TODO: Remove (use default)
     "no-underscore-dangle": 0,    // Leave as 0. Commonly used for private variables.
     "no-unexpected-multiline": 2,
     "no-unneeded-ternary": 2,
     "no-unused-expressions": 0,   // TODO: Remove (use default)
     "no-unused-vars": 0,          // TODO: Remove (use default)
     "no-use-before-define": 0,    // TODO: Remove (use default)
     "object-curly-spacing": 0,    // [2, "always"],
--- a/browser/components/loop/content/js/contacts.js
+++ b/browser/components/loop/content/js/contacts.js
@@ -695,17 +695,17 @@ loop.contacts = (function(_, mozL10n) {
             email: [{
               pref: true,
               type: ["home"],
               value: this.state.email.trim()
             }],
             category: ["local"]
           };
           var tel = this.state.tel.trim();
-          if (!!tel) {
+          if (tel) {
             contact.tel = [{
               pref: true,
               type: ["fxos"],
               value: tel
             }];
           }
           contactsAPI.add(contact, err => {
             if (err) {
--- a/browser/components/loop/content/js/contacts.jsx
+++ b/browser/components/loop/content/js/contacts.jsx
@@ -695,17 +695,17 @@ loop.contacts = (function(_, mozL10n) {
             email: [{
               pref: true,
               type: ["home"],
               value: this.state.email.trim()
             }],
             category: ["local"]
           };
           var tel = this.state.tel.trim();
-          if (!!tel) {
+          if (tel) {
             contact.tel = [{
               pref: true,
               type: ["fxos"],
               value: tel
             }];
           }
           contactsAPI.add(contact, err => {
             if (err) {
--- a/browser/components/loop/content/shared/js/mixins.js
+++ b/browser/components/loop/content/shared/js/mixins.js
@@ -146,18 +146,18 @@ loop.shared.mixins = (function() {
             width: this.documentBody.offsetWidth
           };
         }
         // Make sure the menu position will be a certain fixed amount of pixels away
         // from the border of the bounding box.
         boundingRect.width -= boundOffset;
         boundingRect.height -= boundOffset;
 
-        var x = menuNodeRect.left;
-        var y = menuNodeRect.top;
+        x = menuNodeRect.left;
+        y = menuNodeRect.top;
 
         // If there's an anchor present, position it relative to it first.
         var anchor = this.refs.anchor && this.refs.anchor.getDOMNode();
         if (anchor) {
           // XXXmikedeboer: at the moment we only support positioning centered above
           //                anchor node. Please add more modes as necessary.
           var anchorNodeRect = anchor.getBoundingClientRect();
           // Because we're _correcting_ the position of the dropdown, we assume that
@@ -467,18 +467,18 @@ loop.shared.mixins = (function() {
               remoteVideoDimensions.height : leadingAxisSize;
           }
         }
       }
 
       // Supply some sensible defaults for the remoteVideoDimensions if no remote
       // stream is connected (yet).
       if (!remoteVideoDimensions) {
-        var node = this._getElement(".remote");
-        var width = node.offsetWidth;
+        node = this._getElement(".remote");
+        width = node.offsetWidth;
         var height = node.offsetHeight;
         remoteVideoDimensions = {
           width: width,
           height: height,
           streamWidth: width,
           streamHeight: height
         };
       }
--- a/browser/components/loop/modules/MozLoopService.jsm
+++ b/browser/components/loop/modules/MozLoopService.jsm
@@ -168,23 +168,23 @@ XPCOMUtils.defineLazyGetter(this, "log",
   let consoleOptions = {
     maxLogLevelPref: PREF_LOG_LEVEL,
     prefix: "Loop"
   };
   return new ConsoleAPI(consoleOptions);
 });
 
 function setJSONPref(aName, aValue) {
-  let value = !!aValue ? JSON.stringify(aValue) : "";
+  let value = aValue ? JSON.stringify(aValue) : "";
   Services.prefs.setCharPref(aName, value);
 }
 
 function getJSONPref(aName) {
   let value = Services.prefs.getCharPref(aName);
-  return !!value ? JSON.parse(value) : null;
+  return value ? JSON.parse(value) : null;
 }
 
 let gHawkClient = null;
 let gLocalizedStrings = new Map();
 let gFxAEnabled = true;
 let gFxAOAuthClientPromise = null;
 let gFxAOAuthClient = null;
 let gErrors = new Map();
--- a/browser/components/loop/ui/ui-showcase.js
+++ b/browser/components/loop/ui/ui-showcase.js
@@ -1281,17 +1281,17 @@
       document.title = "Loop UI Components Showcase";
 
       // This simulates the mocha layout for errors which means we can run
       // this alongside our other unit tests but use the same harness.
       var expectedWarningsCount = 23;
       var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
       if (uncaughtError || warningsMismatch) {
         $("#results").append("<div class='failures'><em>" +
-          (!!(uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
+          ((uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
         if (warningsMismatch) {
           $("#results").append("<li class='test fail'>" +
             "<h2>Unexpected number of warnings detected in UI-Showcase</h2>" +
             "<pre class='error'>Got: " + caughtWarnings.length + "\n" +
             "Expected: " + expectedWarningsCount + "</pre></li>");
         }
         if (uncaughtError) {
           $("#results").append("<li class='test fail'>" +
--- a/browser/components/loop/ui/ui-showcase.jsx
+++ b/browser/components/loop/ui/ui-showcase.jsx
@@ -1281,17 +1281,17 @@
       document.title = "Loop UI Components Showcase";
 
       // This simulates the mocha layout for errors which means we can run
       // this alongside our other unit tests but use the same harness.
       var expectedWarningsCount = 23;
       var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
       if (uncaughtError || warningsMismatch) {
         $("#results").append("<div class='failures'><em>" +
-          (!!(uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
+          ((uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
         if (warningsMismatch) {
           $("#results").append("<li class='test fail'>" +
             "<h2>Unexpected number of warnings detected in UI-Showcase</h2>" +
             "<pre class='error'>Got: " + caughtWarnings.length + "\n" +
             "Expected: " + expectedWarningsCount + "</pre></li>");
         }
         if (uncaughtError) {
           $("#results").append("<li class='test fail'>" +