Migrate conversations to ESLint

This commit is contained in:
Chris Svenningsen 2020-09-14 12:51:27 -07:00 committed by Josh Perez
parent b4f0f3c685
commit 372aa44e49
90 changed files with 1261 additions and 1165 deletions

View file

@ -13,7 +13,7 @@ function getImageTag({
sizeClass,
key,
}: {
match: any;
match: RegExpExecArray;
sizeClass?: SizeClassType;
key: string | number;
}) {
@ -24,7 +24,6 @@ function getImageTag({
}
return (
// tslint:disable-next-line react-a11y-img-has-alt
<img
key={key}
src={img}
@ -48,15 +47,20 @@ export class Emojify extends React.Component<Props> {
renderNonEmoji: ({ text }) => text,
};
public render() {
public render():
| JSX.Element
| string
| null
| Array<JSX.Element | string | null> {
const { text, sizeClass, renderNonEmoji } = this.props;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const results: Array<any> = [];
const regex = emojiRegex();
// We have to do this, because renderNonEmoji is not required in our Props object,
// but it is always provided via defaultProps.
if (!renderNonEmoji) {
return;
return null;
}
let match = regex.exec(text);
@ -70,17 +74,20 @@ export class Emojify extends React.Component<Props> {
while (match) {
if (last < match.index) {
const textWithNoEmoji = text.slice(last, match.index);
results.push(renderNonEmoji({ text: textWithNoEmoji, key: count++ }));
count += 1;
results.push(renderNonEmoji({ text: textWithNoEmoji, key: count }));
}
results.push(getImageTag({ match, sizeClass, key: count++ }));
count += 1;
results.push(getImageTag({ match, sizeClass, key: count }));
last = regex.lastIndex;
match = regex.exec(text);
}
if (last < text.length) {
results.push(renderNonEmoji({ text: text.slice(last), key: count++ }));
count += 1;
results.push(renderNonEmoji({ text: text.slice(last), key: count }));
}
return results;