Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ce78cdf

Browse files
committed
Conform to new react and typescript eslint rules
1 parent b6feaf7 commit ce78cdf

File tree

266 files changed

+1992
-2000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+1992
-2000
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
4747
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
4848
"lint:js": "eslint --max-warnings 0 src test",
49+
"lint:js-fix": "eslint --fix src test",
4950
"lint:types": "tsc --noEmit --jsx react",
5051
"lint:style": "stylelint 'res/css/**/*.scss'",
5152
"test": "jest",

src/@types/global.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import UIStore from "../stores/UIStore";
5050
import { SetupEncryptionStore } from "../stores/SetupEncryptionStore";
5151
import { RoomScrollStateStore } from "../stores/RoomScrollStateStore";
5252

53+
/* eslint-disable @typescript-eslint/naming-convention */
54+
5355
declare global {
5456
interface Window {
5557
matrixChat: ReturnType<Renderer>;
@@ -186,3 +188,5 @@ declare global {
186188
}
187189
);
188190
}
191+
192+
/* eslint-enable @typescript-eslint/naming-convention */

src/Analytics.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class Analytics {
270270
localStorage.removeItem(LAST_VISIT_TS_KEY);
271271
}
272272

273-
private async _track(data: IData) {
273+
private async track(data: IData) {
274274
if (this.disabled) return;
275275

276276
const now = new Date();
@@ -304,7 +304,7 @@ export class Analytics {
304304
}
305305

306306
public ping() {
307-
this._track({
307+
this.track({
308308
ping: "1",
309309
});
310310
localStorage.setItem(LAST_VISIT_TS_KEY, String(new Date().getTime())); // update last visit ts
@@ -324,14 +324,14 @@ export class Analytics {
324324
// But continue anyway because we still want to track the change
325325
}
326326

327-
this._track({
327+
this.track({
328328
gt_ms: String(generationTimeMs),
329329
});
330330
}
331331

332332
public trackEvent(category: string, action: string, name?: string, value?: string) {
333333
if (this.disabled) return;
334-
this._track({
334+
this.track({
335335
e_c: category,
336336
e_a: action,
337337
e_n: name,
@@ -395,17 +395,17 @@ export class Analytics {
395395
Modal.createTrackedDialog('Analytics Details', '', ErrorDialog, {
396396
title: _t('Analytics'),
397397
description: <div className="mx_AnalyticsModal">
398-
<div>{_t('The information being sent to us to help make %(brand)s better includes:', {
398+
<div>{ _t('The information being sent to us to help make %(brand)s better includes:', {
399399
brand: SdkConfig.get().brand,
400-
})}</div>
400+
}) }</div>
401401
<table>
402402
{ rows.map((row) => <tr key={row[0]}>
403-
<td>{_t(
403+
<td>{ _t(
404404
customVariables[row[0]].expl,
405405
customVariables[row[0]].getTextVariables ?
406406
customVariables[row[0]].getTextVariables() :
407407
null,
408-
)}</td>
408+
) }</td>
409409
{ row[1] !== undefined && <td><code>{ row[1] }</code></td> }
410410
</tr>) }
411411
{ otherVariables.map((item, index) =>

src/CallHandler.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,23 +615,23 @@ export default class CallHandler extends EventEmitter {
615615

616616
private showICEFallbackPrompt() {
617617
const cli = MatrixClientPeg.get();
618-
const code = sub => <code>{sub}</code>;
618+
const code = sub => <code>{ sub }</code>;
619619
Modal.createTrackedDialog('No TURN servers', '', QuestionDialog, {
620620
title: _t("Call failed due to misconfigured server"),
621621
description: <div>
622-
<p>{_t(
622+
<p>{ _t(
623623
"Please ask the administrator of your homeserver " +
624624
"(<code>%(homeserverDomain)s</code>) to configure a TURN server in " +
625625
"order for calls to work reliably.",
626626
{ homeserverDomain: cli.getDomain() }, { code },
627-
)}</p>
628-
<p>{_t(
627+
) }</p>
628+
<p>{ _t(
629629
"Alternatively, you can try to use the public server at " +
630630
"<code>turn.matrix.org</code>, but this will not be as reliable, and " +
631631
"it will share your IP address with that server. You can also manage " +
632632
"this in Settings.",
633633
null, { code },
634-
)}</p>
634+
) }</p>
635635
</div>,
636636
button: _t('Try using turn.matrix.org'),
637637
cancelButton: _t('OK'),
@@ -649,19 +649,19 @@ export default class CallHandler extends EventEmitter {
649649
if (call.type === CallType.Voice) {
650650
title = _t("Unable to access microphone");
651651
description = <div>
652-
{_t(
652+
{ _t(
653653
"Call failed because microphone could not be accessed. " +
654654
"Check that a microphone is plugged in and set up correctly.",
655-
)}
655+
) }
656656
</div>;
657657
} else if (call.type === CallType.Video) {
658658
title = _t("Unable to access webcam / microphone");
659659
description = <div>
660-
{_t("Call failed because webcam or microphone could not be accessed. Check that:")}
660+
{ _t("Call failed because webcam or microphone could not be accessed. Check that:") }
661661
<ul>
662-
<li>{_t("A microphone and webcam are plugged in and set up correctly")}</li>
663-
<li>{_t("Permission is granted to use the webcam")}</li>
664-
<li>{_t("No other application is using the webcam")}</li>
662+
<li>{ _t("A microphone and webcam are plugged in and set up correctly") }</li>
663+
<li>{ _t("Permission is granted to use the webcam") }</li>
664+
<li>{ _t("No other application is using the webcam") }</li>
665665
</ul>
666666
</div>;
667667
}

src/ContentMessages.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export default class ContentMessages {
425425
const { finished } = Modal.createTrackedDialog<[boolean]>('Upload Reply Warning', '', QuestionDialog, {
426426
title: _t('Replying With Files'),
427427
description: (
428-
<div>{_t(
428+
<div>{ _t(
429429
'At this time it is not possible to reply with a file. ' +
430430
'Would you like to upload this file without replying?',
431-
)}</div>
431+
) }</div>
432432
),
433433
hasCancelButton: true,
434434
button: _t("Continue"),

src/DeviceListener.ts

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { isSecretStorageBeingAccessed, accessSecretStorage } from "./SecurityMan
3333
import { isSecureBackupRequired } from './utils/WellKnownUtils';
3434
import { isLoggedIn } from './components/structures/MatrixChat';
3535
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
36+
import { ActionPayload } from "./dispatcher/payloads";
3637

3738
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
3839

@@ -58,28 +59,28 @@ export default class DeviceListener {
5859
}
5960

6061
start() {
61-
MatrixClientPeg.get().on('crypto.willUpdateDevices', this._onWillUpdateDevices);
62-
MatrixClientPeg.get().on('crypto.devicesUpdated', this._onDevicesUpdated);
63-
MatrixClientPeg.get().on('deviceVerificationChanged', this._onDeviceVerificationChanged);
64-
MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged);
65-
MatrixClientPeg.get().on('crossSigning.keysChanged', this._onCrossSingingKeysChanged);
66-
MatrixClientPeg.get().on('accountData', this._onAccountData);
67-
MatrixClientPeg.get().on('sync', this._onSync);
68-
MatrixClientPeg.get().on('RoomState.events', this._onRoomStateEvents);
69-
this.dispatcherRef = dis.register(this._onAction);
70-
this._recheck();
62+
MatrixClientPeg.get().on('crypto.willUpdateDevices', this.onWillUpdateDevices);
63+
MatrixClientPeg.get().on('crypto.devicesUpdated', this.onDevicesUpdated);
64+
MatrixClientPeg.get().on('deviceVerificationChanged', this.onDeviceVerificationChanged);
65+
MatrixClientPeg.get().on('userTrustStatusChanged', this.onUserTrustStatusChanged);
66+
MatrixClientPeg.get().on('crossSigning.keysChanged', this.onCrossSingingKeysChanged);
67+
MatrixClientPeg.get().on('accountData', this.onAccountData);
68+
MatrixClientPeg.get().on('sync', this.onSync);
69+
MatrixClientPeg.get().on('RoomState.events', this.onRoomStateEvents);
70+
this.dispatcherRef = dis.register(this.onAction);
71+
this.recheck();
7172
}
7273

7374
stop() {
7475
if (MatrixClientPeg.get()) {
75-
MatrixClientPeg.get().removeListener('crypto.willUpdateDevices', this._onWillUpdateDevices);
76-
MatrixClientPeg.get().removeListener('crypto.devicesUpdated', this._onDevicesUpdated);
77-
MatrixClientPeg.get().removeListener('deviceVerificationChanged', this._onDeviceVerificationChanged);
78-
MatrixClientPeg.get().removeListener('userTrustStatusChanged', this._onUserTrustStatusChanged);
79-
MatrixClientPeg.get().removeListener('crossSigning.keysChanged', this._onCrossSingingKeysChanged);
80-
MatrixClientPeg.get().removeListener('accountData', this._onAccountData);
81-
MatrixClientPeg.get().removeListener('sync', this._onSync);
82-
MatrixClientPeg.get().removeListener('RoomState.events', this._onRoomStateEvents);
76+
MatrixClientPeg.get().removeListener('crypto.willUpdateDevices', this.onWillUpdateDevices);
77+
MatrixClientPeg.get().removeListener('crypto.devicesUpdated', this.onDevicesUpdated);
78+
MatrixClientPeg.get().removeListener('deviceVerificationChanged', this.onDeviceVerificationChanged);
79+
MatrixClientPeg.get().removeListener('userTrustStatusChanged', this.onUserTrustStatusChanged);
80+
MatrixClientPeg.get().removeListener('crossSigning.keysChanged', this.onCrossSingingKeysChanged);
81+
MatrixClientPeg.get().removeListener('accountData', this.onAccountData);
82+
MatrixClientPeg.get().removeListener('sync', this.onSync);
83+
MatrixClientPeg.get().removeListener('RoomState.events', this.onRoomStateEvents);
8384
}
8485
if (this.dispatcherRef) {
8586
dis.unregister(this.dispatcherRef);
@@ -103,15 +104,15 @@ export default class DeviceListener {
103104
this.dismissed.add(d);
104105
}
105106

106-
this._recheck();
107+
this.recheck();
107108
}
108109

109110
dismissEncryptionSetup() {
110111
this.dismissedThisDeviceToast = true;
111-
this._recheck();
112+
this.recheck();
112113
}
113114

114-
_ensureDeviceIdsAtStartPopulated() {
115+
private ensureDeviceIdsAtStartPopulated() {
115116
if (this.ourDeviceIdsAtStart === null) {
116117
const cli = MatrixClientPeg.get();
117118
this.ourDeviceIdsAtStart = new Set(
@@ -120,39 +121,39 @@ export default class DeviceListener {
120121
}
121122
}
122123

123-
_onWillUpdateDevices = async (users: string[], initialFetch?: boolean) => {
124+
private onWillUpdateDevices = async (users: string[], initialFetch?: boolean) => {
124125
// If we didn't know about *any* devices before (ie. it's fresh login),
125126
// then they are all pre-existing devices, so ignore this and set the
126127
// devicesAtStart list to the devices that we see after the fetch.
127128
if (initialFetch) return;
128129

129130
const myUserId = MatrixClientPeg.get().getUserId();
130-
if (users.includes(myUserId)) this._ensureDeviceIdsAtStartPopulated();
131+
if (users.includes(myUserId)) this.ensureDeviceIdsAtStartPopulated();
131132

132133
// No need to do a recheck here: we just need to get a snapshot of our devices
133134
// before we download any new ones.
134135
};
135136

136-
_onDevicesUpdated = (users: string[]) => {
137+
private onDevicesUpdated = (users: string[]) => {
137138
if (!users.includes(MatrixClientPeg.get().getUserId())) return;
138-
this._recheck();
139+
this.recheck();
139140
};
140141

141-
_onDeviceVerificationChanged = (userId: string) => {
142+
private onDeviceVerificationChanged = (userId: string) => {
142143
if (userId !== MatrixClientPeg.get().getUserId()) return;
143-
this._recheck();
144+
this.recheck();
144145
};
145146

146-
_onUserTrustStatusChanged = (userId: string) => {
147+
private onUserTrustStatusChanged = (userId: string) => {
147148
if (userId !== MatrixClientPeg.get().getUserId()) return;
148-
this._recheck();
149+
this.recheck();
149150
};
150151

151-
_onCrossSingingKeysChanged = () => {
152-
this._recheck();
152+
private onCrossSingingKeysChanged = () => {
153+
this.recheck();
153154
};
154155

155-
_onAccountData = (ev) => {
156+
private onAccountData = (ev: MatrixEvent) => {
156157
// User may have:
157158
// * migrated SSSS to symmetric
158159
// * uploaded keys to secret storage
@@ -163,32 +164,32 @@ export default class DeviceListener {
163164
ev.getType().startsWith('m.cross_signing.') ||
164165
ev.getType() === 'm.megolm_backup.v1'
165166
) {
166-
this._recheck();
167+
this.recheck();
167168
}
168169
};
169170

170-
_onSync = (state, prevState) => {
171-
if (state === 'PREPARED' && prevState === null) this._recheck();
171+
private onSync = (state, prevState) => {
172+
if (state === 'PREPARED' && prevState === null) this.recheck();
172173
};
173174

174-
_onRoomStateEvents = (ev: MatrixEvent) => {
175+
private onRoomStateEvents = (ev: MatrixEvent) => {
175176
if (ev.getType() !== "m.room.encryption") {
176177
return;
177178
}
178179

179180
// If a room changes to encrypted, re-check as it may be our first
180181
// encrypted room. This also catches encrypted room creation as well.
181-
this._recheck();
182+
this.recheck();
182183
};
183184

184-
_onAction = ({ action }) => {
185+
private onAction = ({ action }: ActionPayload) => {
185186
if (action !== "on_logged_in") return;
186-
this._recheck();
187+
this.recheck();
187188
};
188189

189190
// The server doesn't tell us when key backup is set up, so we poll
190191
// & cache the result
191-
async _getKeyBackupInfo() {
192+
private async getKeyBackupInfo() {
192193
const now = (new Date()).getTime();
193194
if (!this.keyBackupInfo || this.keyBackupFetchedAt < now - KEY_BACKUP_POLL_INTERVAL) {
194195
this.keyBackupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
@@ -206,7 +207,7 @@ export default class DeviceListener {
206207
return cli && cli.getRooms().some(r => cli.isRoomEncrypted(r.roomId));
207208
}
208209

209-
async _recheck() {
210+
private async recheck() {
210211
const cli = MatrixClientPeg.get();
211212

212213
if (!await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) return;
@@ -235,7 +236,7 @@ export default class DeviceListener {
235236
// Cross-signing on account but this device doesn't trust the master key (verify this session)
236237
showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION);
237238
} else {
238-
const backupInfo = await this._getKeyBackupInfo();
239+
const backupInfo = await this.getKeyBackupInfo();
239240
if (backupInfo) {
240241
// No cross-signing on account but key backup available (upgrade encryption)
241242
showSetupEncryptionToast(SetupKind.UPGRADE_ENCRYPTION);
@@ -256,7 +257,7 @@ export default class DeviceListener {
256257

257258
// This needs to be done after awaiting on downloadKeys() above, so
258259
// we make sure we get the devices after the fetch is done.
259-
this._ensureDeviceIdsAtStartPopulated();
260+
this.ensureDeviceIdsAtStartPopulated();
260261

261262
// Unverified devices that were there last time the app ran
262263
// (technically could just be a boolean: we don't actually

src/IdentityAuthClient.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ export default class IdentityAuthClient {
149149
title: _t("Identity server has no terms of service"),
150150
description: (
151151
<div>
152-
<p>{_t(
152+
<p>{ _t(
153153
"This action requires accessing the default identity server " +
154154
"<server /> to validate an email address or phone number, " +
155155
"but the server does not have any terms of service.", {},
156156
{
157-
server: () => <b>{abbreviateUrl(identityServerUrl)}</b>,
157+
server: () => <b>{ abbreviateUrl(identityServerUrl) }</b>,
158158
},
159-
)}</p>
160-
<p>{_t(
159+
) }</p>
160+
<p>{ _t(
161161
"Only continue if you trust the owner of the server.",
162-
)}</p>
162+
) }</p>
163163
</div>
164164
),
165165
button: _t("Trust"),

src/MatrixClientPeg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface IMatrixClientPeg {
105105
* This module provides a singleton instance of this class so the 'current'
106106
* Matrix Client object is available easily.
107107
*/
108-
class _MatrixClientPeg implements IMatrixClientPeg {
108+
class MatrixClientPegClass implements IMatrixClientPeg {
109109
// These are the default options used when when the
110110
// client is started in 'start'. These can be altered
111111
// at any time up to after the 'will_start_client'
@@ -300,7 +300,7 @@ class _MatrixClientPeg implements IMatrixClientPeg {
300300
}
301301

302302
if (!window.mxMatrixClientPeg) {
303-
window.mxMatrixClientPeg = new _MatrixClientPeg();
303+
window.mxMatrixClientPeg = new MatrixClientPegClass();
304304
}
305305

306306
export const MatrixClientPeg = window.mxMatrixClientPeg;

0 commit comments

Comments
 (0)