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:
parent
7a36ba0fde
commit
030b7e90bf
683 changed files with 3459 additions and 3013 deletions
|
@ -53,7 +53,7 @@ const DeviceContextMenuSection: React.FC<IDeviceContextMenuSectionProps> = ({ de
|
|||
const [selectedDevice, setSelectedDevice] = useState(MediaDeviceHandler.getDevice(deviceKind));
|
||||
|
||||
useEffect(() => {
|
||||
const getDevices = async () => {
|
||||
const getDevices = async (): Promise<void> => {
|
||||
return setDevices((await MediaDeviceHandler.getDevices())[deviceKind]);
|
||||
};
|
||||
getDevices();
|
||||
|
|
|
@ -42,7 +42,7 @@ export default class DialpadContextMenu extends React.Component<IProps, IState>
|
|||
};
|
||||
}
|
||||
|
||||
public onDigitPress = (digit: string, ev: ButtonEvent) => {
|
||||
public onDigitPress = (digit: string, ev: ButtonEvent): void => {
|
||||
this.props.call.sendDtmfDigit(digit);
|
||||
this.setState({ value: this.state.value + digit });
|
||||
|
||||
|
@ -54,22 +54,22 @@ export default class DialpadContextMenu extends React.Component<IProps, IState>
|
|||
}
|
||||
};
|
||||
|
||||
public onCancelClick = () => {
|
||||
public onCancelClick = (): void => {
|
||||
this.props.onFinished();
|
||||
};
|
||||
|
||||
public onKeyDown = (ev) => {
|
||||
public onKeyDown = (ev): void => {
|
||||
// Prevent Backspace and Delete keys from functioning in the entry field
|
||||
if (ev.code === "Backspace" || ev.code === "Delete") {
|
||||
ev.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
public onChange = (ev) => {
|
||||
public onChange = (ev): void => {
|
||||
this.setState({ value: ev.target.value });
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<ContextMenu {...this.props}>
|
||||
<div className="mx_DialPadContextMenuWrapper">
|
||||
|
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
|||
import React from "react";
|
||||
|
||||
import { Icon as ContextMenuIcon } from "../../../../res/img/element-icons/context-menu.svg";
|
||||
import { ChevronFace, ContextMenuButton, useContextMenu } from "../../structures/ContextMenu";
|
||||
import { ChevronFace, ContextMenuButton, MenuProps, useContextMenu } from "../../structures/ContextMenu";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import IconizedContextMenu, { IconizedContextMenuOptionList } from "./IconizedContextMenu";
|
||||
|
||||
const contextMenuBelow = (elementRect: DOMRect) => {
|
||||
const contextMenuBelow = (elementRect: DOMRect): MenuProps => {
|
||||
// align the context menu's icons with the icon which opened the context menu
|
||||
const left = elementRect.left + window.scrollX + elementRect.width;
|
||||
const top = elementRect.bottom + window.scrollY;
|
||||
|
|
|
@ -30,23 +30,23 @@ export default class LegacyCallContextMenu extends React.Component<IProps> {
|
|||
super(props);
|
||||
}
|
||||
|
||||
public onHoldClick = () => {
|
||||
public onHoldClick = (): void => {
|
||||
this.props.call.setRemoteOnHold(true);
|
||||
this.props.onFinished();
|
||||
};
|
||||
|
||||
public onUnholdClick = () => {
|
||||
public onUnholdClick = (): void => {
|
||||
LegacyCallHandler.instance.setActiveCallRoomId(this.props.call.roomId);
|
||||
|
||||
this.props.onFinished();
|
||||
};
|
||||
|
||||
public onTransferClick = () => {
|
||||
public onTransferClick = (): void => {
|
||||
LegacyCallHandler.instance.showTransferDialog(this.props.call);
|
||||
this.props.onFinished();
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const holdUnholdCaption = this.props.call.isRemoteOnHold() ? _t("Resume") : _t("Hold");
|
||||
const handler = this.props.call.isRemoteOnHold() ? this.onUnholdClick : this.onHoldClick;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import { Action } from "../../../dispatcher/actions";
|
|||
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
|
||||
import { ButtonEvent } from "../elements/AccessibleButton";
|
||||
import { copyPlaintext, getSelectedText } from "../../../utils/strings";
|
||||
import ContextMenu, { toRightOf, IPosition, ChevronFace } from "../../structures/ContextMenu";
|
||||
import ContextMenu, { toRightOf, MenuProps } from "../../structures/ContextMenu";
|
||||
import ReactionPicker from "../emojipicker/ReactionPicker";
|
||||
import ViewSource from "../../structures/ViewSource";
|
||||
import { createRedactEventDialog } from "../dialogs/ConfirmRedactDialog";
|
||||
|
@ -63,7 +63,7 @@ interface IReplyInThreadButton {
|
|||
closeMenu: () => void;
|
||||
}
|
||||
|
||||
const ReplyInThreadButton = ({ mxEvent, closeMenu }: IReplyInThreadButton) => {
|
||||
const ReplyInThreadButton: React.FC<IReplyInThreadButton> = ({ mxEvent, closeMenu }) => {
|
||||
const context = useContext(CardContext);
|
||||
const relationType = mxEvent?.getRelation()?.rel_type;
|
||||
|
||||
|
@ -104,8 +104,7 @@ const ReplyInThreadButton = ({ mxEvent, closeMenu }: IReplyInThreadButton) => {
|
|||
);
|
||||
};
|
||||
|
||||
interface IProps extends IPosition {
|
||||
chevronFace: ChevronFace;
|
||||
interface IProps extends MenuProps {
|
||||
/* the MatrixEvent associated with the context menu */
|
||||
mxEvent: MatrixEvent;
|
||||
// An optional EventTileOps implementation that can be used to unhide preview widgets
|
||||
|
@ -150,7 +149,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
MatrixClientPeg.get().on(RoomMemberEvent.PowerLevel, this.checkPermissions);
|
||||
this.checkPermissions();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ interface IProps extends IContextMenuProps {
|
|||
room: Room;
|
||||
}
|
||||
|
||||
const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||
const RoomContextMenu: React.FC<IProps> = ({ room, onFinished, ...props }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const roomTags = useEventEmitterState(RoomListStore.instance, LISTS_UPDATE_EVENT, () =>
|
||||
RoomListStore.instance.getTagsForRoom(room),
|
||||
|
@ -63,7 +63,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
|
||||
let leaveOption: JSX.Element;
|
||||
if (roomTags.includes(DefaultTagID.Archived)) {
|
||||
const onForgetRoomClick = (ev: ButtonEvent) => {
|
||||
const onForgetRoomClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -83,7 +83,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
/>
|
||||
);
|
||||
} else {
|
||||
const onLeaveRoomClick = (ev: ButtonEvent) => {
|
||||
const onLeaveRoomClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -114,7 +114,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
|
||||
let inviteOption: JSX.Element;
|
||||
if (room.canInvite(cli.getUserId()!) && !isDm) {
|
||||
const onInviteClick = (ev: ButtonEvent) => {
|
||||
const onInviteClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -323,7 +323,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
);
|
||||
}
|
||||
|
||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
|
||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -346,7 +346,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
}
|
||||
};
|
||||
|
||||
const ensureViewingRoom = (ev: ButtonEvent) => {
|
||||
const ensureViewingRoom = (ev: ButtonEvent): void => {
|
||||
if (SdkContextClass.instance.roomViewStore.getRoomId() === room.roomId) return;
|
||||
dis.dispatch<ViewRoomPayload>(
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ export interface RoomGeneralContextMenuProps extends IContextMenuProps {
|
|||
onPostLeaveClick?: (event: ButtonEvent) => void;
|
||||
}
|
||||
|
||||
export const RoomGeneralContextMenu = ({
|
||||
export const RoomGeneralContextMenu: React.FC<RoomGeneralContextMenuProps> = ({
|
||||
room,
|
||||
onFinished,
|
||||
onPostFavoriteClick,
|
||||
|
@ -61,7 +61,7 @@ export const RoomGeneralContextMenu = ({
|
|||
onPostLeaveClick,
|
||||
onPostForgetClick,
|
||||
...props
|
||||
}: RoomGeneralContextMenuProps) => {
|
||||
}) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const roomTags = useEventEmitterState(RoomListStore.instance, LISTS_UPDATE_EVENT, () =>
|
||||
RoomListStore.instance.getTagsForRoom(room),
|
||||
|
@ -86,7 +86,7 @@ export const RoomGeneralContextMenu = ({
|
|||
};
|
||||
};
|
||||
|
||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
|
||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID): void => {
|
||||
if (tagId === DefaultTagID.Favourite || tagId === DefaultTagID.LowPriority) {
|
||||
const inverseTag = tagId === DefaultTagID.Favourite ? DefaultTagID.LowPriority : DefaultTagID.Favourite;
|
||||
const isApplied = RoomListStore.instance.getTagsForRoom(room).includes(tagId);
|
||||
|
|
|
@ -33,7 +33,7 @@ interface IProps extends IContextMenuProps {
|
|||
room: Room;
|
||||
}
|
||||
|
||||
export const RoomNotificationContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||
export const RoomNotificationContextMenu: React.FC<IProps> = ({ room, onFinished, ...props }) => {
|
||||
const [notificationState, setNotificationState] = useNotificationState(room);
|
||||
|
||||
const wrapHandler = (handler: (ev: ButtonEvent) => void, persistent = false): ((ev: ButtonEvent) => void) => {
|
||||
|
|
|
@ -47,13 +47,13 @@ interface IProps extends IContextMenuProps {
|
|||
hideHeader?: boolean;
|
||||
}
|
||||
|
||||
const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) => {
|
||||
const SpaceContextMenu: React.FC<IProps> = ({ space, hideHeader, onFinished, ...props }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const userId = cli.getUserId()!;
|
||||
|
||||
let inviteOption: JSX.Element | null = null;
|
||||
if (space.getJoinRule() === "public" || space.canInvite(userId)) {
|
||||
const onInviteClick = (ev: ButtonEvent) => {
|
||||
const onInviteClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -75,7 +75,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
let settingsOption: JSX.Element | null = null;
|
||||
let leaveOption: JSX.Element | null = null;
|
||||
if (shouldShowSpaceSettings(space)) {
|
||||
const onSettingsClick = (ev: ButtonEvent) => {
|
||||
const onSettingsClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -92,7 +92,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
/>
|
||||
);
|
||||
} else {
|
||||
const onLeaveClick = (ev: ButtonEvent) => {
|
||||
const onLeaveClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -113,7 +113,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
|
||||
let devtoolsOption: JSX.Element | null = null;
|
||||
if (SettingsStore.getValue("developerMode")) {
|
||||
const onViewTimelineClick = (ev: ButtonEvent) => {
|
||||
const onViewTimelineClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -145,7 +145,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
|
||||
let newRoomSection: JSX.Element | null = null;
|
||||
if (canAddRooms || canAddSubSpaces) {
|
||||
const onNewRoomClick = (ev: ButtonEvent) => {
|
||||
const onNewRoomClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -154,7 +154,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
onFinished();
|
||||
};
|
||||
|
||||
const onNewVideoRoomClick = (ev: ButtonEvent) => {
|
||||
const onNewVideoRoomClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -162,7 +162,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
onFinished();
|
||||
};
|
||||
|
||||
const onNewSubspaceClick = (ev: ButtonEvent) => {
|
||||
const onNewSubspaceClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -207,7 +207,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
);
|
||||
}
|
||||
|
||||
const onPreferencesClick = (ev: ButtonEvent) => {
|
||||
const onPreferencesClick = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -215,7 +215,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
onFinished();
|
||||
};
|
||||
|
||||
const openSpace = (ev: ButtonEvent) => {
|
||||
const openSpace = (ev: ButtonEvent): void => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -227,12 +227,12 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
onFinished();
|
||||
};
|
||||
|
||||
const onExploreRoomsClick = (ev: ButtonEvent) => {
|
||||
const onExploreRoomsClick = (ev: ButtonEvent): void => {
|
||||
PosthogTrackers.trackInteraction("WebSpaceContextMenuExploreRoomsItem", ev);
|
||||
openSpace(ev);
|
||||
};
|
||||
|
||||
const onHomeClick = (ev: ButtonEvent) => {
|
||||
const onHomeClick = (ev: ButtonEvent): void => {
|
||||
PosthogTrackers.trackInteraction("WebSpaceContextMenuHomeItem", ev);
|
||||
openSpace(ev);
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ import dis from "../../../dispatcher/dispatcher";
|
|||
import { Action } from "../../../dispatcher/actions";
|
||||
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
|
||||
import { copyPlaintext } from "../../../utils/strings";
|
||||
import { ChevronFace, ContextMenuTooltipButton, useContextMenu } from "../../structures/ContextMenu";
|
||||
import { ChevronFace, ContextMenuTooltipButton, MenuProps, useContextMenu } from "../../structures/ContextMenu";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import IconizedContextMenu, { IconizedContextMenuOption, IconizedContextMenuOptionList } from "./IconizedContextMenu";
|
||||
import { WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
|
||||
|
@ -35,7 +35,7 @@ export interface ThreadListContextMenuProps {
|
|||
onMenuToggle?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
const contextMenuBelow = (elementRect: DOMRect) => {
|
||||
const contextMenuBelow = (elementRect: DOMRect): MenuProps => {
|
||||
// align the context menu's icons with the icon which opened the context menu
|
||||
const left = elementRect.left + window.scrollX + elementRect.width;
|
||||
const top = elementRect.bottom + window.scrollY;
|
||||
|
@ -68,7 +68,7 @@ const ThreadListContextMenu: React.FC<ThreadListContextMenuProps> = ({
|
|||
);
|
||||
|
||||
const copyLinkToThread = useCallback(
|
||||
async (evt: ButtonEvent | undefined) => {
|
||||
async (evt: ButtonEvent | undefined): Promise<void> => {
|
||||
if (permalinkCreator) {
|
||||
evt?.preventDefault();
|
||||
evt?.stopPropagation();
|
||||
|
|
|
@ -62,7 +62,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
|
||||
let streamAudioStreamButton;
|
||||
if (getConfigLivestreamUrl() && WidgetType.JITSI.matches(app.type)) {
|
||||
const onStreamAudioClick = async () => {
|
||||
const onStreamAudioClick = async (): Promise<void> => {
|
||||
try {
|
||||
await startJitsiAudioLivestream(widgetMessaging, roomId);
|
||||
} catch (err) {
|
||||
|
@ -86,7 +86,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
|
||||
let editButton;
|
||||
if (canModify && WidgetUtils.isManagedByManager(app)) {
|
||||
const _onEditClick = () => {
|
||||
const _onEditClick = (): void => {
|
||||
if (onEditClick) {
|
||||
onEditClick();
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
let snapshotButton;
|
||||
const screenshotsEnabled = SettingsStore.getValue("enableWidgetScreenshots");
|
||||
if (screenshotsEnabled && widgetMessaging?.hasCapability(MatrixCapabilities.Screenshots)) {
|
||||
const onSnapshotClick = () => {
|
||||
const onSnapshotClick = (): void => {
|
||||
widgetMessaging
|
||||
?.takeScreenshot()
|
||||
.then((data) => {
|
||||
|
@ -121,7 +121,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
|
||||
let deleteButton;
|
||||
if (onDeleteClick || canModify) {
|
||||
const _onDeleteClick = () => {
|
||||
const _onDeleteClick = (): void => {
|
||||
if (onDeleteClick) {
|
||||
onDeleteClick();
|
||||
} else {
|
||||
|
@ -158,7 +158,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
const isLocalWidget = WidgetType.JITSI.matches(app.type);
|
||||
let revokeButton;
|
||||
if (!userWidget && !isLocalWidget && isAllowedWidget) {
|
||||
const onRevokeClick = () => {
|
||||
const onRevokeClick = (): void => {
|
||||
logger.info("Revoking permission for widget to load: " + app.eventId);
|
||||
const current = SettingsStore.getValue("allowedWidgets", roomId);
|
||||
if (app.eventId !== undefined) current[app.eventId] = false;
|
||||
|
@ -175,7 +175,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
|
||||
let moveLeftButton;
|
||||
if (showUnpin && widgetIndex > 0) {
|
||||
const onClick = () => {
|
||||
const onClick = (): void => {
|
||||
WidgetLayoutStore.instance.moveWithinContainer(room, Container.Top, app, -1);
|
||||
onFinished();
|
||||
};
|
||||
|
@ -185,7 +185,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
|||
|
||||
let moveRightButton;
|
||||
if (showUnpin && widgetIndex < pinnedWidgets.length - 1) {
|
||||
const onClick = () => {
|
||||
const onClick = (): void => {
|
||||
WidgetLayoutStore.instance.moveWithinContainer(room, Container.Top, app, 1);
|
||||
onFinished();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue