Migrate conversations to ESLint
This commit is contained in:
parent
b4f0f3c685
commit
372aa44e49
90 changed files with 1261 additions and 1165 deletions
|
@ -13,15 +13,20 @@ export class AddNewLines extends React.Component<Props> {
|
|||
renderNonNewLine: ({ text }) => text,
|
||||
};
|
||||
|
||||
public render() {
|
||||
public render():
|
||||
| JSX.Element
|
||||
| string
|
||||
| null
|
||||
| Array<JSX.Element | string | null> {
|
||||
const { text, renderNonNewLine } = this.props;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const results: Array<any> = [];
|
||||
const FIND_NEWLINES = /\n/g;
|
||||
|
||||
// We have to do this, because renderNonNewLine is not required in our Props object,
|
||||
// but it is always provided via defaultProps.
|
||||
if (!renderNonNewLine) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
let match = FIND_NEWLINES.exec(text);
|
||||
|
@ -35,20 +40,20 @@ export class AddNewLines extends React.Component<Props> {
|
|||
while (match) {
|
||||
if (last < match.index) {
|
||||
const textWithNoNewline = text.slice(last, match.index);
|
||||
results.push(
|
||||
renderNonNewLine({ text: textWithNoNewline, key: count++ })
|
||||
);
|
||||
count += 1;
|
||||
results.push(renderNonNewLine({ text: textWithNoNewline, key: count }));
|
||||
}
|
||||
|
||||
results.push(<br key={count++} />);
|
||||
count += 1;
|
||||
results.push(<br key={count} />);
|
||||
|
||||
// @ts-ignore
|
||||
last = FIND_NEWLINES.lastIndex;
|
||||
match = FIND_NEWLINES.exec(text);
|
||||
}
|
||||
|
||||
if (last < text.length) {
|
||||
results.push(renderNonNewLine({ text: text.slice(last), key: count++ }));
|
||||
count += 1;
|
||||
results.push(renderNonNewLine({ text: text.slice(last), key: count }));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue