Migrate components to eslint

This commit is contained in:
Chris Svenningsen 2020-09-11 17:46:52 -07:00 committed by Josh Perez
parent de66486e41
commit b13dbcfa77
69 changed files with 875 additions and 800 deletions

View file

@ -38,9 +38,9 @@ const renderEmoji = ({
);
export class MessageBodyHighlight extends React.Component<Props> {
public render() {
public render(): JSX.Element | Array<JSX.Element> {
const { text, i18n } = this.props;
const results: Array<any> = [];
const results: Array<JSX.Element> = [];
const FIND_BEGIN_END = /<<left>>(.+?)<<right>>/g;
let match = FIND_BEGIN_END.exec(text);
@ -49,12 +49,7 @@ export class MessageBodyHighlight extends React.Component<Props> {
if (!match) {
return (
<MessageBody
disableJumbomoji={true}
disableLinks={true}
text={text}
i18n={i18n}
/>
<MessageBody disableJumbomoji disableLinks text={text} i18n={i18n} />
);
}
@ -63,11 +58,12 @@ export class MessageBodyHighlight extends React.Component<Props> {
while (match) {
if (last < match.index) {
const beforeText = text.slice(last, match.index);
count += 1;
results.push(
renderEmoji({
text: beforeText,
sizeClass,
key: count++,
key: count,
i18n,
renderNonEmoji: renderNewLines,
})
@ -75,29 +71,30 @@ export class MessageBodyHighlight extends React.Component<Props> {
}
const [, toHighlight] = match;
count += 2;
results.push(
<span className="module-message-body__highlight" key={count++}>
<span className="module-message-body__highlight" key={count - 1}>
{renderEmoji({
text: toHighlight,
sizeClass,
key: count++,
key: count,
i18n,
renderNonEmoji: renderNewLines,
})}
</span>
);
// @ts-ignore
last = FIND_BEGIN_END.lastIndex;
match = FIND_BEGIN_END.exec(text);
}
if (last < text.length) {
count += 1;
results.push(
renderEmoji({
text: text.slice(last),
sizeClass,
key: count++,
key: count,
i18n,
renderNonEmoji: renderNewLines,
})