Skip to content

Commit 1f02742

Browse files
committed
lint
1 parent a125218 commit 1f02742

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

client/src/templates/Challenges/components/prism-formatted.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,40 @@ interface PrismFormattedProps {
1414
* @param showLineNumbers
1515
* @param darkTheme
1616
*/
17-
const addFormattingClassesForPres = (container: HTMLElement, showLineNumbers = true, darkTheme = true) => {
18-
const codeBlocks: HTMLElement[] = [].slice.call(container.querySelectorAll('[class*="language-"]'));
17+
const addFormattingClassesForPres = (
18+
container: HTMLElement,
19+
showLineNumbers = true,
20+
darkTheme = true
21+
) => {
22+
const codeBlocks: HTMLElement[] = [].slice.call(
23+
container.querySelectorAll('[class*="language-"]')
24+
);
1925
// we want to formatt the <pre> element, not the <code>, get parent if current element is not PRE
20-
const preElements: HTMLPreElement[] = codeBlocks.map(c => (c.nodeName === 'PRE' ? c : c.parentElement) as HTMLPreElement);
26+
const preElements: HTMLPreElement[] = codeBlocks.map(
27+
c => (c.nodeName === 'PRE' ? c : c.parentElement) as HTMLPreElement
28+
);
2129

22-
for(const pre of preElements) {
30+
for (const pre of preElements) {
2331
pre.classList.toggle('line-numbers', showLineNumbers);
2432
pre.classList.toggle('dark-palette', darkTheme);
2533
}
26-
}
34+
};
2735

28-
function PrismFormatted({ className, text, ...props }: PrismFormattedProps): JSX.Element {
36+
function PrismFormatted({
37+
className,
38+
text,
39+
...props
40+
}: PrismFormattedProps): JSX.Element {
2941
const instructionsRef = useRef<HTMLDivElement>(null);
3042

3143
useEffect(() => {
3244
// Just in case 'current' has not been created, though it should have been.
3345
if (instructionsRef.current) {
34-
addFormattingClassesForPres(instructionsRef.current, props.lineNumbers, props.darkTheme);
46+
addFormattingClassesForPres(
47+
instructionsRef.current,
48+
props.lineNumbers,
49+
props.darkTheme
50+
);
3551
Prism.highlightAllUnder(instructionsRef.current);
3652
}
3753
}, [props.darkTheme, props.lineNumbers]);

0 commit comments

Comments
 (0)