Bug 1330791 - Enable the brace-style rule for eslint in /services and fix the associated errors. r?markh
MozReview-Commit-ID: Ebl3bODX14z
--- a/services/.eslintrc.js
+++ b/services/.eslintrc.js
@@ -3,17 +3,16 @@
module.exports = {
"extends": [
"../toolkit/.eslintrc.js"
],
rules: {
/* These rules are only set to warn temporarily
until they get fixed, at which point their
respective line in this file should be removed. */
- "brace-style": "warn",
"consistent-return": "warn",
"no-cond-assign": "warn",
"no-ex-assign": "warn",
"no-func-assign": "warn",
"no-native-reassign": "warn",
"no-nested-ternary": "warn",
}
};
--- a/services/common/tokenserverclient.js
+++ b/services/common/tokenserverclient.js
@@ -363,24 +363,22 @@ TokenServerClient.prototype = {
if (response.status == 400) {
error.message = "Malformed request.";
error.cause = "malformed-request";
} else if (response.status == 401) {
// Cause can be invalid-credentials, invalid-timestamp, or
// invalid-generation.
error.message = "Authentication failed.";
error.cause = result.status;
- }
-
- // 403 should represent a "condition acceptance needed" response.
- //
- // The extra validation of "urls" is important. We don't want to signal
- // conditions required unless we are absolutely sure that is what the
- // server is asking for.
- else if (response.status == 403) {
+ } else if (response.status == 403) {
+ // 403 should represent a "condition acceptance needed" response.
+ //
+ // The extra validation of "urls" is important. We don't want to signal
+ // conditions required unless we are absolutely sure that is what the
+ // server is asking for.
if (!("urls" in result)) {
this._log.warn("403 response without proper fields!");
this._log.warn("Response body: " + response.body);
error.message = "Missing JSON fields.";
error.cause = "malformed-response";
} else if (typeof(result.urls) != "object") {
error.message = "urls field is not a map.";
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -924,25 +924,23 @@ SyncEngine.prototype = {
// Set the newer version and newly generated syncID
engineData.version = this.version;
engineData.syncID = this.syncID;
// Put the new data back into meta/global and mark for upload
engines[this.name] = engineData;
metaGlobal.payload.engines = engines;
metaGlobal.changed = true;
- }
- // Don't sync this engine if the server has newer data
- else if (engineData.version > this.version) {
+ } else if (engineData.version > this.version) {
+ // Don't sync this engine if the server has newer data
let error = new String("New data: " + [engineData.version, this.version]);
error.failureCode = VERSION_OUT_OF_DATE;
throw error;
- }
- // Changes to syncID mean we'll need to upload everything
- else if (engineData.syncID != this.syncID) {
+ } else if (engineData.syncID != this.syncID) {
+ // Changes to syncID mean we'll need to upload everything
this._log.debug("Engine syncIDs: " + [engineData.syncID, this.syncID]);
this.syncID = engineData.syncID;
this._resetClient();
}
// Delete any existing data and reupload on bad version or missing meta.
// No crypto component here...? We could regenerate per-collection keys...
if (needsWipe) {
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -1042,27 +1042,25 @@ BookmarksTracker.prototype = {
let mobile = find(MOBILE_ANNO);
let queryURI = Utils.makeURI("place:folder=" + PlacesUtils.mobileFolderId);
let title = PlacesBundle.GetStringFromName("MobileBookmarksFolderTitle");
// Don't add OR remove the mobile bookmarks if there's nothing.
if (PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.mobileFolderId, 0) == -1) {
if (mobile.length != 0)
PlacesUtils.bookmarks.removeItem(mobile[0], SOURCE_SYNC);
- }
- // Add the mobile bookmarks query if it doesn't exist
- else if (mobile.length == 0) {
+ } else if (mobile.length == 0) {
+ // Add the mobile bookmarks query if it doesn't exist
let query = PlacesUtils.bookmarks.insertBookmark(all[0], queryURI, -1, title, /* guid */ null, SOURCE_SYNC);
PlacesUtils.annotations.setItemAnnotation(query, ORGANIZERQUERY_ANNO, MOBILE_ANNO, 0,
PlacesUtils.annotations.EXPIRE_NEVER, SOURCE_SYNC);
PlacesUtils.annotations.setItemAnnotation(query, PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO, 1, 0,
PlacesUtils.annotations.EXPIRE_NEVER, SOURCE_SYNC);
- }
- // Make sure the existing query URL and title are correct
- else {
+ } else {
+ // Make sure the existing query URL and title are correct
if (!PlacesUtils.bookmarks.getBookmarkURI(mobile[0]).equals(queryURI)) {
PlacesUtils.bookmarks.changeBookmarkURI(mobile[0], queryURI,
SOURCE_SYNC);
}
let queryTitle = PlacesUtils.bookmarks.getItemTitle(mobile[0]);
if (queryTitle != title) {
PlacesUtils.bookmarks.setItemTitle(mobile[0], title, SOURCE_SYNC);
}
--- a/services/sync/modules/engines/clients.js
+++ b/services/sync/modules/engines/clients.js
@@ -589,19 +589,18 @@ ClientEngine.prototype = {
* devices.
*/
sendCommand: function sendCommand(command, args, clientId, flowID = null) {
let commandData = this._commands[command];
// Don't send commands that we don't know about.
if (!commandData) {
this._log.error("Unknown command to send: " + command);
return;
- }
- // Don't send a command with the wrong number of arguments.
- else if (!args || args.length != commandData.args) {
+ } else if (!args || args.length != commandData.args) {
+ // Don't send a command with the wrong number of arguments.
this._log.error("Expected " + commandData.args + " args for '" +
command + "', but got " + args);
return;
}
if (clientId) {
this._sendCommandToClient(command, args, clientId, flowID);
} else {
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -1588,19 +1588,18 @@ Sync11Service.prototype = {
*/
wipeClient: function wipeClient(engines) {
// If we don't have any engines, reset the service and wipe all engines
if (!engines) {
// Clear out any service data
this.resetService();
engines = [this.clientsEngine].concat(this.engineManager.getAll());
- }
- // Convert the array of names into engines
- else {
+ } else {
+ // Convert the array of names into engines
engines = this.engineManager.get(engines);
}
// Fully wipe each engine if it's able to decrypt data
for (let engine of engines) {
if (engine.canDecrypt()) {
engine.wipeClient();
}
@@ -1625,19 +1624,18 @@ Sync11Service.prototype = {
// Clear out any server data.
this.wipeServer(engines);
// Only wipe the engines provided.
if (engines) {
engines.forEach(function(e) {
this.clientsEngine.sendCommand("wipeEngine", [e]);
}, this);
- }
- // Tell the remote machines to wipe themselves.
- else {
+ } else {
+ // Tell the remote machines to wipe themselves.
this.clientsEngine.sendCommand("wipeAll", []);
}
// Make sure the changed clients get updated.
this.clientsEngine.sync();
} catch (ex) {
this.errorHandler.checkServerError(ex);
throw ex;
@@ -1666,19 +1664,18 @@ Sync11Service.prototype = {
resetClient: function resetClient(engines) {
this._catch(function doResetClient() {
// If we don't have any engines, reset everything including the service
if (!engines) {
// Clear out any service data
this.resetService();
engines = [this.clientsEngine].concat(this.engineManager.getAll());
- }
- // Convert the array of names into engines
- else {
+ } else {
+ // Convert the array of names into engines
engines = this.engineManager.get(engines);
}
// Have each engine drop any temporary meta data
for (let engine of engines) {
engine.resetClient();
}
})();