Merge pull request #5375 from matrix-org/dbkr/silly_lint_errors

Fix a bunch of silly lint errors
This commit is contained in:
David Baker 2020-10-30 18:31:18 +00:00 committed by GitHub
commit e391d5a1dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 79 additions and 58 deletions

View file

@ -5,25 +5,10 @@ src/Rooms.js
src/Unread.js src/Unread.js
src/Velociraptor.js src/Velociraptor.js
src/components/structures/RoomDirectory.js src/components/structures/RoomDirectory.js
src/components/structures/ScrollPanel.js
src/components/structures/UploadBar.js
src/components/views/elements/AddressSelector.js
src/components/views/elements/DirectorySearchBox.js
src/components/views/messages/MFileBody.js
src/components/views/messages/TextualBody.js
src/components/views/rooms/LinkPreviewWidget.js
src/components/views/rooms/MemberList.js src/components/views/rooms/MemberList.js
src/components/views/rooms/RoomPreviewBar.js
src/components/views/settings/ChangeAvatar.js
src/components/views/settings/DevicesPanel.js
src/components/views/settings/Notifications.js
src/rageshake/rageshake.js
src/ratelimitedfunc.js src/ratelimitedfunc.js
src/utils/DMRoomMap.js src/utils/DMRoomMap.js
src/utils/DecryptFile.js
src/utils/DirectoryUtils.js
src/utils/MultiInviter.js src/utils/MultiInviter.js
src/utils/Receipt.js
test/components/structures/MessagePanel-test.js test/components/structures/MessagePanel-test.js
test/components/views/dialogs/InteractiveAuthDialog-test.js test/components/views/dialogs/InteractiveAuthDialog-test.js
test/mock-clock.js test/mock-clock.js

View file

@ -704,7 +704,7 @@ export default class ScrollPanel extends React.Component {
if (itemlist.style.height !== newHeight) { if (itemlist.style.height !== newHeight) {
itemlist.style.height = newHeight; itemlist.style.height = newHeight;
} }
if (sn.scrollTop !== sn.scrollHeight){ if (sn.scrollTop !== sn.scrollHeight) {
sn.scrollTop = sn.scrollHeight; sn.scrollTop = sn.scrollHeight;
} }
debuglog("updateHeight to", newHeight); debuglog("updateHeight to", newHeight);

View file

@ -86,7 +86,9 @@ export default class UploadBar extends React.Component {
} }
// MUST use var name 'count' for pluralization to kick in // MUST use var name 'count' for pluralization to kick in
const uploadText = _t("Uploading %(filename)s and %(count)s others", {filename: upload.fileName, count: (uploads.length - 1)}); const uploadText = _t(
"Uploading %(filename)s and %(count)s others", {filename: upload.fileName, count: (uploads.length - 1)},
);
return ( return (
<div className="mx_UploadBar"> <div className="mx_UploadBar">

View file

@ -46,7 +46,7 @@ export default class AddressSelector extends React.Component {
} }
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event // TODO: [REACT-WARNING] Replace with appropriate lifecycle event
UNSAFE_componentWillReceiveProps(props) { UNSAFE_componentWillReceiveProps(props) { // eslint-disable-line camelcase
// Make sure the selected item isn't outside the list bounds // Make sure the selected item isn't outside the list bounds
const selected = this.state.selected; const selected = this.state.selected;
const maxSelected = this._maxSelected(props.addressList); const maxSelected = this._maxSelected(props.addressList);

View file

@ -16,7 +16,6 @@ limitations under the License.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classnames from 'classnames';
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
@ -78,14 +77,14 @@ export default class DirectorySearchBox extends React.Component {
render() { render() {
const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
const searchbox_classes = { const searchboxClasses = {
mx_DirectorySearchBox: true, mx_DirectorySearchBox: true,
}; };
searchbox_classes[this.props.className] = true; searchboxClasses[this.props.className] = true;
let join_button; let joinButton;
if (this.props.showJoinButton) { if (this.props.showJoinButton) {
join_button = <AccessibleButton className="mx_DirectorySearchBox_joinButton" joinButton = <AccessibleButton className="mx_DirectorySearchBox_joinButton"
onClick={this._onJoinButtonClick} onClick={this._onJoinButtonClick}
>{_t("Join")}</AccessibleButton>; >{_t("Join")}</AccessibleButton>;
} }
@ -97,7 +96,7 @@ export default class DirectorySearchBox extends React.Component {
onChange={this._onChange} onKeyUp={this._onKeyUp} onChange={this._onChange} onKeyUp={this._onKeyUp}
placeholder={this.props.placeholder} autoFocus placeholder={this.props.placeholder} autoFocus
/> />
{ join_button } { joinButton }
<AccessibleButton className="mx_DirectorySearchBox_clear" onClick={this._onClearClick}></AccessibleButton> <AccessibleButton className="mx_DirectorySearchBox_clear" onClick={this._onClearClick}></AccessibleButton>
</div>; </div>;
} }

View file

@ -144,7 +144,7 @@ export default class MFileBody extends React.Component {
* Extracts a human readable label for the file attachment to use as * Extracts a human readable label for the file attachment to use as
* link text. * link text.
* *
* @params {Object} content The "content" key of the matrix event. * @param {Object} content The "content" key of the matrix event.
* @return {string} the human readable link text for the attachment. * @return {string} the human readable link text for the attachment.
*/ */
presentableTextForFile(content) { presentableTextForFile(content) {

View file

@ -416,7 +416,9 @@ export default class TextualBody extends React.Component {
if (this.props.highlightLink) { if (this.props.highlightLink) {
body = <a href={this.props.highlightLink}>{ body }</a>; body = <a href={this.props.highlightLink}>{ body }</a>;
} else if (content.data && typeof content.data["org.matrix.neb.starter_link"] === "string") { } else if (content.data && typeof content.data["org.matrix.neb.starter_link"] === "string") {
body = <a href="#" onClick={this.onStarterLinkClick.bind(this, content.data["org.matrix.neb.starter_link"])}>{ body }</a>; body = <a href="#"
onClick={this.onStarterLinkClick.bind(this, content.data["org.matrix.neb.starter_link"])}
>{ body }</a>;
} }
let widgets; let widgets;

View file

@ -114,7 +114,10 @@ export default class LinkPreviewWidget extends React.Component {
let thumbHeight = imageMaxHeight; let thumbHeight = imageMaxHeight;
if (p["og:image:width"] && p["og:image:height"]) { if (p["og:image:width"] && p["og:image:height"]) {
thumbHeight = ImageUtils.thumbHeight(p["og:image:width"], p["og:image:height"], imageMaxWidth, imageMaxHeight); thumbHeight = ImageUtils.thumbHeight(
p["og:image:width"], p["og:image:height"],
imageMaxWidth, imageMaxHeight,
);
} }
let img; let img;

View file

@ -284,7 +284,7 @@ export default class RoomPreviewBar extends React.Component {
room_name: this.props.oobData ? this.props.oobData.room_name : null, room_name: this.props.oobData ? this.props.oobData.room_name : null,
room_avatar_url: this.props.oobData ? this.props.oobData.avatarUrl : null, room_avatar_url: this.props.oobData ? this.props.oobData.avatarUrl : null,
inviter_name: this.props.oobData ? this.props.oobData.inviterName : null, inviter_name: this.props.oobData ? this.props.oobData.inviterName : null,
} },
}; };
} }
@ -337,7 +337,7 @@ export default class RoomPreviewBar extends React.Component {
if (this.props.previewLoading) { if (this.props.previewLoading) {
footer = ( footer = (
<div> <div>
<Spinner w={20} h={20}/> <Spinner w={20} h={20} />
{_t("Loading room preview")} {_t("Loading room preview")}
</div> </div>
); );

View file

@ -19,6 +19,7 @@ import PropTypes from 'prop-types';
import {MatrixClientPeg} from "../../../MatrixClientPeg"; import {MatrixClientPeg} from "../../../MatrixClientPeg";
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import Spinner from '../elements/Spinner';
export default class ChangeAvatar extends React.Component { export default class ChangeAvatar extends React.Component {
static propTypes = { static propTypes = {
@ -58,7 +59,7 @@ export default class ChangeAvatar extends React.Component {
} }
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event // TODO: [REACT-WARNING] Replace with appropriate lifecycle event
UNSAFE_componentWillReceiveProps(newProps) { UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line camelcase
if (this.avatarSet) { if (this.avatarSet) {
// don't clobber what the user has just set // don't clobber what the user has just set
return; return;
@ -143,7 +144,9 @@ export default class ChangeAvatar extends React.Component {
// time to propagate through to the RoomAvatar. // time to propagate through to the RoomAvatar.
if (this.props.room && !this.avatarSet) { if (this.props.room && !this.avatarSet) {
const RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); const RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
avatarImg = <RoomAvatar room={this.props.room} width={this.props.width} height={this.props.height} resizeMethod='crop' />; avatarImg = <RoomAvatar
room={this.props.room} width={this.props.width} height={this.props.height} resizeMethod='crop'
/>;
} else { } else {
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
// XXX: FIXME: once we track in the JS what our own displayname is(!) then use it here rather than ? // XXX: FIXME: once we track in the JS what our own displayname is(!) then use it here rather than ?
@ -174,9 +177,8 @@ export default class ChangeAvatar extends React.Component {
</div> </div>
); );
case ChangeAvatar.Phases.Uploading: case ChangeAvatar.Phases.Uploading:
var Loader = sdk.getComponent("elements.Spinner");
return ( return (
<Loader /> <Spinner />
); );
} }
} }

View file

@ -74,7 +74,7 @@ export default class DevicesPanel extends React.Component {
} }
/** /*
* compare two devices, sorting from most-recently-seen to least-recently-seen * compare two devices, sorting from most-recently-seen to least-recently-seen
* (and then, for stability, by device id) * (and then, for stability, by device id)
*/ */

View file

@ -94,7 +94,9 @@ export default class Notifications extends React.Component {
phase: Notifications.phases.LOADING, phase: Notifications.phases.LOADING,
}); });
MatrixClientPeg.get().setPushRuleEnabled('global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !checked).then(function() { MatrixClientPeg.get().setPushRuleEnabled(
'global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !checked,
).then(function() {
self._refreshFromServer(); self._refreshFromServer();
}); });
}; };
@ -216,8 +218,8 @@ export default class Notifications extends React.Component {
description: _t('Enter keywords separated by a comma:'), description: _t('Enter keywords separated by a comma:'),
button: _t('OK'), button: _t('OK'),
value: keywords, value: keywords,
onFinished: (should_leave, newValue) => { onFinished: (shouldLeave, newValue) => {
if (should_leave && newValue !== keywords) { if (shouldLeave && newValue !== keywords) {
let newKeywords = newValue.split(','); let newKeywords = newValue.split(',');
for (const i in newKeywords) { for (const i in newKeywords) {
newKeywords[i] = newKeywords[i].trim(); newKeywords[i] = newKeywords[i].trim();
@ -403,7 +405,9 @@ export default class Notifications extends React.Component {
// when creating the new rule. // when creating the new rule.
// Thus, this new rule will join the 'vectorContentRules' set. // Thus, this new rule will join the 'vectorContentRules' set.
if (self.state.vectorContentRules.rules.length) { if (self.state.vectorContentRules.rules.length) {
pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind(self.state.vectorContentRules.rules[0]); pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind(
self.state.vectorContentRules.rules[0],
);
} else { } else {
// ON is default // ON is default
pushRuleVectorStateKind = PushRuleVectorState.ON; pushRuleVectorStateKind = PushRuleVectorState.ON;
@ -415,10 +419,9 @@ export default class Notifications extends React.Component {
if (vectorContentRulesPatterns.indexOf(keyword) < 0) { if (vectorContentRulesPatterns.indexOf(keyword) < 0) {
if (self.state.vectorContentRules.vectorState !== PushRuleVectorState.OFF) { if (self.state.vectorContentRules.vectorState !== PushRuleVectorState.OFF) {
deferreds.push(cli.addPushRule deferreds.push(cli.addPushRule('global', 'content', keyword, {
('global', 'content', keyword, { actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind),
actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind), pattern: keyword,
pattern: keyword,
})); }));
} else { } else {
deferreds.push(self._addDisabledPushRule('global', 'content', keyword, { deferreds.push(self._addDisabledPushRule('global', 'content', keyword, {
@ -482,12 +485,14 @@ export default class Notifications extends React.Component {
_refreshFromServer = () => { _refreshFromServer = () => {
const self = this; const self = this;
const pushRulesPromise = MatrixClientPeg.get().getPushRules().then(self._portRulesToNewAPI).then(function(rulesets) { const pushRulesPromise = MatrixClientPeg.get().getPushRules().then(
self._portRulesToNewAPI,
).then(function(rulesets) {
/// XXX seriously? wtf is this? /// XXX seriously? wtf is this?
MatrixClientPeg.get().pushRules = rulesets; MatrixClientPeg.get().pushRules = rulesets;
// Get homeserver default rules and triage them by categories // Get homeserver default rules and triage them by categories
const rule_categories = { const ruleCategories = {
// The master rule (all notifications disabling) // The master rule (all notifications disabling)
'.m.rule.master': 'master', '.m.rule.master': 'master',
@ -514,7 +519,7 @@ export default class Notifications extends React.Component {
for (const kind in rulesets.global) { for (const kind in rulesets.global) {
for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) { for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
const r = rulesets.global[kind][i]; const r = rulesets.global[kind][i];
const cat = rule_categories[r.rule_id]; const cat = ruleCategories[r.rule_id];
r.kind = kind; r.kind = kind;
if (r.rule_id[0] === '.') { if (r.rule_id[0] === '.') {
@ -750,7 +755,7 @@ export default class Notifications extends React.Component {
if (this.state.masterPushRule) { if (this.state.masterPushRule) {
masterPushRuleDiv = <LabelledToggleSwitch value={!this.state.masterPushRule.enabled} masterPushRuleDiv = <LabelledToggleSwitch value={!this.state.masterPushRule.enabled}
onChange={this.onEnableNotificationsChange} onChange={this.onEnableNotificationsChange}
label={_t('Enable notifications for this account')}/>; label={_t('Enable notifications for this account')} />;
} }
let clearNotificationsButton; let clearNotificationsButton;
@ -803,7 +808,10 @@ export default class Notifications extends React.Component {
} }
if (externalKeywords.length) { if (externalKeywords.length) {
externalKeywords = externalKeywords.join(", "); externalKeywords = externalKeywords.join(", ");
externalRules.push(<li>{ _t('Notifications on the following keywords follow rules which cant be displayed here:') } { externalKeywords }</li>); externalRules.push(<li>
{_t('Notifications on the following keywords follow rules which cant be displayed here:') }
{ externalKeywords }
</li>);
} }
let devicesSection; let devicesSection;

View file

@ -371,7 +371,6 @@ class IndexedDBLogStore {
removeLogIds = allLogIds.slice(i + 1); removeLogIds = allLogIds.slice(i + 1);
break; break;
} }
} }
if (removeLogIds.length > 0) { if (removeLogIds.length > 0) {
console.log("Removing logs: ", removeLogIds); console.log("Removing logs: ", removeLogIds);
@ -469,7 +468,7 @@ export function flush() {
/** /**
* Clean up old logs. * Clean up old logs.
* @return Promise Resolves if cleaned logs. * @return {Promise} Resolves if cleaned logs.
*/ */
export async function cleanup() { export async function cleanup() {
if (!global.mx_rage_store) { if (!global.mx_rage_store) {

View file

@ -78,12 +78,13 @@ const ALLOWED_BLOB_MIMETYPES = {
/** /**
* Decrypt a file attached to a matrix event. * Decrypt a file attached to a matrix event.
* @param file {Object} The json taken from the matrix event. * @param {Object} file The json taken from the matrix event.
* This passed to [link]{@link https://github.com/matrix-org/browser-encrypt-attachments} * This passed to [link]{@link https://github.com/matrix-org/browser-encrypt-attachments}
* as the encryption info object, so will also have the those keys in addition to * as the encryption info object, so will also have the those keys in addition to
* the keys below. * the keys below.
* @param file.url {string} An mxc:// URL for the encrypted file. * @param {string} file.url An mxc:// URL for the encrypted file.
* @param file.mimetype {string} The MIME-type of the plaintext file. * @param {string} file.mimetype The MIME-type of the plaintext file.
* @returns {Promise}
*/ */
export function decryptFile(file) { export function decryptFile(file) {
const url = MatrixClientPeg.get().mxcUrlToHttp(file.url); const url = MatrixClientPeg.get().mxcUrlToHttp(file.url);

View file

@ -1,23 +1,39 @@
/*
Copyright 2018 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Find a protocol 'instance' with a given instance_id // Find a protocol 'instance' with a given instance_id
// in the supplied protocols dict // in the supplied protocols dict
export function instanceForInstanceId(protocols, instance_id) { export function instanceForInstanceId(protocols, instanceId) {
if (!instance_id) return null; if (!instanceId) return null;
for (const proto of Object.keys(protocols)) { for (const proto of Object.keys(protocols)) {
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue; if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
for (const instance of protocols[proto].instances) { for (const instance of protocols[proto].instances) {
if (instance.instance_id == instance_id) return instance; if (instance.instance_id == instanceId) return instance;
} }
} }
} }
// given an instance_id, return the name of the protocol for // given an instance_id, return the name of the protocol for
// that instance ID in the supplied protocols dict // that instance ID in the supplied protocols dict
export function protocolNameForInstanceId(protocols, instance_id) { export function protocolNameForInstanceId(protocols, instanceId) {
if (!instance_id) return null; if (!instanceId) return null;
for (const proto of Object.keys(protocols)) { for (const proto of Object.keys(protocols)) {
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue; if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
for (const instance of protocols[proto].instances) { for (const instance of protocols[proto].instances) {
if (instance.instance_id == instance_id) return proto; if (instance.instance_id == instanceId) return proto;
} }
} }
} }

View file

@ -18,6 +18,10 @@ limitations under the License.
* Given MatrixEvent containing receipts, return the first * Given MatrixEvent containing receipts, return the first
* read receipt from the given user ID, or null if no such * read receipt from the given user ID, or null if no such
* receipt exists. * receipt exists.
*
* @param {Object} receiptEvent A Matrix Event
* @param {string} userId A user ID
* @returns {Object} Read receipt
*/ */
export function findReadReceiptFromUserId(receiptEvent, userId) { export function findReadReceiptFromUserId(receiptEvent, userId) {
const receiptKeys = Object.keys(receiptEvent.getContent()); const receiptKeys = Object.keys(receiptEvent.getContent());