diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index 83f185de61..6ffeda8db9 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -5,25 +5,10 @@ src/Rooms.js src/Unread.js src/Velociraptor.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/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/utils/DMRoomMap.js -src/utils/DecryptFile.js -src/utils/DirectoryUtils.js src/utils/MultiInviter.js -src/utils/Receipt.js test/components/structures/MessagePanel-test.js test/components/views/dialogs/InteractiveAuthDialog-test.js test/mock-clock.js diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 99a3da2565..744400df3c 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -704,7 +704,7 @@ export default class ScrollPanel extends React.Component { if (itemlist.style.height !== newHeight) { itemlist.style.height = newHeight; } - if (sn.scrollTop !== sn.scrollHeight){ + if (sn.scrollTop !== sn.scrollHeight) { sn.scrollTop = sn.scrollHeight; } debuglog("updateHeight to", newHeight); diff --git a/src/components/structures/UploadBar.js b/src/components/structures/UploadBar.js index 0865764c5a..16cc4cb987 100644 --- a/src/components/structures/UploadBar.js +++ b/src/components/structures/UploadBar.js @@ -86,7 +86,9 @@ export default class UploadBar extends React.Component { } // 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 (
diff --git a/src/components/views/elements/AddressSelector.js b/src/components/views/elements/AddressSelector.js index 45cdbeced8..2a71622bb8 100644 --- a/src/components/views/elements/AddressSelector.js +++ b/src/components/views/elements/AddressSelector.js @@ -46,7 +46,7 @@ export default class AddressSelector extends React.Component { } // 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 const selected = this.state.selected; const maxSelected = this._maxSelected(props.addressList); diff --git a/src/components/views/elements/DirectorySearchBox.js b/src/components/views/elements/DirectorySearchBox.js index 5fe2f6dbc8..c2e8e4fd68 100644 --- a/src/components/views/elements/DirectorySearchBox.js +++ b/src/components/views/elements/DirectorySearchBox.js @@ -16,7 +16,6 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; -import classnames from 'classnames'; import * as sdk from '../../../index'; import { _t } from '../../../languageHandler'; @@ -78,14 +77,14 @@ export default class DirectorySearchBox extends React.Component { render() { const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); - const searchbox_classes = { + const searchboxClasses = { mx_DirectorySearchBox: true, }; - searchbox_classes[this.props.className] = true; + searchboxClasses[this.props.className] = true; - let join_button; + let joinButton; if (this.props.showJoinButton) { - join_button = {_t("Join")}; } @@ -97,7 +96,7 @@ export default class DirectorySearchBox extends React.Component { onChange={this._onChange} onKeyUp={this._onKeyUp} placeholder={this.props.placeholder} autoFocus /> - { join_button } + { joinButton }
; } diff --git a/src/components/views/messages/MFileBody.js b/src/components/views/messages/MFileBody.js index cc140a4352..d17a1c4ce3 100644 --- a/src/components/views/messages/MFileBody.js +++ b/src/components/views/messages/MFileBody.js @@ -144,7 +144,7 @@ export default class MFileBody extends React.Component { * Extracts a human readable label for the file attachment to use as * 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. */ presentableTextForFile(content) { diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 9764b08e5b..8f153e48e9 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -416,7 +416,9 @@ export default class TextualBody extends React.Component { if (this.props.highlightLink) { body = { body }; } else if (content.data && typeof content.data["org.matrix.neb.starter_link"] === "string") { - body = { body }; + body = { body }; } let widgets; diff --git a/src/components/views/rooms/LinkPreviewWidget.js b/src/components/views/rooms/LinkPreviewWidget.js index a3d59e5137..2a053bf467 100644 --- a/src/components/views/rooms/LinkPreviewWidget.js +++ b/src/components/views/rooms/LinkPreviewWidget.js @@ -114,7 +114,10 @@ export default class LinkPreviewWidget extends React.Component { let thumbHeight = imageMaxHeight; 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; diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index f42e18372a..dc68068157 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -284,7 +284,7 @@ export default class RoomPreviewBar extends React.Component { room_name: this.props.oobData ? this.props.oobData.room_name : null, room_avatar_url: this.props.oobData ? this.props.oobData.avatarUrl : 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) { footer = (
- + {_t("Loading room preview")}
); diff --git a/src/components/views/settings/ChangeAvatar.js b/src/components/views/settings/ChangeAvatar.js index a6fc60ceb9..7ab2936584 100644 --- a/src/components/views/settings/ChangeAvatar.js +++ b/src/components/views/settings/ChangeAvatar.js @@ -19,6 +19,7 @@ import PropTypes from 'prop-types'; import {MatrixClientPeg} from "../../../MatrixClientPeg"; import * as sdk from '../../../index'; import { _t } from '../../../languageHandler'; +import Spinner from '../elements/Spinner'; export default class ChangeAvatar extends React.Component { static propTypes = { @@ -58,7 +59,7 @@ export default class ChangeAvatar extends React.Component { } // TODO: [REACT-WARNING] Replace with appropriate lifecycle event - UNSAFE_componentWillReceiveProps(newProps) { + UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line camelcase if (this.avatarSet) { // don't clobber what the user has just set return; @@ -143,7 +144,9 @@ export default class ChangeAvatar extends React.Component { // time to propagate through to the RoomAvatar. if (this.props.room && !this.avatarSet) { const RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); - avatarImg = ; + avatarImg = ; } else { 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 ? @@ -174,9 +177,8 @@ export default class ChangeAvatar extends React.Component { ); case ChangeAvatar.Phases.Uploading: - var Loader = sdk.getComponent("elements.Spinner"); return ( - + ); } } diff --git a/src/components/views/settings/DevicesPanel.js b/src/components/views/settings/DevicesPanel.js index fe4a4abfdc..dc3ce9e03d 100644 --- a/src/components/views/settings/DevicesPanel.js +++ b/src/components/views/settings/DevicesPanel.js @@ -74,7 +74,7 @@ export default class DevicesPanel extends React.Component { } - /** + /* * compare two devices, sorting from most-recently-seen to least-recently-seen * (and then, for stability, by device id) */ diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index 6eaf55279b..cd87803d84 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -94,7 +94,9 @@ export default class Notifications extends React.Component { 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(); }); }; @@ -216,8 +218,8 @@ export default class Notifications extends React.Component { description: _t('Enter keywords separated by a comma:'), button: _t('OK'), value: keywords, - onFinished: (should_leave, newValue) => { - if (should_leave && newValue !== keywords) { + onFinished: (shouldLeave, newValue) => { + if (shouldLeave && newValue !== keywords) { let newKeywords = newValue.split(','); for (const i in newKeywords) { newKeywords[i] = newKeywords[i].trim(); @@ -403,7 +405,9 @@ export default class Notifications extends React.Component { // when creating the new rule. // Thus, this new rule will join the 'vectorContentRules' set. if (self.state.vectorContentRules.rules.length) { - pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind(self.state.vectorContentRules.rules[0]); + pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind( + self.state.vectorContentRules.rules[0], + ); } else { // ON is default pushRuleVectorStateKind = PushRuleVectorState.ON; @@ -415,10 +419,9 @@ export default class Notifications extends React.Component { if (vectorContentRulesPatterns.indexOf(keyword) < 0) { if (self.state.vectorContentRules.vectorState !== PushRuleVectorState.OFF) { - deferreds.push(cli.addPushRule - ('global', 'content', keyword, { - actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind), - pattern: keyword, + deferreds.push(cli.addPushRule('global', 'content', keyword, { + actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind), + pattern: keyword, })); } else { deferreds.push(self._addDisabledPushRule('global', 'content', keyword, { @@ -482,12 +485,14 @@ export default class Notifications extends React.Component { _refreshFromServer = () => { 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? MatrixClientPeg.get().pushRules = rulesets; // Get homeserver default rules and triage them by categories - const rule_categories = { + const ruleCategories = { // The master rule (all notifications disabling) '.m.rule.master': 'master', @@ -514,7 +519,7 @@ export default class Notifications extends React.Component { for (const kind in rulesets.global) { for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) { const r = rulesets.global[kind][i]; - const cat = rule_categories[r.rule_id]; + const cat = ruleCategories[r.rule_id]; r.kind = kind; if (r.rule_id[0] === '.') { @@ -750,7 +755,7 @@ export default class Notifications extends React.Component { if (this.state.masterPushRule) { masterPushRuleDiv = ; + label={_t('Enable notifications for this account')} />; } let clearNotificationsButton; @@ -803,7 +808,10 @@ export default class Notifications extends React.Component { } if (externalKeywords.length) { externalKeywords = externalKeywords.join(", "); - externalRules.push(
  • { _t('Notifications on the following keywords follow rules which can’t be displayed here:') } { externalKeywords }
  • ); + externalRules.push(
  • + {_t('Notifications on the following keywords follow rules which can’t be displayed here:') } + { externalKeywords } +
  • ); } let devicesSection; diff --git a/src/rageshake/rageshake.js b/src/rageshake/rageshake.js index 59ed5fa8b7..8eb77bb3ae 100644 --- a/src/rageshake/rageshake.js +++ b/src/rageshake/rageshake.js @@ -371,7 +371,6 @@ class IndexedDBLogStore { removeLogIds = allLogIds.slice(i + 1); break; } - } if (removeLogIds.length > 0) { console.log("Removing logs: ", removeLogIds); @@ -469,7 +468,7 @@ export function flush() { /** * Clean up old logs. - * @return Promise Resolves if cleaned logs. + * @return {Promise} Resolves if cleaned logs. */ export async function cleanup() { if (!global.mx_rage_store) { diff --git a/src/utils/DecryptFile.js b/src/utils/DecryptFile.js index dcdc2f9fdb..d3625d614a 100644 --- a/src/utils/DecryptFile.js +++ b/src/utils/DecryptFile.js @@ -78,12 +78,13 @@ const ALLOWED_BLOB_MIMETYPES = { /** * 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} * as the encryption info object, so will also have the those keys in addition to * the keys below. - * @param file.url {string} An mxc:// URL for the encrypted file. - * @param file.mimetype {string} The MIME-type of the plaintext file. + * @param {string} file.url An mxc:// URL for the encrypted file. + * @param {string} file.mimetype The MIME-type of the plaintext file. + * @returns {Promise} */ export function decryptFile(file) { const url = MatrixClientPeg.get().mxcUrlToHttp(file.url); diff --git a/src/utils/DirectoryUtils.js b/src/utils/DirectoryUtils.js index 72e44681b6..577a6441f8 100644 --- a/src/utils/DirectoryUtils.js +++ b/src/utils/DirectoryUtils.js @@ -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 // in the supplied protocols dict -export function instanceForInstanceId(protocols, instance_id) { - if (!instance_id) return null; +export function instanceForInstanceId(protocols, instanceId) { + if (!instanceId) return null; for (const proto of Object.keys(protocols)) { if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue; 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 // that instance ID in the supplied protocols dict -export function protocolNameForInstanceId(protocols, instance_id) { - if (!instance_id) return null; +export function protocolNameForInstanceId(protocols, instanceId) { + if (!instanceId) return null; for (const proto of Object.keys(protocols)) { if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue; for (const instance of protocols[proto].instances) { - if (instance.instance_id == instance_id) return proto; + if (instance.instance_id == instanceId) return proto; } } } diff --git a/src/utils/Receipt.js b/src/utils/Receipt.js index 04bd4a4d8f..d88c67fb18 100644 --- a/src/utils/Receipt.js +++ b/src/utils/Receipt.js @@ -18,6 +18,10 @@ limitations under the License. * Given MatrixEvent containing receipts, return the first * read receipt from the given user ID, or null if no such * receipt exists. + * + * @param {Object} receiptEvent A Matrix Event + * @param {string} userId A user ID + * @returns {Object} Read receipt */ export function findReadReceiptFromUserId(receiptEvent, userId) { const receiptKeys = Object.keys(receiptEvent.getContent());