diff --git a/.eslintrc.js b/.eslintrc.js
index fd4d1da631..c6aeb0d1be 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -29,6 +29,10 @@ module.exports = {
// so we replace it with a version that is class property aware
"babel/no-invalid-this": "error",
+ // We appear to follow this most of the time, so let's enforce it instead
+ // of occasionally following it (or catching it in review)
+ "keyword-spacing": "error",
+
/** react **/
// This just uses the react plugin to help eslint known when
// variables have been used in JSX
diff --git a/src/ComposerHistoryManager.js b/src/ComposerHistoryManager.js
index 2fff3882b4..2757c5bd3d 100644
--- a/src/ComposerHistoryManager.js
+++ b/src/ComposerHistoryManager.js
@@ -61,7 +61,7 @@ export default class ComposerHistoryManager {
// TODO: Performance issues?
let item;
- for(; item = sessionStorage.getItem(`${this.prefix}[${this.currentIndex}]`); this.currentIndex++) {
+ for (; item = sessionStorage.getItem(`${this.prefix}[${this.currentIndex}]`); this.currentIndex++) {
this.history.push(
Object.assign(new HistoryItem(), JSON.parse(item)),
);
diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js
index 7a4f0b99b0..86b38d4150 100644
--- a/src/MatrixClientPeg.js
+++ b/src/MatrixClientPeg.js
@@ -84,7 +84,7 @@ class MatrixClientPeg {
if (this.matrixClient.initCrypto) {
await this.matrixClient.initCrypto();
}
- } catch(e) {
+ } catch (e) {
// this can happen for a number of reasons, the most likely being
// that the olm library was missing. It's not fatal.
console.warn("Unable to initialise e2e: " + e);
@@ -99,7 +99,7 @@ class MatrixClientPeg {
const promise = this.matrixClient.store.startup();
console.log(`MatrixClientPeg: waiting for MatrixClient store to initialise`);
await promise;
- } catch(err) {
+ } catch (err) {
// log any errors when starting up the database (if one exists)
console.error(`Error starting matrixclient store: ${err}`);
}
diff --git a/src/RichText.js b/src/RichText.js
index b61ba0b9a4..12274ee9f3 100644
--- a/src/RichText.js
+++ b/src/RichText.js
@@ -68,7 +68,7 @@ function unicodeToEmojiUri(str) {
return unicodeChar;
} else {
// Remove variant selector VS16 (explicitly emoji) as it is unnecessary and leads to an incorrect URL below
- if(unicodeChar.length == 2 && unicodeChar[1] == '\ufe0f') {
+ if (unicodeChar.length == 2 && unicodeChar[1] == '\ufe0f') {
unicodeChar = unicodeChar[0];
}
diff --git a/src/TextForEvent.js b/src/TextForEvent.js
index 51e3eb8dc9..1bdf5ad90c 100644
--- a/src/TextForEvent.js
+++ b/src/TextForEvent.js
@@ -151,9 +151,9 @@ function textForCallHangupEvent(event) {
const senderName = event.sender ? event.sender.name : _t('Someone');
const eventContent = event.getContent();
let reason = "";
- if(!MatrixClientPeg.get().supportsVoip()) {
+ if (!MatrixClientPeg.get().supportsVoip()) {
reason = _t('(not supported by this browser)');
- } else if(eventContent.reason) {
+ } else if (eventContent.reason) {
if (eventContent.reason === "ice_failed") {
reason = _t('(could not connect media)');
} else if (eventContent.reason === "invite_timeout") {
diff --git a/src/Tinter.js b/src/Tinter.js
index 5c9b436d45..c7402c15be 100644
--- a/src/Tinter.js
+++ b/src/Tinter.js
@@ -393,7 +393,7 @@ class Tinter {
let svgDoc;
try {
svgDoc = svgs[i].contentDocument;
- } catch(e) {
+ } catch (e) {
let msg = 'Failed to get svg.contentDocument of ' + svgs[i].toString();
if (e.message) {
msg += e.message;
diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js
index 8b43964b1a..9d587c2eb4 100644
--- a/src/autocomplete/UserProvider.js
+++ b/src/autocomplete/UserProvider.js
@@ -126,7 +126,7 @@ export default class UserProvider extends AutocompleteProvider {
const events = this.room.getLiveTimeline().getEvents();
const lastSpoken = {};
- for(const event of events) {
+ for (const event of events) {
lastSpoken[event.getSender()] = event.getTs();
}
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 05ed9c95ed..83c7fe01bb 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -317,7 +317,7 @@ module.exports = React.createClass({
// the first thing to do is to try the token params in the query-string
Lifecycle.attemptTokenLogin(this.props.realQueryParams).then((loggedIn) => {
- if(loggedIn) {
+ if (loggedIn) {
this.props.onTokenLoginCompleted();
// don't do anything else until the page reloads - just stay in
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 38a3392e43..1381b4fce0 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -303,7 +303,7 @@ module.exports = React.createClass({
// Check if user has previously chosen to hide the app drawer for this
// room. If so, do not show apps
- let hideWidgetDrawer = localStorage.getItem(
+ const hideWidgetDrawer = localStorage.getItem(
room.roomId + "_hide_widget_drawer");
if (hideWidgetDrawer === "true") {
@@ -713,7 +713,7 @@ module.exports = React.createClass({
return;
}
- const joinedMembers = room.currentState.getMembers().filter(m => m.membership === "join" || m.membership === "invite");
+ const joinedMembers = room.currentState.getMembers().filter((m) => m.membership === "join" || m.membership === "invite");
this.setState({isAlone: joinedMembers.length === 1});
},
@@ -1110,7 +1110,7 @@ module.exports = React.createClass({
}
if (this.state.searchScope === 'All') {
- if(roomId != lastRoomId) {
+ if (roomId != lastRoomId) {
const room = cli.getRoom(roomId);
// XXX: if we've left the room, we might not know about
@@ -1421,13 +1421,13 @@ module.exports = React.createClass({
*/
handleScrollKey: function(ev) {
let panel;
- if(this.refs.searchResultsPanel) {
+ if (this.refs.searchResultsPanel) {
panel = this.refs.searchResultsPanel;
- } else if(this.refs.messagePanel) {
+ } else if (this.refs.messagePanel) {
panel = this.refs.messagePanel;
}
- if(panel) {
+ if (panel) {
panel.handleScrollKey(ev);
}
},
@@ -1446,7 +1446,7 @@ module.exports = React.createClass({
// otherwise react calls it with null on each update.
_gatherTimelinePanelRef: function(r) {
this.refs.messagePanel = r;
- if(r) {
+ if (r) {
console.log("updateTint from RoomView._gatherTimelinePanelRef");
this.updateTint();
}
diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js
index cda60c606f..dfc6b0f7a1 100644
--- a/src/components/structures/ScrollPanel.js
+++ b/src/components/structures/ScrollPanel.js
@@ -573,7 +573,7 @@ module.exports = React.createClass({
debuglog("ScrollPanel: scrolling to token '" + scrollToken + "'+" +
pixelOffset + " (delta: "+scrollDelta+")");
- if(scrollDelta != 0) {
+ if (scrollDelta != 0) {
this._setScrollTop(scrollNode.scrollTop + scrollDelta);
}
},
diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js
index 56661b0d26..aeb6cce6c3 100644
--- a/src/components/structures/TimelinePanel.js
+++ b/src/components/structures/TimelinePanel.js
@@ -310,7 +310,7 @@ var TimelinePanel = React.createClass({
return Promise.resolve(false);
}
- if(!this._timelineWindow.canPaginate(dir)) {
+ if (!this._timelineWindow.canPaginate(dir)) {
debuglog("TimelinePanel: can't", dir, "paginate any further");
this.setState({[canPaginateKey]: false});
return Promise.resolve(false);
@@ -440,7 +440,7 @@ var TimelinePanel = React.createClass({
var callback = null;
if (sender != myUserId && !UserActivity.userCurrentlyActive()) {
updatedState.readMarkerVisible = true;
- } else if(lastEv && this.getReadMarkerPosition() === 0) {
+ } else if (lastEv && this.getReadMarkerPosition() === 0) {
// we know we're stuckAtBottom, so we can advance the RM
// immediately, to save a later render cycle
@@ -657,7 +657,7 @@ var TimelinePanel = React.createClass({
// the read-marker should become invisible, so that if the user scrolls
// down, they don't see it.
- if(this.state.readMarkerVisible) {
+ if (this.state.readMarkerVisible) {
this.setState({
readMarkerVisible: false,
});
diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js
index 794c0d5d4d..933f90523a 100644
--- a/src/components/structures/UserSettings.js
+++ b/src/components/structures/UserSettings.js
@@ -612,7 +612,7 @@ module.exports = React.createClass({
},
onLanguageChange: function(newLang) {
- if(this.state.language !== newLang) {
+ if (this.state.language !== newLang) {
SettingsStore.setValue("language", null, SettingLevel.DEVICE, newLang);
this.setState({
language: newLang,
diff --git a/src/components/structures/login/ForgotPassword.js b/src/components/structures/login/ForgotPassword.js
index 8a2714d96a..43753bfd38 100644
--- a/src/components/structures/login/ForgotPassword.js
+++ b/src/components/structures/login/ForgotPassword.js
@@ -154,7 +154,7 @@ module.exports = React.createClass({
},
render: function() {
- const LoginPage = sdk.getComponent("login.LoginPage");
+ const LoginPage = sdk.getComponent("login.LoginPage");
const LoginHeader = sdk.getComponent("login.LoginHeader");
const LoginFooter = sdk.getComponent("login.LoginFooter");
const ServerConfig = sdk.getComponent("login.ServerConfig");
diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js
index 53f1b0e380..baa2064277 100644
--- a/src/components/structures/login/Login.js
+++ b/src/components/structures/login/Login.js
@@ -96,7 +96,7 @@ module.exports = React.createClass({
).then((data) => {
this.props.onLoggedIn(data);
}, (error) => {
- if(this._unmounted) {
+ if (this._unmounted) {
return;
}
let errorText;
@@ -113,14 +113,14 @@ module.exports = React.createClass({
{ _t('Please note you are logging into the %(hs)s server, not matrix.org.',
{
- hs: this.props.defaultHsUrl.replace(/^https?:\/\//, '')
+ hs: this.props.defaultHsUrl.replace(/^https?:\/\//, ''),
})
}