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
|
@ -49,7 +49,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
class Category extends React.PureComponent<IProps> {
|
||||
private renderEmojiRow = (rowIndex: number) => {
|
||||
private renderEmojiRow = (rowIndex: number): JSX.Element => {
|
||||
const { onClick, onMouseEnter, onMouseLeave, selectedEmojis, emojis } = this.props;
|
||||
const emojisForRow = emojis.slice(rowIndex * 8, (rowIndex + 1) * 8);
|
||||
return (
|
||||
|
@ -69,7 +69,7 @@ class Category extends React.PureComponent<IProps> {
|
|||
);
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { emojis, name, heightBefore, viewportHeight, scrollTop } = this.props;
|
||||
if (!emojis || emojis.length === 0) {
|
||||
return null;
|
||||
|
|
|
@ -30,7 +30,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
class Emoji extends React.PureComponent<IProps> {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { onClick, onMouseEnter, onMouseLeave, emoji, selectedEmojis } = this.props;
|
||||
const isSelected = selectedEmojis && selectedEmojis.has(emoji.unicode);
|
||||
return (
|
||||
|
|
|
@ -141,7 +141,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
];
|
||||
}
|
||||
|
||||
private onScroll = () => {
|
||||
private onScroll = (): void => {
|
||||
const body = this.scrollRef.current?.containerRef.current;
|
||||
this.setState({
|
||||
scrollTop: body.scrollTop,
|
||||
|
@ -150,7 +150,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
this.updateVisibility();
|
||||
};
|
||||
|
||||
private updateVisibility = () => {
|
||||
private updateVisibility = (): void => {
|
||||
const body = this.scrollRef.current?.containerRef.current;
|
||||
const rect = body.getBoundingClientRect();
|
||||
for (const cat of this.categories) {
|
||||
|
@ -177,13 +177,13 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
}
|
||||
};
|
||||
|
||||
private scrollToCategory = (category: string) => {
|
||||
private scrollToCategory = (category: string): void => {
|
||||
this.scrollRef.current?.containerRef.current
|
||||
?.querySelector(`[data-category-id="${category}"]`)
|
||||
.scrollIntoView();
|
||||
};
|
||||
|
||||
private onChangeFilter = (filter: string) => {
|
||||
private onChangeFilter = (filter: string): void => {
|
||||
const lcFilter = filter.toLowerCase().trim(); // filter is case insensitive
|
||||
for (const cat of this.categories) {
|
||||
let emojis;
|
||||
|
@ -216,7 +216,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
);
|
||||
};
|
||||
|
||||
private onEnterFilter = () => {
|
||||
private onEnterFilter = (): void => {
|
||||
const btn =
|
||||
this.scrollRef.current?.containerRef.current?.querySelector<HTMLButtonElement>(".mx_EmojiPicker_item");
|
||||
if (btn) {
|
||||
|
@ -224,32 +224,32 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
}
|
||||
};
|
||||
|
||||
private onHoverEmoji = (emoji: IEmoji) => {
|
||||
private onHoverEmoji = (emoji: IEmoji): void => {
|
||||
this.setState({
|
||||
previewEmoji: emoji,
|
||||
});
|
||||
};
|
||||
|
||||
private onHoverEmojiEnd = (emoji: IEmoji) => {
|
||||
private onHoverEmojiEnd = (emoji: IEmoji): void => {
|
||||
this.setState({
|
||||
previewEmoji: null,
|
||||
});
|
||||
};
|
||||
|
||||
private onClickEmoji = (emoji: IEmoji) => {
|
||||
private onClickEmoji = (emoji: IEmoji): void => {
|
||||
if (this.props.onChoose(emoji.unicode) !== false) {
|
||||
recent.add(emoji.unicode);
|
||||
}
|
||||
};
|
||||
|
||||
private static categoryHeightForEmojiCount(count: number) {
|
||||
private static categoryHeightForEmojiCount(count: number): number {
|
||||
if (count === 0) {
|
||||
return 0;
|
||||
}
|
||||
return CATEGORY_HEADER_HEIGHT + Math.ceil(count / EMOJIS_PER_ROW) * EMOJI_HEIGHT;
|
||||
}
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
let heightBefore = 0;
|
||||
return (
|
||||
<div className="mx_EmojiPicker" data-testid="mx_EmojiPicker">
|
||||
|
|
|
@ -29,7 +29,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
class Header extends React.PureComponent<IProps> {
|
||||
private findNearestEnabled(index: number, delta: number) {
|
||||
private findNearestEnabled(index: number, delta: number): number {
|
||||
index += this.props.categories.length;
|
||||
const cats = [...this.props.categories, ...this.props.categories, ...this.props.categories];
|
||||
|
||||
|
@ -39,12 +39,12 @@ class Header extends React.PureComponent<IProps> {
|
|||
}
|
||||
}
|
||||
|
||||
private changeCategoryRelative(delta: number) {
|
||||
private changeCategoryRelative(delta: number): void {
|
||||
const current = this.props.categories.findIndex((c) => c.visible);
|
||||
this.changeCategoryAbsolute(current + delta, delta);
|
||||
}
|
||||
|
||||
private changeCategoryAbsolute(index: number, delta = 1) {
|
||||
private changeCategoryAbsolute(index: number, delta = 1): void {
|
||||
const category = this.props.categories[this.findNearestEnabled(index, delta)];
|
||||
if (category) {
|
||||
this.props.onAnchorClick(category.id);
|
||||
|
@ -54,7 +54,7 @@ class Header extends React.PureComponent<IProps> {
|
|||
|
||||
// Implements ARIA Tabs with Automatic Activation pattern
|
||||
// https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-1/tabs.html
|
||||
private onKeyDown = (ev: React.KeyboardEvent) => {
|
||||
private onKeyDown = (ev: React.KeyboardEvent): void => {
|
||||
let handled = true;
|
||||
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev);
|
||||
|
@ -82,7 +82,7 @@ class Header extends React.PureComponent<IProps> {
|
|||
}
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<nav
|
||||
className="mx_EmojiPicker_header"
|
||||
|
|
|
@ -24,7 +24,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
class Preview extends React.PureComponent<IProps> {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const {
|
||||
unicode,
|
||||
label,
|
||||
|
|
|
@ -47,19 +47,19 @@ class QuickReactions extends React.Component<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
private onMouseEnter = (emoji: IEmoji) => {
|
||||
private onMouseEnter = (emoji: IEmoji): void => {
|
||||
this.setState({
|
||||
hover: emoji,
|
||||
});
|
||||
};
|
||||
|
||||
private onMouseLeave = () => {
|
||||
private onMouseLeave = (): void => {
|
||||
this.setState({
|
||||
hover: null,
|
||||
});
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<section className="mx_EmojiPicker_footer mx_EmojiPicker_quick mx_EmojiPicker_category">
|
||||
<h2 className="mx_EmojiPicker_quick_header mx_EmojiPicker_category_label">
|
||||
|
|
|
@ -50,14 +50,14 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||
this.addListeners();
|
||||
}
|
||||
|
||||
public componentDidUpdate(prevProps) {
|
||||
public componentDidUpdate(prevProps): void {
|
||||
if (prevProps.reactions !== this.props.reactions) {
|
||||
this.addListeners();
|
||||
this.onReactionsChange();
|
||||
}
|
||||
}
|
||||
|
||||
private addListeners() {
|
||||
private addListeners(): void {
|
||||
if (this.props.reactions) {
|
||||
this.props.reactions.on(RelationsEvent.Add, this.onReactionsChange);
|
||||
this.props.reactions.on(RelationsEvent.Remove, this.onReactionsChange);
|
||||
|
@ -65,7 +65,7 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
if (this.props.reactions) {
|
||||
this.props.reactions.removeListener(RelationsEvent.Add, this.onReactionsChange);
|
||||
this.props.reactions.removeListener(RelationsEvent.Remove, this.onReactionsChange);
|
||||
|
@ -86,13 +86,13 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||
);
|
||||
}
|
||||
|
||||
private onReactionsChange = () => {
|
||||
private onReactionsChange = (): void => {
|
||||
this.setState({
|
||||
selectedEmojis: new Set(Object.keys(this.getReactions())),
|
||||
});
|
||||
};
|
||||
|
||||
private onChoose = (reaction: string) => {
|
||||
private onChoose = (reaction: string): boolean => {
|
||||
this.componentWillUnmount();
|
||||
this.props.onFinished();
|
||||
const myReactions = this.getReactions();
|
||||
|
@ -130,7 +130,7 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||
return true;
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<EmojiPicker
|
||||
onChoose={this.onChoose}
|
||||
|
|
|
@ -30,12 +30,12 @@ interface IProps {
|
|||
class Search extends React.PureComponent<IProps> {
|
||||
private inputRef = React.createRef<HTMLInputElement>();
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
// For some reason, neither the autoFocus nor just calling focus() here worked, so here's a window.setTimeout
|
||||
window.setTimeout(() => this.inputRef.current.focus(), 0);
|
||||
}
|
||||
|
||||
private onKeyDown = (ev: React.KeyboardEvent) => {
|
||||
private onKeyDown = (ev: React.KeyboardEvent): void => {
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev);
|
||||
switch (action) {
|
||||
case KeyBindingAction.Enter:
|
||||
|
@ -46,7 +46,7 @@ class Search extends React.PureComponent<IProps> {
|
|||
}
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
let rightButton;
|
||||
if (this.props.query) {
|
||||
rightButton = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue