diff --git a/spec/integ/matrix-client-retrying.spec.js b/spec/integ/matrix-client-retrying.spec.js index fa13384c4..c45d9ced1 100644 --- a/spec/integ/matrix-client-retrying.spec.js +++ b/spec/integ/matrix-client-retrying.spec.js @@ -90,7 +90,7 @@ describe("MatrixClient retrying", function() { // wait for the localecho of ev1 to be updated const p3 = new Promise((resolve, reject) => { room.on("Room.localEchoUpdated", (ev0) => { - if(ev0 === ev1) { + if (ev0 === ev1) { resolve(); } }); diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index 2f3a5b829..07ca585f1 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -1379,7 +1379,7 @@ describe("Room", function() { let hasThrown = false; try { await room.loadMembersIfNeeded(); - } catch(err) { + } catch (err) { hasThrown = true; } expect(hasThrown).toEqual(true); diff --git a/spec/unit/scheduler.spec.js b/spec/unit/scheduler.spec.js index ffe9fa180..b4e83c4ef 100644 --- a/spec/unit/scheduler.spec.js +++ b/spec/unit/scheduler.spec.js @@ -143,7 +143,7 @@ describe("MatrixScheduler", function() { deferA.reject({}); try { await globalA; - } catch(err) { + } catch (err) { await Promise.resolve(); expect(procCount).toEqual(2); } diff --git a/src/browser-index.js b/src/browser-index.js index c1146ae13..dfa3f4d68 100644 --- a/src/browser-index.js +++ b/src/browser-index.js @@ -34,7 +34,7 @@ matrixcs.request(function(opts, fn) { let indexedDB; try { indexedDB = global.indexedDB; -} catch(e) {} +} catch (e) {} // if our browser (appears to) support indexeddb, use an indexeddb crypto store. if (indexedDB) { diff --git a/src/client.js b/src/client.js index 54aa73117..e3b6706c2 100644 --- a/src/client.js +++ b/src/client.js @@ -1925,7 +1925,7 @@ MatrixClient.prototype._restoreKeyBackup = function( let backupPubKey; try { backupPubKey = decryption.init_with_private_key(privKey); - } catch(e) { + } catch (e) { decryption.free(); throw e; } @@ -3797,7 +3797,7 @@ MatrixClient.prototype.paginateEventTimeline = function(eventTimeline, opts) { return pendingRequest; } - let path, params, promise; + let path; let params; let promise; const self = this; if (isNotifTimeline) { @@ -4217,7 +4217,7 @@ MatrixClient.prototype.getRoomPushRule = function(scope, roomId) { */ MatrixClient.prototype.setRoomMutePushRule = function(scope, roomId, mute) { const self = this; - let deferred, hasDontNotifyRule; + let deferred; let hasDontNotifyRule; // Get the existing room-kind push rule if any const roomPushRule = this.getRoomPushRule(scope, roomId); diff --git a/src/crypto/index.js b/src/crypto/index.js index caaaba5e4..a91c6f35a 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -2374,7 +2374,7 @@ Crypto.prototype.setRoomEncryption = async function(roomId, config, inhibitDevic // after all the in-memory state (_roomEncryptors and _roomList) has been updated // to avoid races when calling this method multiple times. Hence keep a hold of the promise. let storeConfigPromise = null; - if(!existingConfig) { + if (!existingConfig) { storeConfigPromise = this._roomList.setRoomEncryption(roomId, config); } @@ -2407,7 +2407,7 @@ Crypto.prototype.setRoomEncryption = async function(roomId, config, inhibitDevic // which is never used (inside riot at least) // but didn't want to remove it as it technically would // be a breaking change. - if(!this.inhibitDeviceQuery) { + if (!this.inhibitDeviceQuery) { this._deviceList.refreshOutdatedDeviceLists(); } } else { diff --git a/src/crypto/store/indexeddb-crypto-store-backend.js b/src/crypto/store/indexeddb-crypto-store-backend.js index 7576e9332..505e5fe51 100644 --- a/src/crypto/store/indexeddb-crypto-store-backend.js +++ b/src/crypto/store/indexeddb-crypto-store-backend.js @@ -131,7 +131,7 @@ export class Backend { cursorReq.onsuccess = (ev) => { const cursor = ev.target.result; - if(!cursor) { + if (!cursor) { // no match found callback(null); return; diff --git a/src/crypto/verification/SAS.js b/src/crypto/verification/SAS.js index 7aba7622b..c69f9f7e8 100644 --- a/src/crypto/verification/SAS.js +++ b/src/crypto/verification/SAS.js @@ -430,7 +430,7 @@ export class SAS extends Base { try { await this._sendMAC(olmSAS, macMethod); resolve(); - } catch(err) { + } catch (err) { reject(err); } }, diff --git a/src/http-api.js b/src/http-api.js index e7134bb59..94a0dcd81 100644 --- a/src/http-api.js +++ b/src/http-api.js @@ -890,7 +890,7 @@ function getResponseContentType(response) { try { return parseContentType(contentType); - } catch(e) { + } catch (e) { throw new Error(`Error parsing Content-Type '${contentType}': ${e}`); } } diff --git a/src/models/event-timeline-set.js b/src/models/event-timeline-set.js index b681b66b8..8a76e84a2 100644 --- a/src/models/event-timeline-set.js +++ b/src/models/event-timeline-set.js @@ -647,7 +647,7 @@ EventTimelineSet.prototype.compareEventOrdering = function(eventId1, eventId2) { if (timeline1 === timeline2) { // both events are in the same timeline - figure out their // relative indices - let idx1, idx2; + let idx1; let idx2; const events = timeline1.getEvents(); for (let idx = 0; idx < events.length && (idx1 === undefined || idx2 === undefined); idx++) { diff --git a/src/models/room-member.js b/src/models/room-member.js index 4dc973c79..bb7ba9a11 100644 --- a/src/models/room-member.js +++ b/src/models/room-member.js @@ -286,9 +286,9 @@ RoomMember.prototype.getAvatarUrl = * @return {string} the mxc avatar url */ RoomMember.prototype.getMxcAvatarUrl = function() { - if(this.events.member) { + if (this.events.member) { return this.events.member.getDirectionalContent().avatar_url; - } else if(this.user) { + } else if (this.user) { return this.user.avatarUrl; } return null; diff --git a/src/models/room-state.js b/src/models/room-state.js index 0c542432d..9bb733ba5 100644 --- a/src/models/room-state.js +++ b/src/models/room-state.js @@ -673,7 +673,7 @@ RoomState.prototype._maySendEventOfType = function(eventType, userId, state) { const userPowerLevel = power_levels.users && power_levels.users[userId]; if (Number.isFinite(userPowerLevel)) { powerLevel = userPowerLevel; - } else if(Number.isFinite(power_levels.users_default)) { + } else if (Number.isFinite(power_levels.users_default)) { powerLevel = power_levels.users_default; } diff --git a/src/models/room.js b/src/models/room.js index 4a656712f..53df39899 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1904,14 +1904,14 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) { // let's try to figure out who was here before let leftNames = otherNames; // if we didn't have heroes, try finding them in the room state - if(!leftNames.length) { + if (!leftNames.length) { leftNames = room.currentState.getMembers().filter((m) => { return m.userId !== userId && m.membership !== "invite" && m.membership !== "join"; }).map((m) => m.name); } - if(leftNames.length) { + if (leftNames.length) { return `Empty room (was ${memberNamesToRoomName(leftNames)})`; } else { return "Empty room"; diff --git a/src/realtime-callbacks.js b/src/realtime-callbacks.js index 0d21e23fb..2aae397ae 100644 --- a/src/realtime-callbacks.js +++ b/src/realtime-callbacks.js @@ -185,8 +185,8 @@ function _runCallbacks() { */ function binarySearch(array, func) { // min is inclusive, max exclusive. - let min = 0, - max = array.length; + let min = 0; + let max = array.length; while (min < max) { const mid = (min + max) >> 1; diff --git a/src/sync.js b/src/sync.js index 015144a42..a06639790 100644 --- a/src/sync.js +++ b/src/sync.js @@ -701,7 +701,7 @@ SyncApi.prototype._syncFromCache = async function(savedSync) { try { await this._processSyncResponse(syncEventData, data); - } catch(e) { + } catch (e) { logger.error("Error processing cached sync", e.stack || e); } @@ -774,7 +774,7 @@ SyncApi.prototype._sync = async function(syncOptions) { try { await this._processSyncResponse(syncEventData, data); - } catch(e) { + } catch (e) { // log the exception with stack if we have it, else fall back // to the plain description logger.error("Caught /sync error", e.stack || e); @@ -894,7 +894,7 @@ SyncApi.prototype._onSyncError = function(err, syncOptions) { logger.error("/sync error %s", err); logger.error(err); - if(this._shouldAbortSync(err)) { + if (this._shouldAbortSync(err)) { return; } diff --git a/src/timeline-window.js b/src/timeline-window.js index d277b72e3..38d0c1675 100644 --- a/src/timeline-window.js +++ b/src/timeline-window.js @@ -396,7 +396,7 @@ TimelineWindow.prototype.getEvents = function() { // (Note that both this._start.index and this._end.index are relative // to their respective timelines' BaseIndex). // - let startIndex = 0, endIndex = events.length; + let startIndex = 0; let endIndex = events.length; if (timeline === this._start.timeline) { startIndex = this._start.index + timeline.getBaseIndex(); } diff --git a/src/webrtc/call.js b/src/webrtc/call.js index 36db7ab46..3a2aaf757 100644 --- a/src/webrtc/call.js +++ b/src/webrtc/call.js @@ -176,7 +176,7 @@ MatrixCall.prototype.placeScreenSharingCall = debuglog("Got screen stream, requesting audio stream..."); const audioConstraints = _getUserMediaVideoContraints('voice'); _placeCallWithConstraints(self, audioConstraints); - } catch(err) { + } catch (err) { self.emit("error", callError( MatrixCall.ERR_NO_USER_MEDIA,