Enable @typescript-eslint/explicit-function-return-type in /src (#9788)

* Enable `@typescript-eslint/explicit-member-accessibility` on /src

* Prettier

* Enable `@typescript-eslint/explicit-function-return-type` in /src

* Fix types

* tsc strict fixes

* Delint

* Fix test

* Fix bad merge
This commit is contained in:
Michael Telatynski
2023-01-12 13:25:14 +00:00
committed by GitHub
parent 7a36ba0fde
commit 030b7e90bf
683 changed files with 3459 additions and 3013 deletions
+6 -6
View File
@@ -30,19 +30,19 @@ import {
import { Action } from "../dispatcher/actions";
import SettingsStore from "../settings/SettingsStore";
const onAccept = () => {
const onAccept = (): void => {
dis.dispatch({
action: Action.PseudonymousAnalyticsAccept,
});
};
const onReject = () => {
const onReject = (): void => {
dis.dispatch({
action: Action.PseudonymousAnalyticsReject,
});
};
const onLearnMoreNoOptIn = () => {
const onLearnMoreNoOptIn = (): void => {
showAnalyticsLearnMoreDialog({
onFinished: (buttonClicked?: ButtonClicked) => {
if (buttonClicked === ButtonClicked.Primary) {
@@ -56,7 +56,7 @@ const onLearnMoreNoOptIn = () => {
});
};
const onLearnMorePreviouslyOptedIn = () => {
const onLearnMorePreviouslyOptedIn = (): void => {
showAnalyticsLearnMoreDialog({
onFinished: (buttonClicked?: ButtonClicked) => {
if (buttonClicked === ButtonClicked.Primary) {
@@ -98,7 +98,7 @@ export const showToast = (): void => {
} else if (legacyAnalyticsOptIn === null || legacyAnalyticsOptIn === undefined) {
// The user had no analytics setting previously set, so we just need to prompt to opt-in, rather than
// explaining any change.
const learnMoreLink = (sub: string) => (
const learnMoreLink = (sub: string): JSX.Element => (
<AccessibleButton kind="link_inline" onClick={onLearnMoreNoOptIn}>
{sub}
</AccessibleButton>
@@ -132,6 +132,6 @@ export const showToast = (): void => {
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+4 -4
View File
@@ -24,8 +24,8 @@ import { snoozeBulkUnverifiedDeviceReminder } from "../utils/device/snoozeBulkUn
const TOAST_KEY = "reviewsessions";
export const showToast = (deviceIds: Set<string>) => {
const onAccept = () => {
export const showToast = (deviceIds: Set<string>): void => {
const onAccept = (): void => {
DeviceListener.sharedInstance().dismissUnverifiedSessions(deviceIds);
dis.dispatch({
@@ -33,7 +33,7 @@ export const showToast = (deviceIds: Set<string>) => {
});
};
const onReject = () => {
const onReject = (): void => {
DeviceListener.sharedInstance().dismissUnverifiedSessions(deviceIds);
snoozeBulkUnverifiedDeviceReminder();
};
@@ -54,6 +54,6 @@ export const showToast = (deviceIds: Set<string>) => {
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+4 -4
View File
@@ -21,7 +21,7 @@ import ToastStore from "../stores/ToastStore";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { getLocalNotificationAccountDataEventType } from "../utils/notifications";
const onAccept = () => {
const onAccept = (): void => {
Notifier.setEnabled(true);
const cli = MatrixClientPeg.get();
const eventType = getLocalNotificationAccountDataEventType(cli.deviceId);
@@ -30,13 +30,13 @@ const onAccept = () => {
});
};
const onReject = () => {
const onReject = (): void => {
Notifier.setPromptHidden(true);
};
const TOAST_KEY = "desktopnotifications";
export const showToast = (fromMessageSend: boolean) => {
export const showToast = (fromMessageSend: boolean): void => {
ToastStore.sharedInstance().addOrReplaceToast({
key: TOAST_KEY,
title: fromMessageSend ? _t("Don't miss a reply") : _t("Notifications"),
@@ -52,6 +52,6 @@ export const showToast = (fromMessageSend: boolean) => {
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+3 -3
View File
@@ -37,14 +37,14 @@ import { useDispatcher } from "../hooks/useDispatcher";
import { ActionPayload } from "../dispatcher/payloads";
import { Call } from "../models/Call";
export const getIncomingCallToastKey = (stateKey: string) => `call_${stateKey}`;
export const getIncomingCallToastKey = (stateKey: string): string => `call_${stateKey}`;
interface JoinCallButtonWithCallProps {
onClick: (e: ButtonEvent) => void;
call: Call;
}
function JoinCallButtonWithCall({ onClick, call }: JoinCallButtonWithCallProps) {
function JoinCallButtonWithCall({ onClick, call }: JoinCallButtonWithCallProps): JSX.Element {
const disabledTooltip = useJoinCallButtonDisabledTooltip(call);
return (
@@ -64,7 +64,7 @@ interface Props {
callEvent: MatrixEvent;
}
export function IncomingCallToast({ callEvent }: Props) {
export function IncomingCallToast({ callEvent }: Props): JSX.Element {
const roomId = callEvent.getRoomId()!;
const room = MatrixClientPeg.get().getRoom(roomId);
const call = useCall(roomId);
+2 -2
View File
@@ -28,7 +28,7 @@ import RoomAvatar from "../components/views/avatars/RoomAvatar";
import AccessibleTooltipButton from "../components/views/elements/AccessibleTooltipButton";
import AccessibleButton from "../components/views/elements/AccessibleButton";
export const getIncomingLegacyCallToastKey = (callId: string) => `call_${callId}`;
export const getIncomingLegacyCallToastKey = (callId: string): string => `call_${callId}`;
interface IProps {
call: MatrixCall;
@@ -83,7 +83,7 @@ export default class IncomingLegacyCallToast extends React.Component<IProps, ISt
: LegacyCallHandler.instance.silenceCall(callId);
};
public render() {
public render(): JSX.Element {
const call = this.props.call;
const room = MatrixClientPeg.get().getRoom(LegacyCallHandler.instance.roomIdForCall(call));
const isVoice = call.type === CallType.Voice;
+4 -4
View File
@@ -19,18 +19,18 @@ import GenericToast from "../components/views/toasts/GenericToast";
import ToastStore from "../stores/ToastStore";
import SdkConfig from "../SdkConfig";
const onAccept = () => {
const onAccept = (): void => {
window.location.href = "mobile_guide/";
};
const onReject = () => {
const onReject = (): void => {
document.cookie = "element_mobile_redirect_to_guide=false;path=/;max-age=14400";
hideToast();
};
const TOAST_KEY = "mobileguide";
export const showToast = () => {
export const showToast = (): void => {
const isIos = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
const isAndroid = /Android/.test(navigator.userAgent);
const brand = SdkConfig.get().brand;
@@ -59,6 +59,6 @@ export const showToast = () => {
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+7 -2
View File
@@ -23,7 +23,12 @@ import { messageForResourceLimitError } from "../utils/ErrorUtils";
const TOAST_KEY = "serverlimit";
export const showToast = (limitType: string, onHideToast: () => void, adminContact?: string, syncError?: boolean) => {
export const showToast = (
limitType: string,
onHideToast: () => void,
adminContact?: string,
syncError?: boolean,
): void => {
const errorText = messageForResourceLimitError(limitType, adminContact, {
"monthly_active_user": _td("Your homeserver has exceeded its user limit."),
"hs_blocked": _td("This homeserver has been blocked by its administrator."),
@@ -53,6 +58,6 @@ export const showToast = (limitType: string, onHideToast: () => void, adminConta
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+8 -8
View File
@@ -26,7 +26,7 @@ import Spinner from "../components/views/elements/Spinner";
const TOAST_KEY = "setupencryption";
const getTitle = (kind: Kind) => {
const getTitle = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
return _t("Set up Secure Backup");
@@ -37,7 +37,7 @@ const getTitle = (kind: Kind) => {
}
};
const getIcon = (kind: Kind) => {
const getIcon = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
case Kind.UPGRADE_ENCRYPTION:
@@ -47,7 +47,7 @@ const getIcon = (kind: Kind) => {
}
};
const getSetupCaption = (kind: Kind) => {
const getSetupCaption = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
return _t("Continue");
@@ -58,7 +58,7 @@ const getSetupCaption = (kind: Kind) => {
}
};
const getDescription = (kind: Kind) => {
const getDescription = (kind: Kind): string => {
switch (kind) {
case Kind.SET_UP_ENCRYPTION:
case Kind.UPGRADE_ENCRYPTION:
@@ -74,16 +74,16 @@ export enum Kind {
VERIFY_THIS_SESSION = "verify_this_session",
}
const onReject = () => {
const onReject = (): void => {
DeviceListener.sharedInstance().dismissEncryptionSetup();
};
export const showToast = (kind: Kind) => {
export const showToast = (kind: Kind): void => {
if (SecurityCustomisations.setupEncryptionNeeded?.(kind)) {
return;
}
const onAccept = async () => {
const onAccept = async (): Promise<void> => {
if (kind === Kind.VERIFY_THIS_SESSION) {
Modal.createDialog(SetupEncryptionDialog, {}, null, /* priority = */ false, /* static = */ true);
} else {
@@ -118,6 +118,6 @@ export const showToast = (kind: Kind) => {
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};
+5 -5
View File
@@ -22,21 +22,21 @@ import ToastStore from "../stores/ToastStore";
import GenericToast from "../components/views/toasts/GenericToast";
import { Action } from "../dispatcher/actions";
function toastKey(deviceId: string) {
function toastKey(deviceId: string): string {
return "unverified_session_" + deviceId;
}
export const showToast = async (deviceId: string) => {
export const showToast = async (deviceId: string): Promise<void> => {
const cli = MatrixClientPeg.get();
const onAccept = () => {
const onAccept = (): void => {
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
dis.dispatch({
action: Action.ViewUserDeviceSettings,
});
};
const onReject = () => {
const onReject = (): void => {
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
};
@@ -62,6 +62,6 @@ export const showToast = async (deviceId: string) => {
});
};
export const hideToast = (deviceId: string) => {
export const hideToast = (deviceId: string): void => {
ToastStore.sharedInstance().dismissToast(toastKey(deviceId));
};
+5 -5
View File
@@ -31,17 +31,17 @@ const TOAST_KEY = "update";
* Check a version string is compatible with the Changelog
* dialog ([element-version]-react-[react-sdk-version]-js-[js-sdk-version])
*/
function checkVersion(ver) {
function checkVersion(ver: string): boolean {
const parts = ver.split("-");
return parts.length === 5 && parts[1] === "react" && parts[3] === "js";
}
function installUpdate() {
function installUpdate(): void {
PlatformPeg.get().installUpdate();
}
export const showToast = (version: string, newVersion: string, releaseNotes?: string) => {
function onReject() {
export const showToast = (version: string, newVersion: string, releaseNotes?: string): void => {
function onReject(): void {
PlatformPeg.get().deferUpdate(newVersion);
}
@@ -93,6 +93,6 @@ export const showToast = (version: string, newVersion: string, releaseNotes?: st
});
};
export const hideToast = () => {
export const hideToast = (): void => {
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};