Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

Commit 8f4879e

Browse files
committed
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/ts/8
� Conflicts: � src/components/structures/MessagePanel.tsx � src/components/structures/ScrollPanel.tsx � src/components/structures/TimelinePanel.tsx � src/components/views/elements/ErrorBoundary.tsx � src/components/views/elements/EventListSummary.tsx � src/components/views/messages/TileErrorBoundary.tsx
2 parents 623317c + 9d6d8fc commit 8f4879e

File tree

638 files changed

+3443
-4516
lines changed

Some content is hidden

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

638 files changed

+3443
-4516
lines changed

.eslintrc.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = {
2-
extends: ["matrix-org", "matrix-org/react-legacy"],
3-
parser: "babel-eslint",
4-
2+
plugins: ["matrix-org"],
3+
extends: [
4+
"plugin:matrix-org/babel",
5+
"plugin:matrix-org/react",
6+
],
57
env: {
68
browser: true,
79
node: true,
@@ -15,21 +17,39 @@ module.exports = {
1517
"prefer-promise-reject-errors": "off",
1618
"no-async-promise-executor": "off",
1719
"quotes": "off",
18-
},
20+
"no-extra-boolean-cast": "off",
1921

22+
// Bind or arrow functions in props causes performance issues (but we
23+
// currently use them in some places).
24+
// It's disabled here, but we should using it sparingly.
25+
"react/jsx-no-bind": "off",
26+
"react/jsx-key": ["error"],
27+
},
2028
overrides: [{
21-
"files": ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}"],
22-
"extends": ["matrix-org/ts"],
23-
"rules": {
29+
files: [
30+
"src/**/*.{ts,tsx}",
31+
"test/**/*.{ts,tsx}",
32+
],
33+
extends: [
34+
"plugin:matrix-org/typescript",
35+
"plugin:matrix-org/react",
36+
],
37+
rules: {
38+
// Things we do that break the ideal style
39+
"prefer-promise-reject-errors": "off",
40+
"quotes": "off",
41+
"no-extra-boolean-cast": "off",
42+
43+
// Remove Babel things manually due to override limitations
44+
"@babel/no-invalid-this": ["off"],
45+
2446
// We're okay being explicit at the moment
2547
"@typescript-eslint/no-empty-interface": "off",
2648
// We disable this while we're transitioning
2749
"@typescript-eslint/no-explicit-any": "off",
2850
// We'd rather not do this but we do
2951
"@typescript-eslint/ban-ts-comment": "off",
3052

31-
"quotes": "off",
32-
"no-extra-boolean-cast": "off",
3353
"no-restricted-properties": [
3454
"error",
3555
...buildRestrictedPropertiesOptions(

.flowconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

babel.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
],
1111
}],
1212
"@babel/preset-typescript",
13-
"@babel/preset-flow",
1413
"@babel/preset-react",
1514
],
1615
"plugins": [
@@ -19,7 +18,6 @@ module.exports = {
1918
"@babel/plugin-proposal-numeric-separator",
2019
"@babel/plugin-proposal-class-properties",
2120
"@babel/plugin-proposal-object-rest-spread",
22-
"@babel/plugin-transform-flow-comments",
2321
"@babel/plugin-syntax-dynamic-import",
2422
"@babel/plugin-transform-runtime",
2523
],

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@
104104
"devDependencies": {
105105
"@babel/cli": "^7.12.10",
106106
"@babel/core": "^7.12.10",
107+
"@babel/eslint-parser": "^7.12.10",
108+
"@babel/eslint-plugin": "^7.12.10",
107109
"@babel/parser": "^7.12.11",
108110
"@babel/plugin-proposal-class-properties": "^7.12.1",
109111
"@babel/plugin-proposal-decorators": "^7.12.12",
110112
"@babel/plugin-proposal-export-default-from": "^7.12.1",
111113
"@babel/plugin-proposal-numeric-separator": "^7.12.7",
112114
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
113-
"@babel/plugin-transform-flow-comments": "^7.12.1",
114115
"@babel/plugin-transform-runtime": "^7.12.10",
115116
"@babel/preset-env": "^7.12.11",
116-
"@babel/preset-flow": "^7.12.1",
117117
"@babel/preset-react": "^7.12.10",
118118
"@babel/preset-typescript": "^7.12.7",
119119
"@babel/register": "^7.12.10",
@@ -139,18 +139,16 @@
139139
"@types/react-transition-group": "^4.4.0",
140140
"@types/sanitize-html": "^2.3.1",
141141
"@types/zxcvbn": "^4.4.0",
142-
"@typescript-eslint/eslint-plugin": "^4.14.0",
143-
"@typescript-eslint/parser": "^4.14.0",
142+
"@typescript-eslint/eslint-plugin": "^4.17.0",
143+
"@typescript-eslint/parser": "^4.17.0",
144144
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
145-
"babel-eslint": "^10.1.0",
146145
"babel-jest": "^26.6.3",
147146
"chokidar": "^3.5.1",
148147
"concurrently": "^5.3.0",
149148
"enzyme": "^3.11.0",
150149
"eslint": "7.18.0",
151-
"eslint-config-matrix-org": "^0.2.0",
152-
"eslint-plugin-babel": "^5.3.1",
153-
"eslint-plugin-flowtype": "^5.2.0",
150+
"eslint-config-google": "^0.14.0",
151+
"eslint-plugin-matrix-org": "github:matrix-org/eslint-plugin-matrix-org#main",
154152
"eslint-plugin-react": "^7.22.0",
155153
"eslint-plugin-react-hooks": "^4.2.0",
156154
"glob": "^7.1.6",

res/css/structures/_ToastContainer.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,15 @@ limitations under the License.
134134
.mx_Toast_buttons {
135135
float: right;
136136
display: flex;
137-
gap: 5px;
138137

139138
.mx_AccessibleButton {
140139
min-width: 96px;
141140
box-sizing: border-box;
142141
}
142+
143+
.mx_AccessibleButton + .mx_AccessibleButton {
144+
margin-left: 5px;
145+
}
143146
}
144147

145148
.mx_Toast_description {

src/@types/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import { JSXElementConstructor } from "react";
1818

1919
// Based on https://stackoverflow.com/a/53229857/3532235
20-
export type Without<T, U> = {[P in Exclude<keyof T, keyof U>] ? : never};
20+
export type Without<T, U> = {[P in Exclude<keyof T, keyof U>]?: never};
2121
export type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
2222
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
2323

src/AddThreepid.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19-
import {MatrixClientPeg} from './MatrixClientPeg';
19+
import { MatrixClientPeg } from './MatrixClientPeg';
2020
import * as sdk from './index';
2121
import Modal from './Modal';
2222
import { _t } from './languageHandler';
2323
import IdentityAuthClient from './IdentityAuthClient';
24-
import {SSOAuthEntry} from "./components/views/auth/InteractiveAuthEntryComponents";
24+
import { SSOAuthEntry } from "./components/views/auth/InteractiveAuthEntryComponents";
2525

2626
function getIdServerDomain() {
2727
return MatrixClientPeg.get().idBaseUrl.split("://")[1];
@@ -189,7 +189,6 @@ export default class AddThreepid {
189189
// pop up an interactive auth dialog
190190
const InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog");
191191

192-
193192
const dialogAesthetics = {
194193
[SSOAuthEntry.PHASE_PREAUTH]: {
195194
title: _t("Use Single Sign On to continue"),

src/Analytics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717

1818
import React from 'react';
1919

20-
import {getCurrentLanguage, _t, _td, IVariables} from './languageHandler';
20+
import { getCurrentLanguage, _t, _td, IVariables } from './languageHandler';
2121
import PlatformPeg from './PlatformPeg';
2222
import SdkConfig from './SdkConfig';
2323
import Modal from './Modal';

src/BasePlatform.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20-
import {MatrixClient} from "matrix-js-sdk/src/client";
21-
import {encodeUnpaddedBase64} from "matrix-js-sdk/src/crypto/olmlib";
20+
import { MatrixClient } from "matrix-js-sdk/src/client";
21+
import { encodeUnpaddedBase64 } from "matrix-js-sdk/src/crypto/olmlib";
2222
import dis from './dispatcher/dispatcher';
2323
import BaseEventIndexManager from './indexing/BaseEventIndexManager';
24-
import {ActionPayload} from "./dispatcher/payloads";
25-
import {CheckUpdatesPayload} from "./dispatcher/payloads/CheckUpdatesPayload";
26-
import {Action} from "./dispatcher/actions";
27-
import {hideToast as hideUpdateToast} from "./toasts/UpdateToast";
28-
import {MatrixClientPeg} from "./MatrixClientPeg";
29-
import {idbLoad, idbSave, idbDelete} from "./utils/StorageManager";
24+
import { ActionPayload } from "./dispatcher/payloads";
25+
import { CheckUpdatesPayload } from "./dispatcher/payloads/CheckUpdatesPayload";
26+
import { Action } from "./dispatcher/actions";
27+
import { hideToast as hideUpdateToast } from "./toasts/UpdateToast";
28+
import { MatrixClientPeg } from "./MatrixClientPeg";
29+
import { idbLoad, idbSave, idbDelete } from "./utils/StorageManager";
3030

3131
export const SSO_HOMESERVER_URL_KEY = "mx_sso_hs_url";
3232
export const SSO_ID_SERVER_URL_KEY = "mx_sso_is_url";
@@ -335,7 +335,7 @@ export default abstract class BasePlatform {
335335

336336
try {
337337
const key = await crypto.subtle.decrypt(
338-
{name: "AES-GCM", iv: data.iv, additionalData}, data.cryptoKey,
338+
{ name: "AES-GCM", iv: data.iv, additionalData }, data.cryptoKey,
339339
data.encrypted,
340340
);
341341
return encodeUnpaddedBase64(key);
@@ -360,7 +360,7 @@ export default abstract class BasePlatform {
360360
const randomArray = new Uint8Array(32);
361361
crypto.getRandomValues(randomArray);
362362
const cryptoKey = await crypto.subtle.generateKey(
363-
{name: "AES-GCM", length: 256}, false, ["encrypt", "decrypt"],
363+
{ name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"],
364364
);
365365
const iv = new Uint8Array(32);
366366
crypto.getRandomValues(iv);
@@ -375,11 +375,11 @@ export default abstract class BasePlatform {
375375
}
376376

377377
const encrypted = await crypto.subtle.encrypt(
378-
{name: "AES-GCM", iv, additionalData}, cryptoKey, randomArray,
378+
{ name: "AES-GCM", iv, additionalData }, cryptoKey, randomArray,
379379
);
380380

381381
try {
382-
await idbSave("pickleKey", [userId, deviceId], {encrypted, iv, cryptoKey});
382+
await idbSave("pickleKey", [userId, deviceId], { encrypted, iv, cryptoKey });
383383
} catch (e) {
384384
return null;
385385
}

src/CallHandler.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ limitations under the License.
5555

5656
import React from 'react';
5757

58-
import {MatrixClientPeg} from './MatrixClientPeg';
58+
import { MatrixClientPeg } from './MatrixClientPeg';
5959
import PlatformPeg from './PlatformPeg';
6060
import Modal from './Modal';
6161
import { _t } from './languageHandler';
6262
import dis from './dispatcher/dispatcher';
6363
import WidgetUtils from './utils/WidgetUtils';
6464
import WidgetEchoStore from './stores/WidgetEchoStore';
6565
import SettingsStore from './settings/SettingsStore';
66-
import {Jitsi} from "./widgets/Jitsi";
67-
import {WidgetType} from "./widgets/WidgetType";
68-
import {SettingLevel} from "./settings/SettingLevel";
66+
import { Jitsi } from "./widgets/Jitsi";
67+
import { WidgetType } from "./widgets/WidgetType";
68+
import { SettingLevel } from "./settings/SettingLevel";
6969
import { ActionPayload } from "./dispatcher/payloads";
70-
import {base32} from "rfc4648";
70+
import { base32 } from "rfc4648";
7171

7272
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
7373
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
@@ -77,10 +77,10 @@ import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions";
7777
import { MatrixCall, CallErrorCode, CallState, CallEvent, CallParty, CallType } from "matrix-js-sdk/src/webrtc/call";
7878
import Analytics from './Analytics';
7979
import CountlyAnalytics from "./CountlyAnalytics";
80-
import {UIFeature} from "./settings/UIFeature";
80+
import { UIFeature } from "./settings/UIFeature";
8181
import { CallError } from "matrix-js-sdk/src/webrtc/call";
8282
import { logger } from 'matrix-js-sdk/src/logger';
83-
import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapturerSourcePicker"
83+
import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapturerSourcePicker";
8484
import { Action } from './dispatcher/actions';
8585
import VoipUserMapper from './VoipUserMapper';
8686
import { addManagedHybridWidget, isManagedHybridWidgetEnabled } from './widgets/ManagedHybrid';
@@ -166,7 +166,7 @@ export default class CallHandler extends EventEmitter {
166166

167167
static sharedInstance() {
168168
if (!window.mxCallHandler) {
169-
window.mxCallHandler = new CallHandler()
169+
window.mxCallHandler = new CallHandler();
170170
}
171171

172172
return window.mxCallHandler;
@@ -185,7 +185,7 @@ export default class CallHandler extends EventEmitter {
185185
const nativeUser = this.assertedIdentityNativeUsers[call.callId];
186186
if (nativeUser) {
187187
const room = findDMForUser(MatrixClientPeg.get(), nativeUser);
188-
if (room) return room.roomId
188+
if (room) return room.roomId;
189189
}
190190
}
191191

@@ -238,15 +238,15 @@ export default class CallHandler extends EventEmitter {
238238
this.supportsPstnProtocol = null;
239239
}
240240

241-
dis.dispatch({action: Action.PstnSupportUpdated});
241+
dis.dispatch({ action: Action.PstnSupportUpdated });
242242

243243
if (protocols[PROTOCOL_SIP_NATIVE] !== undefined && protocols[PROTOCOL_SIP_VIRTUAL] !== undefined) {
244244
this.supportsSipNativeVirtual = Boolean(
245245
protocols[PROTOCOL_SIP_NATIVE] && protocols[PROTOCOL_SIP_VIRTUAL],
246246
);
247247
}
248248

249-
dis.dispatch({action: Action.VirtualRoomSupportUpdated});
249+
dis.dispatch({ action: Action.VirtualRoomSupportUpdated });
250250
} catch (e) {
251251
if (maxTries === 1) {
252252
console.log("Failed to check for protocol support and no retries remain: assuming no support", e);
@@ -299,7 +299,7 @@ export default class CallHandler extends EventEmitter {
299299
action: 'incoming_call',
300300
call: call,
301301
}, true);
302-
}
302+
};
303303

304304
getCallForRoom(roomId: string): MatrixCall {
305305
return this.calls.get(roomId) || null;
@@ -711,7 +711,7 @@ export default class CallHandler extends EventEmitter {
711711

712712
call.placeScreenSharingCall(
713713
async (): Promise<DesktopCapturerSource> => {
714-
const {finished} = Modal.createDialog(DesktopCapturerSourcePicker);
714+
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
715715
const [source] = await finished;
716716
return source;
717717
},
@@ -816,7 +816,7 @@ export default class CallHandler extends EventEmitter {
816816

817817
Analytics.trackEvent('voip', 'receiveCall', 'type', call.type);
818818
console.log("Adding call for room ", mappedRoomId);
819-
this.calls.set(mappedRoomId, call)
819+
this.calls.set(mappedRoomId, call);
820820
this.emit(CallHandlerEvent.CallsChanged, this.calls);
821821
this.setCallListeners(call);
822822

@@ -872,7 +872,7 @@ export default class CallHandler extends EventEmitter {
872872
this.dialNumber(payload.number);
873873
break;
874874
}
875-
}
875+
};
876876

877877
private async dialNumber(number: string) {
878878
const results = await this.pstnLookup(number);
@@ -966,7 +966,7 @@ export default class CallHandler extends EventEmitter {
966966
confId = 'Jitsi' + random;
967967
}
968968

969-
let widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({auth: jitsiAuth});
969+
let widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({ auth: jitsiAuth });
970970

971971
// TODO: Remove URL hacks when the mobile clients eventually support v2 widgets
972972
const parsedUrl = new URL(widgetUrl);

0 commit comments

Comments
 (0)