Upgrade eslint-plugin-matrix-org to 1.2.1
This upgrade came with a number of new lints that needed to be fixed across the code base. Primarily: explicit return types on functions, and explicit visibility modifiers on class members.
This commit is contained in:
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { useCallback } from "react";
|
||||
import { FC, useCallback } from "react";
|
||||
import { randomString } from "matrix-js-sdk/src/randomstring";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -29,7 +29,7 @@ interface Props {
|
||||
roomId?: string;
|
||||
}
|
||||
|
||||
export function FeedbackSettingsTab({ roomId }: Props) {
|
||||
export const FeedbackSettingsTab: FC<Props> = ({ roomId }) => {
|
||||
const { t } = useTranslation();
|
||||
const { submitRageshake, sending, sent, error } = useSubmitRageshake();
|
||||
const sendRageshakeRequest = useRageshakeRequest();
|
||||
@@ -104,4 +104,4 @@ export function FeedbackSettingsTab({ roomId }: Props) {
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||
import { FC, useCallback, useEffect, useMemo, useRef } from "react";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -26,7 +26,7 @@ import styles from "./ProfileSettingsTab.module.css";
|
||||
interface Props {
|
||||
client: MatrixClient;
|
||||
}
|
||||
export function ProfileSettingsTab({ client }: Props) {
|
||||
export const ProfileSettingsTab: FC<Props> = ({ client }) => {
|
||||
const { t } = useTranslation();
|
||||
const { error, displayName, avatarUrl, saveProfile } = useProfile(client);
|
||||
const userId = useMemo(() => client.getUserId(), [client]);
|
||||
@@ -120,4 +120,4 @@ export function ProfileSettingsTab({ client }: Props) {
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useCallback } from "react";
|
||||
import { FC, useCallback } from "react";
|
||||
|
||||
import { Button } from "../button";
|
||||
import { Config } from "../config/Config";
|
||||
@@ -26,7 +26,7 @@ interface Props {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const RageshakeButton = ({ description }: Props) => {
|
||||
export const RageshakeButton: FC<Props> = ({ description }) => {
|
||||
const { submitRageshake, sending, sent, error } = useSubmitRageshake();
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { ChangeEvent, Key, useCallback, useState } from "react";
|
||||
import { ChangeEvent, FC, Key, ReactNode, useCallback, useState } from "react";
|
||||
import { Item } from "@react-stately/collections";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { MatrixClient } from "matrix-js-sdk";
|
||||
@@ -59,7 +59,7 @@ interface Props {
|
||||
defaultTab?: string;
|
||||
}
|
||||
|
||||
export const SettingsModal = (props: Props) => {
|
||||
export const SettingsModal: FC<Props> = (props) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [showInspector, setShowInspector] = useShowInspector();
|
||||
@@ -73,7 +73,10 @@ export const SettingsModal = (props: Props) => {
|
||||
const downloadDebugLog = useDownloadDebugLog();
|
||||
|
||||
// Generate a `SelectInput` with a list of devices for a given device kind.
|
||||
const generateDeviceSelection = (devices: MediaDevice, caption: string) => {
|
||||
const generateDeviceSelection = (
|
||||
devices: MediaDevice,
|
||||
caption: string
|
||||
): ReactNode => {
|
||||
if (devices.available.length == 0) return null;
|
||||
|
||||
return (
|
||||
@@ -84,7 +87,7 @@ export const SettingsModal = (props: Props) => {
|
||||
? "default"
|
||||
: devices.selectedId
|
||||
}
|
||||
onSelectionChange={(id) => devices.select(id.toString())}
|
||||
onSelectionChange={(id): void => devices.select(id.toString())}
|
||||
>
|
||||
{devices.available.map(({ deviceId, label }, index) => (
|
||||
<Item key={deviceId}>
|
||||
@@ -197,7 +200,7 @@ export const SettingsModal = (props: Props) => {
|
||||
checked={developerSettingsTab}
|
||||
label={t("Developer Settings")}
|
||||
description={t("Expose developer settings in the settings window.")}
|
||||
onChange={(event: ChangeEvent<HTMLInputElement>) =>
|
||||
onChange={(event: ChangeEvent<HTMLInputElement>): void =>
|
||||
setDeveloperSettingsTab(event.target.checked)
|
||||
}
|
||||
/>
|
||||
@@ -209,7 +212,7 @@ export const SettingsModal = (props: Props) => {
|
||||
type="checkbox"
|
||||
checked={optInAnalytics ?? undefined}
|
||||
description={optInDescription}
|
||||
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
||||
onChange={(event: ChangeEvent<HTMLInputElement>): void => {
|
||||
setOptInAnalytics?.(event.target.checked);
|
||||
}}
|
||||
/>
|
||||
@@ -241,7 +244,7 @@ export const SettingsModal = (props: Props) => {
|
||||
label={t("Show call inspector")}
|
||||
type="checkbox"
|
||||
checked={showInspector}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>): void =>
|
||||
setShowInspector(e.target.checked)
|
||||
}
|
||||
/>
|
||||
@@ -253,7 +256,7 @@ export const SettingsModal = (props: Props) => {
|
||||
label={t("Show connection stats")}
|
||||
type="checkbox"
|
||||
checked={showConnectionStats}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>): void =>
|
||||
setShowConnectionStats(e.target.checked)
|
||||
}
|
||||
/>
|
||||
@@ -270,7 +273,7 @@ export const SettingsModal = (props: Props) => {
|
||||
disabled={!setEnableE2EE}
|
||||
type="checkbox"
|
||||
checked={enableE2EE ?? undefined}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>): void =>
|
||||
setEnableE2EE?.(e.target.checked)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -89,7 +89,7 @@ class ConsoleLogger extends EventEmitter {
|
||||
this.originalFunctions[name] = originalFn;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
consoleObj[name] = (...args) => {
|
||||
consoleObj[name] = (...args): void => {
|
||||
this.log(level, ...args);
|
||||
originalFn(...args);
|
||||
};
|
||||
@@ -158,7 +158,7 @@ class IndexedDBLogStore {
|
||||
private flushAgainPromise?: Promise<void>;
|
||||
private id: string;
|
||||
|
||||
constructor(
|
||||
public constructor(
|
||||
private indexedDB: IDBFactory,
|
||||
private loggerInstance: ConsoleLogger
|
||||
) {
|
||||
@@ -174,20 +174,20 @@ class IndexedDBLogStore {
|
||||
public connect(): Promise<void> {
|
||||
const req = this.indexedDB.open("logs");
|
||||
return new Promise((resolve, reject) => {
|
||||
req.onsuccess = () => {
|
||||
req.onsuccess = (): void => {
|
||||
this.db = req.result;
|
||||
|
||||
resolve();
|
||||
};
|
||||
|
||||
req.onerror = () => {
|
||||
req.onerror = (): void => {
|
||||
const err = "Failed to open log database: " + req?.error?.name;
|
||||
logger.error(err);
|
||||
reject(new Error(err));
|
||||
};
|
||||
|
||||
// First time: Setup the object store
|
||||
req.onupgradeneeded = () => {
|
||||
req.onupgradeneeded = (): void => {
|
||||
const db = req.result;
|
||||
// This is the log entries themselves. Each entry is a chunk of
|
||||
// logs (ie multiple lines). 'id' is the instance ID (so logs with
|
||||
@@ -218,7 +218,7 @@ class IndexedDBLogStore {
|
||||
});
|
||||
}
|
||||
|
||||
private onLoggerLog = () => {
|
||||
private onLoggerLog = (): void => {
|
||||
if (!this.db) return;
|
||||
|
||||
this.throttledFlush();
|
||||
@@ -289,10 +289,10 @@ class IndexedDBLogStore {
|
||||
}
|
||||
const txn = this.db.transaction(["logs", "logslastmod"], "readwrite");
|
||||
const objStore = txn.objectStore("logs");
|
||||
txn.oncomplete = () => {
|
||||
txn.oncomplete = (): void => {
|
||||
resolve();
|
||||
};
|
||||
txn.onerror = (event) => {
|
||||
txn.onerror = (event): void => {
|
||||
logger.error("Failed to flush logs : ", event);
|
||||
reject(new Error("Failed to write logs: " + txn?.error?.message));
|
||||
};
|
||||
@@ -333,10 +333,10 @@ class IndexedDBLogStore {
|
||||
.index("id")
|
||||
.openCursor(IDBKeyRange.only(id), "prev");
|
||||
let lines = "";
|
||||
query.onerror = () => {
|
||||
query.onerror = (): void => {
|
||||
reject(new Error("Query failed: " + query?.error?.message));
|
||||
};
|
||||
query.onsuccess = () => {
|
||||
query.onsuccess = (): void => {
|
||||
const cursor = query.result;
|
||||
if (!cursor) {
|
||||
resolve(lines);
|
||||
@@ -379,7 +379,7 @@ class IndexedDBLogStore {
|
||||
const o = txn.objectStore("logs");
|
||||
// only load the key path, not the data which may be huge
|
||||
const query = o.index("id").openKeyCursor(IDBKeyRange.only(id));
|
||||
query.onsuccess = () => {
|
||||
query.onsuccess = (): void => {
|
||||
const cursor = query.result;
|
||||
if (!cursor) {
|
||||
return;
|
||||
@@ -387,10 +387,10 @@ class IndexedDBLogStore {
|
||||
o.delete(cursor.primaryKey);
|
||||
cursor.continue();
|
||||
};
|
||||
txn.oncomplete = () => {
|
||||
txn.oncomplete = (): void => {
|
||||
resolve();
|
||||
};
|
||||
txn.onerror = () => {
|
||||
txn.onerror = (): void => {
|
||||
reject(
|
||||
new Error(
|
||||
"Failed to delete logs for " + `'${id}' : ${txn?.error?.message}`
|
||||
@@ -477,11 +477,11 @@ function selectQuery<T>(
|
||||
const query = store.openCursor(keyRange);
|
||||
return new Promise((resolve, reject) => {
|
||||
const results: T[] = [];
|
||||
query.onerror = () => {
|
||||
query.onerror = (): void => {
|
||||
reject(new Error("Query failed: " + query?.error?.message));
|
||||
};
|
||||
// collect results
|
||||
query.onsuccess = () => {
|
||||
query.onsuccess = (): void => {
|
||||
const cursor = query.result;
|
||||
if (!cursor) {
|
||||
resolve(results);
|
||||
|
||||
@@ -360,7 +360,7 @@ export function useRageshakeRequestModal(
|
||||
useEffect(() => {
|
||||
if (!client) return;
|
||||
|
||||
const onEvent = (event: MatrixEvent) => {
|
||||
const onEvent = (event: MatrixEvent): void => {
|
||||
const type = event.getType();
|
||||
|
||||
if (
|
||||
|
||||
@@ -55,15 +55,15 @@ export const getSetting = <T>(name: string, defaultValue: T): T => {
|
||||
return item === null ? defaultValue : JSON.parse(item);
|
||||
};
|
||||
|
||||
export const setSetting = <T>(name: string, newValue: T) =>
|
||||
export const setSetting = <T>(name: string, newValue: T): void =>
|
||||
setLocalStorageItem(getSettingKey(name), JSON.stringify(newValue));
|
||||
|
||||
export const isFirefox = () => {
|
||||
export const isFirefox = (): boolean => {
|
||||
const { userAgent } = navigator;
|
||||
return userAgent.includes("Firefox");
|
||||
};
|
||||
|
||||
const canEnableSpatialAudio = () => {
|
||||
const canEnableSpatialAudio = (): boolean => {
|
||||
// Spatial audio means routing audio through audio contexts. On Chrome,
|
||||
// this bypasses the AEC processor and so breaks echo cancellation.
|
||||
// We only allow spatial audio to be enabled on Firefox which we know
|
||||
@@ -83,7 +83,8 @@ export const useSpatialAudio = (): DisableableSetting<boolean> => {
|
||||
return [false, null];
|
||||
};
|
||||
|
||||
export const useShowInspector = () => useSetting("show-inspector", false);
|
||||
export const useShowInspector = (): Setting<boolean> =>
|
||||
useSetting("show-inspector", false);
|
||||
|
||||
// null = undecided
|
||||
export const useOptInAnalytics = (): DisableableSetting<boolean | null> => {
|
||||
@@ -103,15 +104,15 @@ export const useEnableE2EE = (): DisableableSetting<boolean | null> => {
|
||||
return [false, null];
|
||||
};
|
||||
|
||||
export const useDeveloperSettingsTab = () =>
|
||||
export const useDeveloperSettingsTab = (): Setting<boolean> =>
|
||||
useSetting("developer-settings-tab", false);
|
||||
|
||||
export const useShowConnectionStats = () =>
|
||||
export const useShowConnectionStats = (): Setting<boolean> =>
|
||||
useSetting("show-connection-stats", false);
|
||||
|
||||
export const useAudioInput = () =>
|
||||
export const useAudioInput = (): Setting<string | undefined> =>
|
||||
useSetting<string | undefined>("audio-input", undefined);
|
||||
export const useAudioOutput = () =>
|
||||
export const useAudioOutput = (): Setting<string | undefined> =>
|
||||
useSetting<string | undefined>("audio-output", undefined);
|
||||
export const useVideoInput = () =>
|
||||
export const useVideoInput = (): Setting<string | undefined> =>
|
||||
useSetting<string | undefined>("video-input", undefined);
|
||||
|
||||
Reference in New Issue
Block a user