Run linting --fix

This commit is contained in:
Luke Barnard 2017-11-16 13:19:36 +00:00
parent c429b13b05
commit dad797d4a2
34 changed files with 64 additions and 66 deletions

View File

@ -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)),
);

View File

@ -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}`);
}

View File

@ -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];
}

View File

@ -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") {

View File

@ -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;

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}
},

View File

@ -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,
});

View File

@ -612,7 +612,7 @@ module.exports = React.createClass({
},
onLanguageChange: function(newLang) {
if(this.state.language !== newLang) {
if (this.state.language !== newLang) {
// We intentionally promote this to the account level at this point
SettingsStore.setValue("language", null, SettingLevel.ACCOUNT, newLang);
this.setState({

View File

@ -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");

View File

@ -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({
<div className="mx_Login_smallError">
{ _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?:\/\//, ''),
})
}
</div>
</div>
);
} else {
errorText = _t('Incorrect username and/or password.');
errorText = _t('Incorrect username and/or password.');
}
} else {
// other errors, not specific to doing a password login
@ -136,7 +136,7 @@ module.exports = React.createClass({
loginIncorrect: error.httpStatus === 401 || error.httpStatus == 403,
});
}).finally(() => {
if(this._unmounted) {
if (this._unmounted) {
return;
}
this.setState({
@ -332,7 +332,7 @@ module.exports = React.createClass({
},
_onLanguageChange: function(newLang) {
if(languageHandler.getCurrentLanguage() !== newLang) {
if (languageHandler.getCurrentLanguage() !== newLang) {
SettingsStore.setValue("language", null, SettingLevel.DEVICE, newLang);
PlatformPeg.get().reload();
}
@ -393,8 +393,7 @@ module.exports = React.createClass({
const theme = SettingsStore.getValue("theme");
if (theme !== "status") {
header = <h2>{ _t('Sign in') }</h2>;
}
else {
} else {
if (!this.state.errorText) {
header = <h2>{ _t('Sign in to get started') }</h2>;
}

View File

@ -399,8 +399,7 @@ module.exports = React.createClass({
// FIXME: remove hardcoded Status team tweaks at some point
if (theme === 'status' && this.state.errorText) {
header = <div className="mx_Login_error">{ this.state.errorText }</div>;
}
else {
} else {
header = <h2>{ _t('Create an account') }</h2>;
if (this.state.errorText) {
errorText = <div className="mx_Login_error">{ this.state.errorText }</div>;

View File

@ -54,7 +54,7 @@ export default React.createClass({
const deviceInfo = r[userId][deviceId];
if(!deviceInfo) {
if (!deviceInfo) {
console.warn(`No details found for device ${userId}:${deviceId}`);
this.props.onFinished(false);

View File

@ -19,9 +19,9 @@ export default class AppPermission extends React.Component {
const searchParams = new URLSearchParams(wurl.search);
if(this.isScalarWurl(wurl) && searchParams && searchParams.get('url')) {
if (this.isScalarWurl(wurl) && searchParams && searchParams.get('url')) {
curl = url.parse(searchParams.get('url'));
if(curl) {
if (curl) {
curl.search = curl.query = "";
curlString = curl.format();
}
@ -34,7 +34,7 @@ export default class AppPermission extends React.Component {
}
isScalarWurl(wurl) {
if(wurl && wurl.hostname && (
if (wurl && wurl.hostname && (
wurl.hostname === 'scalar.vector.im' ||
wurl.hostname === 'scalar-staging.riot.im' ||
wurl.hostname === 'scalar-develop.riot.im' ||

View File

@ -284,7 +284,7 @@ export default React.createClass({
formatAppTileName() {
let appTileName = "No name";
if(this.props.name && this.props.name.trim()) {
if (this.props.name && this.props.name.trim()) {
appTileName = this.props.name.trim();
}
return appTileName;
@ -374,7 +374,7 @@ export default React.createClass({
const deleteWidgetLabel = this._deleteWidgetLabel();
let deleteIcon = 'img/cancel_green.svg';
let deleteClasses = 'mx_AppTileMenuBarWidget';
if(this._canUserModify()) {
if (this._canUserModify()) {
deleteIcon = 'img/icon-delete-pink.svg';
deleteClasses += ' mx_AppTileMenuBarWidgetDelete';
}

View File

@ -41,8 +41,8 @@ export default class LanguageDropdown extends React.Component {
componentWillMount() {
languageHandler.getAllLanguagesFromJson().then((langs) => {
langs.sort(function(a, b) {
if(a.label < b.label) return -1;
if(a.label > b.label) return 1;
if (a.label < b.label) return -1;
if (a.label > b.label) return 1;
return 0;
});
this.setState({langs});
@ -57,7 +57,7 @@ export default class LanguageDropdown extends React.Component {
const language = SettingsStore.getValue("language", null, /*excludeDefault:*/true);
if (language) {
this.props.onOptionChange(language);
}else {
} else {
const language = languageHandler.normalizeLanguageKey(languageHandler.getLanguageFromBrowser());
this.props.onOptionChange(language);
}

View File

@ -216,7 +216,7 @@ module.exports = React.createClass({
// are there only to show translators to non-English languages
// that the verb is conjugated to plural or singular Subject.
let res = null;
switch(t) {
switch (t) {
case "joined":
res = (userCount > 1)
? _t("%(severalUsers)sjoined %(count)s times", { severalUsers: "", count: repeats })
@ -304,7 +304,7 @@ module.exports = React.createClass({
return items[0];
} else if (remaining > 0) {
items = items.slice(0, itemLimit);
return _t("%(items)s and %(count)s others", { items: items.join(', '), count: remaining } )
return _t("%(items)s and %(count)s others", { items: items.join(', '), count: remaining } );
} else {
const lastItem = items.pop();
return _t("%(items)s and %(lastItem)s", { items: items.join(', '), lastItem: lastItem });

View File

@ -122,7 +122,7 @@ class PasswordLogin extends React.Component {
mx_Login_field_disabled: disabled,
};
switch(loginType) {
switch (loginType) {
case PasswordLogin.LOGIN_FIELD_EMAIL:
classes.mx_Login_email = true;
return <input
@ -144,9 +144,9 @@ class PasswordLogin extends React.Component {
type="text"
name="username" // make it a little easier for browser's remember-password
onChange={this.onUsernameChanged}
placeholder={ SdkConfig.get().disable_custom_urls ?
placeholder={SdkConfig.get().disable_custom_urls ?
_t("Username on %(hs)s", {
hs: this.props.hsUrl.replace(/^https?:\/\//, '')
hs: this.props.hsUrl.replace(/^https?:\/\//, ''),
}) : _t("User name")}
value={this.state.username}
autoFocus

View File

@ -282,7 +282,7 @@ module.exports = React.createClass({
const emailSection = (
<div>
<input type="text" ref="email"
autoFocus={true} placeholder={ emailPlaceholder }
autoFocus={true} placeholder={emailPlaceholder}
defaultValue={this.props.defaultEmail}
className={this._classForField(FIELD_EMAIL, 'mx_Login_field')}
onBlur={function() {self.validateField(FIELD_EMAIL);}}

View File

@ -43,7 +43,7 @@ export default function SenderProfile(props) {
];
let content;
if(props.text) {
if (props.text) {
content = _t(props.text, { senderName: () => nameElem });
} else {
// There is nothing to translate here, so call substitute() instead

View File

@ -133,7 +133,7 @@ module.exports = React.createClass({
'$matrix_avatar_url': user ? MatrixClientPeg.get().mxcUrlToHttp(user.avatarUrl) : '',
};
if(app.data) {
if (app.data) {
Object.keys(app.data).forEach((key) => {
params['$' + key] = app.data[key];
});
@ -177,7 +177,7 @@ module.exports = React.createClass({
_canUserModify: function() {
try {
return WidgetUtils.canUserModifyWidgets(this.props.room.roomId);
} catch(err) {
} catch (err) {
console.error(err);
return false;
}

View File

@ -44,7 +44,7 @@ const eventTileTypes = {
'm.room.history_visibility': 'messages.TextualEvent',
'm.room.encryption': 'messages.TextualEvent',
'm.room.power_levels': 'messages.TextualEvent',
'm.room.pinned_events' : 'messages.TextualEvent',
'm.room.pinned_events': 'messages.TextualEvent',
'im.vector.modular.widgets': 'messages.TextualEvent',
};

View File

@ -562,7 +562,7 @@ module.exports = withMatrixClient(React.createClass({
onMemberAvatarClick: function() {
const member = this.props.member;
const avatarUrl = member.user ? member.user.avatarUrl : member.events.member.getContent().avatar_url;
if(!avatarUrl) return;
if (!avatarUrl) return;
const httpUrl = this.props.matrixClient.mxcUrlToHttp(avatarUrl);
const ImageView = sdk.getComponent("elements.ImageView");

View File

@ -111,10 +111,10 @@ export default class MessageComposer extends React.Component {
</div>
),
onFinished: (shouldUpload) => {
if(shouldUpload) {
if (shouldUpload) {
// MessageComposer shouldn't have to rely on its parent passing in a callback to upload a file
if (files) {
for(let i=0; i<files.length; i++) {
for (let i=0; i<files.length; i++) {
this.props.uploadFile(files[i]);
}
}

View File

@ -434,7 +434,7 @@ export default class MessageComposerInput extends React.Component {
if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) {
// The first matched group includes just the matched plaintext emoji
const emojiMatch = REGEX_EMOJI_WHITESPACE.exec(text.slice(0, currentStartOffset));
if(emojiMatch) {
if (emojiMatch) {
// plaintext -> hex unicode
const emojiUc = asciiList[emojiMatch[1]];
// hex unicode -> shortname -> actual unicode
@ -696,7 +696,7 @@ export default class MessageComposerInput extends React.Component {
}
const currentBlockType = RichUtils.getCurrentBlockType(this.state.editorState);
if(
if (
['code-block', 'blockquote', 'unordered-list-item', 'ordered-list-item']
.includes(currentBlockType)
) {

View File

@ -389,7 +389,7 @@ module.exports = React.createClass({
let rightRow;
let manageIntegsButton;
if(this.props.room && this.props.room.roomId && this.props.inRoom) {
if (this.props.room && this.props.room.roomId && this.props.inRoom) {
manageIntegsButton = <ManageIntegsButton
roomId={this.props.room.roomId}
/>;

View File

@ -165,13 +165,13 @@ module.exports = React.createClass({
let actionText;
if (kicked) {
if(roomName) {
if (roomName) {
actionText = _t("You have been kicked from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName});
} else {
actionText = _t("You have been kicked from this room by %(userName)s.", {userName: kickerName});
}
} else if (banned) {
if(roomName) {
if (roomName) {
actionText = _t("You have been banned from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName});
} else {
actionText = _t("You have been banned from this room by %(userName)s.", {userName: kickerName});

View File

@ -309,9 +309,9 @@ module.exports = React.createClass({
}
// url preview settings
let ps = this.saveUrlPreviewSettings();
const ps = this.saveUrlPreviewSettings();
if (ps.length > 0) {
ps.map(p => promises.push(p));
ps.map((p) => promises.push(p));
}
// related groups
@ -584,7 +584,7 @@ module.exports = React.createClass({
const roomState = this.props.room.currentState;
const isEncrypted = cli.isRoomEncrypted(this.props.room.roomId);
let settings = (
const settings = (
<SettingsFlag name="blacklistUnverifiedDevices"
level={SettingLevel.ROOM_DEVICE}
roomId={this.props.room.roomId}
@ -747,7 +747,7 @@ module.exports = React.createClass({
}
});
var tagsSection = null;
let tagsSection = null;
if (canSetTag || self.state.tags) {
tagsSection =
<div className="mx_RoomSettings_tags">

View File

@ -54,7 +54,7 @@ module.exports = React.createClass({
},
getInitialState: function() {
return({
return ({
hover: false,
badgeHover: false,
menuDisplayed: false,

View File

@ -39,7 +39,7 @@ module.exports = React.createClass({
},
onResize: function(e) {
if(this.props.onResize) {
if (this.props.onResize) {
this.props.onResize(e);
}
},

View File

@ -116,7 +116,7 @@ export async function decryptMegolmKeyFile(data, password) {
aesKey,
ciphertext,
);
} catch(e) {
} catch (e) {
throw friendlyError('subtleCrypto.decrypt failed: ' + e, cryptoFailMsg());
}

View File

@ -23,7 +23,7 @@ const localStorage = window.localStorage;
let indexedDB;
try {
indexedDB = window.indexedDB;
} catch(e) {}
} catch (e) {}
/**
* Create a new matrix client, with the persistent stores set up appropriately