mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
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:
parent
d33004da1e
commit
15b0ef6d13
12 changed files with 133 additions and 58 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue