Bug 1292008 - Enable the no-empty rule for eslint. r=markh
authorJared Wein <jwein@mozilla.com>
Thu, 04 Aug 2016 00:55:07 -0400
changeset 351499 6732d24079ca1c6f7337bc786d75c0dd2ecd598c
parent 351498 2ce7bd81fd0673ec5b45a56e4236168879c49a80
child 351500 62a983c56050b3ac647d8f95d9c2ca69c3ad2d91
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1292008
milestone51.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 1292008 - Enable the no-empty rule for eslint. r=markh MozReview-Commit-ID: EfM3YOUjClW
browser/base/content/browser-gestureSupport.js
browser/components/nsBrowserContentHandler.js
toolkit/.eslintrc
toolkit/components/narrate/Narrator.jsm
toolkit/components/telemetry/tests/unit/test_ThreadHangStats.js
toolkit/modules/GMPUtils.jsm
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -982,35 +982,32 @@ var gHistorySwipeAnimation = {
    */
   _takeSnapshot: function HSA__takeSnapshot() {
     if (!this._readyToTakeSnapshots()) {
       return;
     }
 
     let canvas = null;
 
-    try {
-      let browser = gBrowser.selectedBrowser;
-      let r = browser.getBoundingClientRect();
-      canvas = document.createElementNS("http://www.w3.org/1999/xhtml",
-                                        "canvas");
-      canvas.mozOpaque = true;
-      let scale = window.devicePixelRatio;
-      canvas.width = r.width * scale;
-      canvas.height = r.height * scale;
-      let ctx = canvas.getContext("2d");
-      let zoom = browser.markupDocumentViewer.fullZoom * scale;
-      ctx.scale(zoom, zoom);
-      ctx.drawWindow(browser.contentWindow,
-                     0, 0, canvas.width / zoom, canvas.height / zoom, "white",
-                     ctx.DRAWWINDOW_DO_NOT_FLUSH | ctx.DRAWWINDOW_DRAW_VIEW |
-                     ctx.DRAWWINDOW_ASYNC_DECODE_IMAGES |
-                     ctx.DRAWWINDOW_USE_WIDGET_LAYERS);
-    } finally {
-    }
+    let browser = gBrowser.selectedBrowser;
+    let r = browser.getBoundingClientRect();
+    canvas = document.createElementNS("http://www.w3.org/1999/xhtml",
+                                      "canvas");
+    canvas.mozOpaque = true;
+    let scale = window.devicePixelRatio;
+    canvas.width = r.width * scale;
+    canvas.height = r.height * scale;
+    let ctx = canvas.getContext("2d");
+    let zoom = browser.markupDocumentViewer.fullZoom * scale;
+    ctx.scale(zoom, zoom);
+    ctx.drawWindow(browser.contentWindow,
+                   0, 0, canvas.width / zoom, canvas.height / zoom, "white",
+                   ctx.DRAWWINDOW_DO_NOT_FLUSH | ctx.DRAWWINDOW_DRAW_VIEW |
+                   ctx.DRAWWINDOW_ASYNC_DECODE_IMAGES |
+                   ctx.DRAWWINDOW_USE_WIDGET_LAYERS);
 
     TelemetryStopwatch.start("FX_GESTURE_INSTALL_SNAPSHOT_OF_PAGE");
     try {
       this._installCurrentPageSnapshot(canvas);
       this._assignSnapshotToCurrentBrowser(canvas);
     } finally {
       TelemetryStopwatch.finish("FX_GESTURE_INSTALL_SNAPSHOT_OF_PAGE");
     }
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -733,17 +733,17 @@ nsDefaultCommandLineHandler.prototype = 
       // urls launched after the initial launch will be lost.
       if (!this._haveProfile) {
         try {
           // This will throw when a profile has not been selected.
           var dir = Services.dirsvc.get("ProfD", Components.interfaces.nsILocalFile);
           this._haveProfile = true;
         }
         catch (e) {
-          while ((ar = cmdLine.handleFlagWithParam("url", false))) { }
+          while ((ar = cmdLine.handleFlagWithParam("url", false)));
           cmdLine.preventDefault = true;
         }
       }
     }
 
     let redirectWinSearch = false;
     if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
       redirectWinSearch = Services.prefs.getBoolPref("browser.search.redirectWindowsSearch");
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -66,17 +66,17 @@
 
     // No labels
     "no-labels": 2,
 
     // If an if block ends with a return no need for an else block
     "no-else-return": 2,
 
     // No empty statements
-    // "no-empty": 2,
+    "no-empty": [2, "allowEmptyCatch": true],
 
     // No empty character classes in regex
     "no-empty-character-class": 2,
 
     // Disallow empty destructuring
     "no-empty-pattern": 2,
 
     // No assiging to exception variable
--- a/toolkit/components/narrate/Narrator.jsm
+++ b/toolkit/components/narrate/Narrator.jsm
@@ -211,17 +211,21 @@ Narrator.prototype = {
       voice: this._getVoice(speechOptions.voice)
     };
 
     this._stopped = false;
     return this._detectLanguage().then(() => {
       let tw = this._treeWalker;
       if (!this._isParagraphInView(tw.currentNode)) {
         tw.currentNode = tw.root;
-        while (tw.nextNode() && !this._isParagraphInView(tw.currentNode)) {}
+        while (tw.nextNode()) {
+          if (this._isParagraphInView(tw.currentNode)) {
+            break;
+          }
+        }
         // _speakInner will advance to the next node for us, so we need
         // to have it one paragraph back from the first visible one.
         tw.previousNode();
       }
 
       return this._speakInner();
     });
   },
--- a/toolkit/components/telemetry/tests/unit/test_ThreadHangStats.js
+++ b/toolkit/components/telemetry/tests/unit/test_ThreadHangStats.js
@@ -34,25 +34,23 @@ function run_test() {
   // Run three events in the event loop:
   // the first event causes a transient hang;
   // the second event causes a permanent hang;
   // the third event checks results from previous events.
 
   do_execute_soon(() => {
     // Cause a hang lasting 1 second (transient hang).
     let startTime = Date.now();
-    while ((Date.now() - startTime) < 1000) {
-    }
+    while ((Date.now() - startTime) < 1000);
   });
 
   do_execute_soon(() => {
     // Cause a hang lasting 10 seconds (permanent hang).
     let startTime = Date.now();
-    while ((Date.now() - startTime) < 10000) {
-    }
+    while ((Date.now() - startTime) < 10000);
   });
 
   do_execute_soon(() => {
     do_test_pending();
 
     let check_results = () => {
       let endHangs = getMainThreadHangStats();
 
--- a/toolkit/modules/GMPUtils.jsm
+++ b/toolkit/modules/GMPUtils.jsm
@@ -63,18 +63,16 @@ this.GMPUtils = {
    * @param   aPlugin
    *          The plugin to check.
    */
   _isPluginSupported: function(aPlugin) {
     if (this._isPluginForceSupported(aPlugin)) {
       return true;
     }
     if (aPlugin.id == EME_ADOBE_ID) {
-      if (Services.appinfo.OS != "WINNT") {
-      }
       // Windows Vista and later only supported by Adobe EME.
       return AppConstants.isPlatformAndVersionAtLeast("win", "6");
     } else if (aPlugin.id == WIDEVINE_ID) {
       // The Widevine plugin is available for Windows versions Vista and later,
       // Mac OSX, and Linux.
       return AppConstants.isPlatformAndVersionAtLeast("win", "6") ||
              AppConstants.platform == "macosx" ||
              AppConstants.platform == "linux";