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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
683 changed files with 3459 additions and 3013 deletions

View file

@ -155,13 +155,13 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
return this.state.masterPushRule?.enabled;
}
public componentDidMount() {
public componentDidMount(): void {
// noinspection JSIgnoredPromiseFromCall
this.refreshFromServer();
this.refreshFromAccountData();
}
public componentWillUnmount() {
public componentWillUnmount(): void {
this.settingWatchers.forEach((watcher) => SettingsStore.unwatchSetting(watcher));
}
@ -171,7 +171,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
}
private async refreshFromServer() {
private async refreshFromServer(): Promise<void> {
try {
const newState = (
await Promise.all([this.refreshRules(), this.refreshPushers(), this.refreshThreepids()])
@ -196,7 +196,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
}
private async refreshFromAccountData() {
private async refreshFromAccountData(): Promise<void> {
const cli = MatrixClientPeg.get();
const settingsEvent = cli.getAccountData(getLocalNotificationAccountDataEventType(cli.deviceId));
if (settingsEvent) {
@ -317,14 +317,14 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
return MatrixClientPeg.get().getThreePids();
}
private showSaveError() {
private showSaveError(): void {
Modal.createDialog(ErrorDialog, {
title: _t("Error saving notification preferences"),
description: _t("An error occurred whilst saving your notification preferences."),
});
}
private onMasterRuleChanged = async (checked: boolean) => {
private onMasterRuleChanged = async (checked: boolean): Promise<void> => {
this.setState({ phase: Phase.Persisting });
try {
@ -338,11 +338,11 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
};
private updateDeviceNotifications = async (checked: boolean) => {
private updateDeviceNotifications = async (checked: boolean): Promise<void> => {
await SettingsStore.setValue("deviceNotificationsEnabled", null, SettingLevel.DEVICE, checked);
};
private onEmailNotificationsChanged = async (email: string, checked: boolean) => {
private onEmailNotificationsChanged = async (email: string, checked: boolean): Promise<void> => {
this.setState({ phase: Phase.Persisting });
try {
@ -376,19 +376,19 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
};
private onDesktopNotificationsChanged = async (checked: boolean) => {
private onDesktopNotificationsChanged = async (checked: boolean): Promise<void> => {
await SettingsStore.setValue("notificationsEnabled", null, SettingLevel.DEVICE, checked);
};
private onDesktopShowBodyChanged = async (checked: boolean) => {
private onDesktopShowBodyChanged = async (checked: boolean): Promise<void> => {
await SettingsStore.setValue("notificationBodyEnabled", null, SettingLevel.DEVICE, checked);
};
private onAudioNotificationsChanged = async (checked: boolean) => {
private onAudioNotificationsChanged = async (checked: boolean): Promise<void> => {
await SettingsStore.setValue("audioNotificationsEnabled", null, SettingLevel.DEVICE, checked);
};
private onRadioChecked = async (rule: IVectorPushRule, checkedState: VectorState) => {
private onRadioChecked = async (rule: IVectorPushRule, checkedState: VectorState): Promise<void> => {
this.setState({ phase: Phase.Persisting });
try {
@ -454,7 +454,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
};
private async setKeywords(keywords: string[], originalRules: IAnnotatedPushRule[]) {
private async setKeywords(keywords: string[], originalRules: IAnnotatedPushRule[]): Promise<void> {
try {
// De-duplicate and remove empties
keywords = Array.from(new Set(keywords)).filter((k) => !!k);
@ -502,7 +502,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
}
private onKeywordAdd = (keyword: string) => {
private onKeywordAdd = (keyword: string): void => {
const originalRules = objectClone(this.state.vectorKeywordRuleInfo.rules);
// We add the keyword immediately as a sort of local echo effect
@ -519,7 +519,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
],
},
},
async () => {
async (): Promise<void> => {
await this.setKeywords(
this.state.vectorKeywordRuleInfo.rules.map((r) => r.pattern),
originalRules,
@ -528,7 +528,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
);
};
private onKeywordRemove = (keyword: string) => {
private onKeywordRemove = (keyword: string): void => {
const originalRules = objectClone(this.state.vectorKeywordRuleInfo.rules);
// We remove the keyword immediately as a sort of local echo effect
@ -540,7 +540,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
rules: this.state.vectorKeywordRuleInfo.rules.filter((r) => r.pattern !== keyword),
},
},
async () => {
async (): Promise<void> => {
await this.setKeywords(
this.state.vectorKeywordRuleInfo.rules.map((r) => r.pattern),
originalRules,
@ -549,7 +549,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
);
};
private renderTopSection() {
private renderTopSection(): JSX.Element {
const masterSwitch = (
<LabelledToggleSwitch
data-testid="notif-master-switch"
@ -622,7 +622,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
);
}
private renderCategory(category: RuleClass) {
private renderCategory(category: RuleClass): JSX.Element {
if (category !== RuleClass.VectorOther && this.isInhibited) {
return null; // nothing to show for the section
}
@ -680,7 +680,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
[VectorState.Loud]: _t("Noisy"),
};
const makeRadio = (r: IVectorPushRule, s: VectorState) => (
const makeRadio = (r: IVectorPushRule, s: VectorState): JSX.Element => (
<StyledRadioButton
key={r.ruleId + s}
name={r.ruleId}
@ -736,7 +736,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
);
}
private renderTargets() {
private renderTargets(): JSX.Element {
if (this.isInhibited) return null; // no targets if there's no notifications
const rows = this.state.pushers.map((p) => (
@ -758,7 +758,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
);
}
public render() {
public render(): JSX.Element {
if (this.state.phase === Phase.Loading) {
// Ends up default centered
return <Spinner />;