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
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -1146,18 +1146,18 @@ var gHistorySwipeAnimation = {
let url = "";
try {
url = URL.createObjectURL(aBlob);
img.onload = function() {
URL.revokeObjectURL(url);
};
} finally {
img.src = url;
- return img;
}
+ return img;
},
/**
* Scales the background of a given box element (which uses a given snapshot
* as background) based on a given scale factor.
* @param aSnapshot
* The snapshot that is used as background of aBox.
* @param aScale
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -166,16 +166,19 @@ module.exports = {
// "no-undef": "error",
// Error on newline where a semicolon is needed
"no-unexpected-multiline": "error",
// 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",
// Disallow unused labels
"no-unused-labels": "error",
// No declaring variables that are never used
"no-unused-vars": ["error", {
--- a/toolkit/components/telemetry/TelemetryStorage.jsm
+++ b/toolkit/components/telemetry/TelemetryStorage.jsm
@@ -1516,18 +1516,18 @@ var TelemetryStorageImpl = {
try {
yield OS.File.remove(file.path);
} catch (ex) {
this._log.error("_scanPendingPings - failed to remove file " + file.path, ex);
} finally {
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);
if (!UUID_REGEX.test(id)) {
this._log.trace("_scanPendingPings - filename is not a UUID: " + id);
id = Utils.generateUUID();
}
--- a/toolkit/modules/WindowsRegistry.jsm
+++ b/toolkit/modules/WindowsRegistry.jsm
@@ -79,12 +79,12 @@ var WindowsRegistry = {
registry.removeValue(aKey);
result = !registry.hasValue(aKey);
} else {
result = true;
}
} catch (ex) {
} finally {
registry.close();
- return result;
}
+ return result;
}
};
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -307,18 +307,18 @@ GMPWrapper.prototype = {
this._log.info("findUpdates() - updateTask succeeded for " +
this._plugin.id);
} catch (e) {
this._log.error("findUpdates() - updateTask for " + this._plugin.id +
" threw", e);
throw e;
} finally {
this._updateTask = null;
- return true;
}
+ return true;
}.bind(this));
return this._updateTask;
},
get pluginMimeTypes() { return []; },
get pluginLibraries() {
if (this.isInstalled) {