From 60b5555bc2e09658386daabf34f1c6ec38b8701c Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Thu, 5 Jan 2017 00:38:24 -0500 Subject: [PATCH] Bug 1328802 - Enable the no-unsafe-finally rule for eslint and fix the four errors that are triggered by it by moving the control flow statement outside of the finally block. r=mossop MozReview-Commit-ID: 7UFBBpvptdd --HG-- extra : rebase_source : b31f86341571ec6928caea130597e6c918a34636 --- browser/base/content/browser-gestureSupport.js | 2 +- toolkit/.eslintrc.js | 3 +++ toolkit/components/telemetry/TelemetryStorage.jsm | 2 +- toolkit/modules/WindowsRegistry.jsm | 2 +- toolkit/mozapps/extensions/internal/GMPProvider.jsm | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser/base/content/browser-gestureSupport.js b/browser/base/content/browser-gestureSupport.js index f7256b4bf1fb..8c09b96c0676 100644 --- a/browser/base/content/browser-gestureSupport.js +++ b/browser/base/content/browser-gestureSupport.js @@ -1151,8 +1151,8 @@ var gHistorySwipeAnimation = { }; } finally { img.src = url; - return img; } + return img; }, /** diff --git a/toolkit/.eslintrc.js b/toolkit/.eslintrc.js index 4f715bc258dc..1592545838b7 100644 --- a/toolkit/.eslintrc.js +++ b/toolkit/.eslintrc.js @@ -171,6 +171,9 @@ module.exports = { // No unreachable statements "no-unreachable": "error", + // Disallow control flow statements in finally blocks + "no-unsafe-finally": "error", + // Disallow negating the left operand of relational operators "no-unsafe-negation": "error", diff --git a/toolkit/components/telemetry/TelemetryStorage.jsm b/toolkit/components/telemetry/TelemetryStorage.jsm index ed99b3fe6d2b..23763e6c29bc 100644 --- a/toolkit/components/telemetry/TelemetryStorage.jsm +++ b/toolkit/components/telemetry/TelemetryStorage.jsm @@ -1521,8 +1521,8 @@ var TelemetryStorageImpl = { Telemetry.getHistogramById("TELEMETRY_DISCARDED_PENDING_PINGS_SIZE_MB") .add(Math.floor(info.size / 1024 / 1024)); Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_PENDING").add(); - continue; } + continue; } let id = OS.Path.basename(file.path); diff --git a/toolkit/modules/WindowsRegistry.jsm b/toolkit/modules/WindowsRegistry.jsm index 38197a8edd64..1ea519193e5e 100644 --- a/toolkit/modules/WindowsRegistry.jsm +++ b/toolkit/modules/WindowsRegistry.jsm @@ -84,7 +84,7 @@ var WindowsRegistry = { } catch (ex) { } finally { registry.close(); - return result; } + return result; } }; diff --git a/toolkit/mozapps/extensions/internal/GMPProvider.jsm b/toolkit/mozapps/extensions/internal/GMPProvider.jsm index 13ff07b59a9c..0366f72f2970 100644 --- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm +++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm @@ -312,8 +312,8 @@ GMPWrapper.prototype = { throw e; } finally { this._updateTask = null; - return true; } + return true; }.bind(this)); return this._updateTask;