Bug 1330791 - Enable the no-useless-call eslint rule for /services and fix associated errors. r?markh
MozReview-Commit-ID: Ixd7jk5G5CB
--- a/services/.eslintrc.js
+++ b/services/.eslintrc.js
@@ -16,11 +16,10 @@ module.exports = {
"no-ex-assign": "warn",
"no-func-assign": "warn",
"no-native-reassign": "warn",
"no-nested-ternary": "warn",
"no-octal": "warn",
"no-redeclare": "warn",
"no-unreachable": "warn",
"no-unsafe-finally": "warn",
- "no-useless-call": "warn"
}
};
--- a/services/cloudsync/CloudSyncEventSource.jsm
+++ b/services/cloudsync/CloudSyncEventSource.jsm
@@ -49,17 +49,17 @@ EventSource.prototype = {
emit(type, arg) {
if (!this.listeners.has(type)) {
return;
}
CommonUtils.nextTick(
function() {
for (let listener of this.listeners.get(type)) {
- listener.call(undefined, arg);
+ listener(arg);
}
},
this
);
},
};
this.EventSource = EventSource;
--- a/services/fxaccounts/tests/browser/browser_device_connected.js
+++ b/services/fxaccounts/tests/browser/browser_device_connected.js
@@ -7,17 +7,17 @@ const { MockRegistrar } =
Cu.import("resource://testing-common/MockRegistrar.jsm", {});
const StubAlertsService = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAlertsService, Ci.nsISupports]),
showAlertNotification(image, title, text, clickable, cookie, clickCallback) {
// We can't simulate a click on the alert popup,
// so instead we call the click listener ourselves directly
- clickCallback.observe.call(clickCallback, null, "alertclickcallback", null);
+ clickCallback.observe(null, "alertclickcallback", null);
}
}
add_task(function*() {
gBrowser.selectedBrowser.loadURI("about:robots");
yield waitForDocLoadComplete();
MockRegistrar.register("@mozilla.org/alerts-service;1", StubAlertsService);
--- a/services/sync/modules/addonsreconciler.js
+++ b/services/sync/modules/addonsreconciler.js
@@ -482,17 +482,17 @@ AddonsReconciler.prototype = {
* The new state of the add-on. From this.addons.
*/
_addChange: function _addChange(date, change, state) {
this._log.info("Change recorded for " + state.id);
this._changes.push([date, change, state.id]);
for (let listener of this._listeners) {
try {
- listener.changeListener.call(listener, date, change, state);
+ listener.changeListener(date, change, state);
} catch (ex) {
this._log.warn("Exception calling change listener", ex);
}
}
},
/**
* Obtain the set of changes to add-ons since the date passed.
--- a/services/sync/tests/unit/test_clients_engine.js
+++ b/services/sync/tests/unit/test_clients_engine.js
@@ -1077,17 +1077,17 @@ add_task(async function test_upload_afte
_("First sync. 2 records downloaded.");
strictEqual(engine.lastRecordUpload, 0);
engine._sync();
_("Send tab to client");
engine.sendCommand("displayURI", ["https://example.com", engine.localID, "Yak Herders Anonymous"], deviceBID);
const oldUploadOutgoing = SyncEngine.prototype._uploadOutgoing;
- SyncEngine.prototype._uploadOutgoing = () => engine._onRecordsWritten.call(engine, [], [deviceBID]);
+ SyncEngine.prototype._uploadOutgoing = () => engine._onRecordsWritten([], [deviceBID]);
engine._sync();
let collection = server.getCollection("foo", "clients");
let deviceBPayload = JSON.parse(JSON.parse(collection.payload(deviceBID)).ciphertext);
compareCommands(deviceBPayload.commands, [{
command: "displayURI", args: ["https://deviceclink.com", deviceCID, "Device C link"]
}], "Should be the same because the upload failed");
@@ -1177,17 +1177,17 @@ add_task(async function test_keep_cleare
}), now - 10));
try {
_("First sync. Download remote and our record.");
strictEqual(engine.lastRecordUpload, 0);
let collection = server.getCollection("foo", "clients");
const oldUploadOutgoing = SyncEngine.prototype._uploadOutgoing;
- SyncEngine.prototype._uploadOutgoing = () => engine._onRecordsWritten.call(engine, [], [deviceBID]);
+ SyncEngine.prototype._uploadOutgoing = () => engine._onRecordsWritten([], [deviceBID]);
let commandsProcessed = 0;
engine._handleDisplayURIs = (uris) => { commandsProcessed = uris.length };
engine._sync();
engine.processIncomingCommands(); // Not called by the engine.sync(), gotta call it ourselves
equal(commandsProcessed, 2, "We processed 2 commands");
let localRemoteRecord = JSON.parse(JSON.parse(collection.payload(engine.localID)).ciphertext);