chore: add eslint-plugin-react-compiler (#10969)

* install ESLint plugin

* fix eslint CodeBlockLine error

* eslint

* eslint

* eslint

* refactor: apply lint autofix

* empty

---------

Co-authored-by: slorber <749374+slorber@users.noreply.github.com>
This commit is contained in:
Sébastien Lorber 2025-03-07 18:04:40 +01:00 committed by GitHub
parent d33004da1e
commit 15b0ef6d13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 133 additions and 58 deletions

View file

@ -11,16 +11,29 @@ import type {Props} from '@theme/CodeBlock/Line';
import styles from './styles.module.css';
type Token = Props['line'][number];
// Replaces '\n' by ''
// Historical code, not sure why we even need this :/
function fixLineBreak(line: Token[]) {
const singleLineBreakToken =
line.length === 1 && line[0]!.content === '\n' ? line[0] : undefined;
if (singleLineBreakToken) {
return [{...singleLineBreakToken, content: ''}];
}
return line;
}
export default function CodeBlockLine({
line,
line: lineProp,
classNames,
showLineNumbers,
getLineProps,
getTokenProps,
}: Props): ReactNode {
if (line.length === 1 && line[0]!.content === '\n') {
line[0]!.content = '';
}
const line = fixLineBreak(lineProp);
const lineProps = getLineProps({
line,