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
|
@ -23,27 +23,27 @@ import { EventEditor, EventViewer, eventTypeField, IEditorProps, stringify } fro
|
|||
import FilteredList from "./FilteredList";
|
||||
import { _t } from "../../../../languageHandler";
|
||||
|
||||
export const AccountDataEventEditor = ({ mxEvent, onBack }: IEditorProps) => {
|
||||
export const AccountDataEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const fields = useMemo(() => [eventTypeField(mxEvent?.getType())], [mxEvent]);
|
||||
|
||||
const onSend = ([eventType]: string[], content?: IContent) => {
|
||||
return cli.setAccountData(eventType, content);
|
||||
const onSend = async ([eventType]: string[], content?: IContent): Promise<void> => {
|
||||
await cli.setAccountData(eventType, content);
|
||||
};
|
||||
|
||||
const defaultContent = mxEvent ? stringify(mxEvent.getContent()) : undefined;
|
||||
return <EventEditor fieldDefs={fields} defaultContent={defaultContent} onSend={onSend} onBack={onBack} />;
|
||||
};
|
||||
|
||||
export const RoomAccountDataEventEditor = ({ mxEvent, onBack }: IEditorProps) => {
|
||||
export const RoomAccountDataEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const fields = useMemo(() => [eventTypeField(mxEvent?.getType())], [mxEvent]);
|
||||
|
||||
const onSend = ([eventType]: string[], content?: IContent) => {
|
||||
return cli.setRoomAccountData(context.room.roomId, eventType, content);
|
||||
const onSend = async ([eventType]: string[], content?: IContent): Promise<void> => {
|
||||
await cli.setRoomAccountData(context.room.roomId, eventType, content);
|
||||
};
|
||||
|
||||
const defaultContent = mxEvent ? stringify(mxEvent.getContent()) : undefined;
|
||||
|
@ -56,18 +56,18 @@ interface IProps extends IDevtoolsProps {
|
|||
actionLabel: string;
|
||||
}
|
||||
|
||||
const BaseAccountDataExplorer = ({ events, Editor, actionLabel, onBack, setTool }: IProps) => {
|
||||
const BaseAccountDataExplorer: React.FC<IProps> = ({ events, Editor, actionLabel, onBack, setTool }) => {
|
||||
const [query, setQuery] = useState("");
|
||||
const [event, setEvent] = useState<MatrixEvent>(null);
|
||||
|
||||
if (event) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setEvent(null);
|
||||
};
|
||||
return <EventViewer mxEvent={event} onBack={onBack} Editor={Editor} />;
|
||||
}
|
||||
|
||||
const onAction = async () => {
|
||||
const onAction = async (): Promise<void> => {
|
||||
setTool(actionLabel, Editor);
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,7 @@ const BaseAccountDataExplorer = ({ events, Editor, actionLabel, onBack, setTool
|
|||
<BaseTool onBack={onBack} actionLabel={actionLabel} onAction={onAction}>
|
||||
<FilteredList query={query} onChange={setQuery}>
|
||||
{Object.entries(events).map(([eventType, ev]) => {
|
||||
const onClick = () => {
|
||||
const onClick = (): void => {
|
||||
setEvent(ev);
|
||||
};
|
||||
|
||||
|
@ -90,7 +90,7 @@ const BaseAccountDataExplorer = ({ events, Editor, actionLabel, onBack, setTool
|
|||
);
|
||||
};
|
||||
|
||||
export const AccountDataExplorer = ({ onBack, setTool }: IDevtoolsProps) => {
|
||||
export const AccountDataExplorer: React.FC<IDevtoolsProps> = ({ onBack, setTool }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
return (
|
||||
|
@ -104,7 +104,7 @@ export const AccountDataExplorer = ({ onBack, setTool }: IDevtoolsProps) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const RoomAccountDataExplorer = ({ onBack, setTool }: IDevtoolsProps) => {
|
||||
export const RoomAccountDataExplorer: React.FC<IDevtoolsProps> = ({ onBack, setTool }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
|
||||
return (
|
||||
|
|
|
@ -39,7 +39,7 @@ interface IProps extends IMinProps {
|
|||
const BaseTool: React.FC<XOR<IMinProps, IProps>> = ({ className, actionLabel, onBack, onAction, children }) => {
|
||||
const [message, setMessage] = useState<string>(null);
|
||||
|
||||
const onBackClick = () => {
|
||||
const onBackClick = (): void => {
|
||||
if (message) {
|
||||
setMessage(null);
|
||||
} else {
|
||||
|
@ -51,7 +51,7 @@ const BaseTool: React.FC<XOR<IMinProps, IProps>> = ({ className, actionLabel, on
|
|||
if (message) {
|
||||
children = message;
|
||||
} else if (onAction) {
|
||||
const onActionClick = () => {
|
||||
const onActionClick = (): void => {
|
||||
onAction().then((msg) => {
|
||||
if (typeof msg === "string") {
|
||||
setMessage(msg);
|
||||
|
|
|
@ -72,7 +72,7 @@ const validateEventContent = withValidation<any, Error | undefined>({
|
|||
],
|
||||
});
|
||||
|
||||
export const EventEditor = ({ fieldDefs, defaultContent = "{\n\n}", onSend, onBack }: IEventEditorProps) => {
|
||||
export const EventEditor: React.FC<IEventEditorProps> = ({ fieldDefs, defaultContent = "{\n\n}", onSend, onBack }) => {
|
||||
const [fieldData, setFieldData] = useState<string[]>(fieldDefs.map((def) => def.default ?? ""));
|
||||
const [content, setContent] = useState<string>(defaultContent);
|
||||
const contentField = useRef<Field>();
|
||||
|
@ -96,7 +96,7 @@ export const EventEditor = ({ fieldDefs, defaultContent = "{\n\n}", onSend, onBa
|
|||
/>
|
||||
));
|
||||
|
||||
const onAction = async () => {
|
||||
const onAction = async (): Promise<string> => {
|
||||
const valid = await contentField.current.validate({});
|
||||
|
||||
if (!valid) {
|
||||
|
@ -143,17 +143,17 @@ interface IViewerProps extends Required<IEditorProps> {
|
|||
Editor: React.FC<Required<IEditorProps>>;
|
||||
}
|
||||
|
||||
export const EventViewer = ({ mxEvent, onBack, Editor }: IViewerProps) => {
|
||||
export const EventViewer: React.FC<IViewerProps> = ({ mxEvent, onBack, Editor }) => {
|
||||
const [editing, setEditing] = useState(false);
|
||||
|
||||
if (editing) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setEditing(false);
|
||||
};
|
||||
return <Editor mxEvent={mxEvent} onBack={onBack} />;
|
||||
}
|
||||
|
||||
const onAction = async () => {
|
||||
const onAction = async (): Promise<void> => {
|
||||
setEditing(true);
|
||||
};
|
||||
|
||||
|
@ -171,13 +171,13 @@ const getBaseEventId = (baseEvent: MatrixEvent): string => {
|
|||
return mxEvent.getWireContent()["m.relates_to"]?.event_id ?? baseEvent.getId();
|
||||
};
|
||||
|
||||
export const TimelineEventEditor = ({ mxEvent, onBack }: IEditorProps) => {
|
||||
export const TimelineEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const fields = useMemo(() => [eventTypeField(mxEvent?.getType())], [mxEvent]);
|
||||
|
||||
const onSend = ([eventType]: string[], content?: IContent) => {
|
||||
const onSend = ([eventType]: string[], content?: IContent): Promise<unknown> => {
|
||||
return cli.sendEvent(context.room.roomId, eventType, content);
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ interface IProps {
|
|||
onChange(value: string): void;
|
||||
}
|
||||
|
||||
const FilteredList = ({ children, query, onChange }: IProps) => {
|
||||
const FilteredList: React.FC<IProps> = ({ children, query, onChange }) => {
|
||||
const [truncateAt, setTruncateAt] = useState<number>(INITIAL_LOAD_TILES);
|
||||
const [filteredChildren, setFilteredChildren] = useState<React.ReactElement[]>(children);
|
||||
|
||||
|
@ -51,8 +51,8 @@ const FilteredList = ({ children, query, onChange }: IProps) => {
|
|||
return filteredChildren.length;
|
||||
};
|
||||
|
||||
const createOverflowElement = (overflowCount: number, totalCount: number) => {
|
||||
const showMore = () => {
|
||||
const createOverflowElement = (overflowCount: number, totalCount: number): JSX.Element => {
|
||||
const showMore = (): void => {
|
||||
setTruncateAt((num) => num + LOAD_TILES_STEP_SIZE);
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import MatrixClientContext from "../../../../contexts/MatrixClientContext";
|
|||
import { EventEditor, EventViewer, eventTypeField, stateKeyField, IEditorProps, stringify } from "./Event";
|
||||
import FilteredList from "./FilteredList";
|
||||
|
||||
export const StateEventEditor = ({ mxEvent, onBack }: IEditorProps) => {
|
||||
export const StateEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
|
@ -33,8 +33,8 @@ export const StateEventEditor = ({ mxEvent, onBack }: IEditorProps) => {
|
|||
[mxEvent],
|
||||
);
|
||||
|
||||
const onSend = ([eventType, stateKey]: string[], content?: IContent) => {
|
||||
return cli.sendStateEvent(context.room.roomId, eventType, content, stateKey);
|
||||
const onSend = async ([eventType, stateKey]: string[], content?: IContent): Promise<void> => {
|
||||
await cli.sendStateEvent(context.room.roomId, eventType, content, stateKey);
|
||||
};
|
||||
|
||||
const defaultContent = mxEvent ? stringify(mxEvent.getContent()) : undefined;
|
||||
|
@ -46,7 +46,7 @@ interface StateEventButtonProps {
|
|||
onClick(): void;
|
||||
}
|
||||
|
||||
const StateEventButton = ({ label, onClick }: StateEventButtonProps) => {
|
||||
const StateEventButton: React.FC<StateEventButtonProps> = ({ label, onClick }) => {
|
||||
const trimmed = label.trim();
|
||||
|
||||
return (
|
||||
|
@ -66,7 +66,7 @@ interface IEventTypeProps extends Pick<IDevtoolsProps, "onBack"> {
|
|||
eventType: string;
|
||||
}
|
||||
|
||||
const RoomStateExplorerEventType = ({ eventType, onBack }: IEventTypeProps) => {
|
||||
const RoomStateExplorerEventType: React.FC<IEventTypeProps> = ({ eventType, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const [query, setQuery] = useState("");
|
||||
const [event, setEvent] = useState<MatrixEvent | null>(null);
|
||||
|
@ -82,7 +82,7 @@ const RoomStateExplorerEventType = ({ eventType, onBack }: IEventTypeProps) => {
|
|||
}, [events]);
|
||||
|
||||
if (event) {
|
||||
const _onBack = () => {
|
||||
const _onBack = (): void => {
|
||||
if (events?.size === 1 && events.has("")) {
|
||||
onBack();
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ const RoomStateExplorerEventType = ({ eventType, onBack }: IEventTypeProps) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const RoomStateExplorer = ({ onBack, setTool }: IDevtoolsProps) => {
|
||||
export const RoomStateExplorer: React.FC<IDevtoolsProps> = ({ onBack, setTool }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const [query, setQuery] = useState("");
|
||||
const [eventType, setEventType] = useState<string | null>(null);
|
||||
|
@ -111,13 +111,13 @@ export const RoomStateExplorer = ({ onBack, setTool }: IDevtoolsProps) => {
|
|||
const events = context.room.currentState.events;
|
||||
|
||||
if (eventType !== null) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setEventType(null);
|
||||
};
|
||||
return <RoomStateExplorerEventType eventType={eventType} onBack={onBack} />;
|
||||
}
|
||||
|
||||
const onAction = async () => {
|
||||
const onAction = async (): Promise<void> => {
|
||||
setTool(_t("Send custom state event"), StateEventEditor);
|
||||
};
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ interface IServerWellKnown {
|
|||
};
|
||||
}
|
||||
|
||||
const ServerInfo = ({ onBack }: IDevtoolsProps) => {
|
||||
const ServerInfo: React.FC<IDevtoolsProps> = ({ onBack }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const capabilities = useAsyncMemo(() => cli.getCapabilities(true).catch(() => FAILED_TO_LOAD), [cli]);
|
||||
const clientVersions = useAsyncMemo(() => cli.getVersions().catch(() => FAILED_TO_LOAD), [cli]);
|
||||
const serverVersions = useAsyncMemo<IServerWellKnown | symbol>(async () => {
|
||||
const serverVersions = useAsyncMemo(async (): Promise<IServerWellKnown | symbol> => {
|
||||
let baseUrl = cli.getHomeserverUrl();
|
||||
|
||||
try {
|
||||
|
|
|
@ -20,7 +20,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event";
|
|||
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
|
||||
import { _t } from "../../../../languageHandler";
|
||||
|
||||
const ServersInRoom = ({ onBack }: IDevtoolsProps) => {
|
||||
const ServersInRoom: React.FC<IDevtoolsProps> = ({ onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
|
||||
const servers = useMemo<Record<string, number>>(() => {
|
||||
|
|
|
@ -26,28 +26,28 @@ import { SettingLevel } from "../../../../settings/SettingLevel";
|
|||
import { SETTINGS } from "../../../../settings/Settings";
|
||||
import Field from "../../elements/Field";
|
||||
|
||||
const SettingExplorer = ({ onBack }: IDevtoolsProps) => {
|
||||
const SettingExplorer: React.FC<IDevtoolsProps> = ({ onBack }) => {
|
||||
const [setting, setSetting] = useState<string>(null);
|
||||
const [editing, setEditing] = useState(false);
|
||||
|
||||
if (setting && editing) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setEditing(false);
|
||||
};
|
||||
return <EditSetting setting={setting} onBack={onBack} />;
|
||||
} else if (setting) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setSetting(null);
|
||||
};
|
||||
const onEdit = async () => {
|
||||
const onEdit = async (): Promise<void> => {
|
||||
setEditing(true);
|
||||
};
|
||||
return <ViewSetting setting={setting} onBack={onBack} onEdit={onEdit} />;
|
||||
} else {
|
||||
const onView = (setting: string) => {
|
||||
const onView = (setting: string): void => {
|
||||
setSetting(setting);
|
||||
};
|
||||
const onEdit = (setting: string) => {
|
||||
const onEdit = (setting: string): void => {
|
||||
setSetting(setting);
|
||||
setEditing(true);
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ interface ICanEditLevelFieldProps {
|
|||
roomId?: string;
|
||||
}
|
||||
|
||||
const CanEditLevelField = ({ setting, roomId, level }: ICanEditLevelFieldProps) => {
|
||||
const CanEditLevelField: React.FC<ICanEditLevelFieldProps> = ({ setting, roomId, level }) => {
|
||||
const canEdit = SettingsStore.canSetValue(setting, roomId, level);
|
||||
const className = canEdit ? "mx_DevTools_SettingsExplorer_mutable" : "mx_DevTools_SettingsExplorer_immutable";
|
||||
return (
|
||||
|
@ -92,14 +92,14 @@ interface IEditSettingProps extends Pick<IDevtoolsProps, "onBack"> {
|
|||
setting: string;
|
||||
}
|
||||
|
||||
const EditSetting = ({ setting, onBack }: IEditSettingProps) => {
|
||||
const EditSetting: React.FC<IEditSettingProps> = ({ setting, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const [explicitValue, setExplicitValue] = useState(renderExplicitSettingValues(setting, null));
|
||||
const [explicitRoomValue, setExplicitRoomValue] = useState(
|
||||
renderExplicitSettingValues(setting, context.room.roomId),
|
||||
);
|
||||
|
||||
const onSave = async () => {
|
||||
const onSave = async (): Promise<string> => {
|
||||
try {
|
||||
const parsedExplicit = JSON.parse(explicitValue);
|
||||
const parsedExplicitRoom = JSON.parse(explicitRoomValue);
|
||||
|
@ -203,7 +203,7 @@ interface IViewSettingProps extends Pick<IDevtoolsProps, "onBack"> {
|
|||
onEdit(): Promise<void>;
|
||||
}
|
||||
|
||||
const ViewSetting = ({ setting, onEdit, onBack }: IViewSettingProps) => {
|
||||
const ViewSetting: React.FC<IViewSettingProps> = ({ setting, onEdit, onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
|
||||
return (
|
||||
|
@ -261,7 +261,7 @@ interface ISettingsListProps extends Pick<IDevtoolsProps, "onBack"> {
|
|||
onEdit(setting: string): void;
|
||||
}
|
||||
|
||||
const SettingsList = ({ onBack, onView, onEdit }: ISettingsListProps) => {
|
||||
const SettingsList: React.FC<ISettingsListProps> = ({ onBack, onView, onEdit }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
|||
import { useTypedEventEmitter, useTypedEventEmitterState } from "../../../../hooks/useEventEmitter";
|
||||
import { _t, _td } from "../../../../languageHandler";
|
||||
import MatrixClientContext from "../../../../contexts/MatrixClientContext";
|
||||
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
|
||||
import BaseTool, { DevtoolsContext } from "./BaseTool";
|
||||
import { Tool } from "../DevtoolsDialog";
|
||||
|
||||
const PHASE_MAP: Record<Phase, string> = {
|
||||
[Phase.Unsent]: _td("Unsent"),
|
||||
|
@ -80,7 +81,7 @@ const VerificationRequestExplorer: React.FC<{
|
|||
);
|
||||
};
|
||||
|
||||
const VerificationExplorer = ({ onBack }: IDevtoolsProps) => {
|
||||
const VerificationExplorer: Tool = ({ onBack }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const context = useContext(DevtoolsContext);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { UPDATE_EVENT } from "../../../../stores/AsyncStore";
|
|||
import FilteredList from "./FilteredList";
|
||||
import { StateEventEditor } from "./RoomState";
|
||||
|
||||
const WidgetExplorer = ({ onBack }: IDevtoolsProps) => {
|
||||
const WidgetExplorer: React.FC<IDevtoolsProps> = ({ onBack }) => {
|
||||
const context = useContext(DevtoolsContext);
|
||||
const [query, setQuery] = useState("");
|
||||
const [widget, setWidget] = useState<IApp>(null);
|
||||
|
@ -35,7 +35,7 @@ const WidgetExplorer = ({ onBack }: IDevtoolsProps) => {
|
|||
});
|
||||
|
||||
if (widget && widgets.includes(widget)) {
|
||||
const onBack = () => {
|
||||
const onBack = (): void => {
|
||||
setWidget(null);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue