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
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import React, { createRef, KeyboardEventHandler } from "react";
|
||||
|
||||
import { _t } from "../../../languageHandler";
|
||||
import withValidation from "./Validation";
|
||||
import withValidation, { IFieldState, IValidationResult } from "./Validation";
|
||||
import Field, { IValidateOpts } from "./Field";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
|
||||
|
@ -60,7 +60,12 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
return hashAlias;
|
||||
}
|
||||
|
||||
private get domainProps() {
|
||||
private get domainProps(): {
|
||||
prefix: JSX.Element;
|
||||
postfix: JSX.Element;
|
||||
value: string;
|
||||
maxlength: number;
|
||||
} {
|
||||
const { domain } = this.props;
|
||||
const prefix = <span>#</span>;
|
||||
const postfix = domain ? <span title={`:${domain}`}>{`:${domain}`}</span> : <span />;
|
||||
|
@ -72,7 +77,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
return { prefix, postfix, value, maxlength };
|
||||
}
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { prefix, postfix, value, maxlength } = this.domainProps;
|
||||
return (
|
||||
<Field
|
||||
|
@ -93,13 +98,11 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
);
|
||||
}
|
||||
|
||||
private onChange = (ev) => {
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(this.asFullAlias(ev.target.value));
|
||||
}
|
||||
private onChange = (ev: React.ChangeEvent<HTMLInputElement>): void => {
|
||||
this.props.onChange?.(this.asFullAlias(ev.target.value));
|
||||
};
|
||||
|
||||
private onValidate = async (fieldState) => {
|
||||
private onValidate = async (fieldState: IFieldState): Promise<IValidationResult> => {
|
||||
const result = await this.validationRules(fieldState);
|
||||
this.setState({ isValid: result.valid });
|
||||
return result;
|
||||
|
@ -109,7 +112,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
rules: [
|
||||
{
|
||||
key: "hasDomain",
|
||||
test: async ({ value }) => {
|
||||
test: async ({ value }): Promise<boolean> => {
|
||||
// Ignore if we have passed domain
|
||||
if (!value || this.props.domain) {
|
||||
return true;
|
||||
|
@ -124,7 +127,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
},
|
||||
{
|
||||
key: "hasLocalpart",
|
||||
test: async ({ value }) => {
|
||||
test: async ({ value }): Promise<boolean> => {
|
||||
if (!value || this.props.domain) {
|
||||
return true;
|
||||
}
|
||||
|
@ -144,7 +147,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
},
|
||||
{
|
||||
key: "safeLocalpart",
|
||||
test: async ({ value }) => {
|
||||
test: async ({ value }): Promise<boolean> => {
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
|
@ -174,7 +177,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
? {
|
||||
key: "matches",
|
||||
final: true,
|
||||
test: async ({ value }) => {
|
||||
test: async ({ value }): Promise<boolean> => {
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
|
@ -192,7 +195,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
: {
|
||||
key: "taken",
|
||||
final: true,
|
||||
test: async ({ value }) => {
|
||||
test: async ({ value }): Promise<boolean> => {
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
|
@ -218,15 +221,15 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||
],
|
||||
});
|
||||
|
||||
public get isValid() {
|
||||
public get isValid(): boolean {
|
||||
return this.state.isValid;
|
||||
}
|
||||
|
||||
public validate(options: IValidateOpts) {
|
||||
public validate(options: IValidateOpts): Promise<boolean> {
|
||||
return this.fieldRef.current?.validate(options);
|
||||
}
|
||||
|
||||
public focus() {
|
||||
public focus(): void {
|
||||
this.fieldRef.current?.focus();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue