From 79753de78f988ae21e01f817302dd933d6d4c502 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Wed, 5 Jan 2022 17:52:20 +0100 Subject: [PATCH] Linting --- components/REPL/REPLHistory.tsx | 26 +++++++++++++------------- components/REPL/REPLInput.tsx | 4 ++-- components/REPL/index.tsx | 2 +- lib/commands/definitions.ts | 8 ++++---- pages/index.tsx | 4 +--- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/components/REPL/REPLHistory.tsx b/components/REPL/REPLHistory.tsx index 322bfe7..4d4b66a 100644 --- a/components/REPL/REPLHistory.tsx +++ b/components/REPL/REPLHistory.tsx @@ -23,7 +23,7 @@ const REPLHistory: NextPage = ({history, inputRef}) => { })); } return true; - } + }; const makeLinks = (line: string) => { let idxStart = line.indexOf("#{"); @@ -31,7 +31,7 @@ const REPLHistory: NextPage = ({history, inputRef}) => { let idxEnd = line.indexOf("}", idxSep); if (idxStart === -1 || idxSep === -1 || idxEnd === -1) return [line]; - const result = [] + const result = []; while (idxStart !== -1 && idxSep !== -1 && idxEnd !== -1) { const linkText = line.substring(idxStart+2, idxSep); @@ -40,14 +40,14 @@ const REPLHistory: NextPage = ({history, inputRef}) => { result.push(line.substring(0, idxStart)); result.push({linkText}); - line = line.substring(idxEnd+1) + line = line.substring(idxEnd+1); idxStart = line.indexOf("#{"); idxSep = line.indexOf("|", idxStart); idxEnd = line.indexOf("}", idxSep); } - result.push(line.substring(idxEnd+1)) + result.push(line.substring(idxEnd+1)); return result; - } + }; const makeCommands = (line: string|JSX.Element, indexKey: number) => { if (typeof line !== "string") return line; @@ -56,7 +56,7 @@ const REPLHistory: NextPage = ({history, inputRef}) => { let idxEnd = line.indexOf("}", idxStart); if (idxStart === -1 || idxEnd === -1) return line; - const result = [] + const result = []; while (idxStart !== -1 && idxEnd !== -1) { const cmdText = line.substring(idxStart+2, idxEnd); @@ -65,27 +65,27 @@ const REPLHistory: NextPage = ({history, inputRef}) => { result.push({cmdText}); - line = line.substring(idxEnd+1) + line = line.substring(idxEnd+1); idxStart = line.indexOf("%{"); idxEnd = line.indexOf("}", idxStart); } - result.push(line.substring(idxEnd+1)) + result.push(line.substring(idxEnd+1)); return result; - } + }; const parseLine = (line: string) => { if (line === "") return "\u00A0"; const resultLinks = makeLinks(line); - const resultAll = resultLinks.map(makeCommands) - return resultAll.flat() - } + const resultAll = resultLinks.map(makeCommands); + return resultAll.flat(); + }; return
{ history.map((value, idx) => { return
{parseLine(value)} -
} +
;} )} ; }; diff --git a/components/REPL/REPLInput.tsx b/components/REPL/REPLInput.tsx index afbf7e9..37c6fb3 100644 --- a/components/REPL/REPLInput.tsx +++ b/components/REPL/REPLInput.tsx @@ -19,7 +19,7 @@ const REPLInput: NextPage = ({historyCallback, historyClear, in inputRef.value = ""; if(typed.current) typed.current.innerHTML = ""; if(completion.current) completion.current.innerHTML = ""; - } + }; const replinOnChange = (e: React.FormEvent) => { const input = (e.target as HTMLInputElement); @@ -58,7 +58,7 @@ const REPLInput: NextPage = ({historyCallback, historyClear, in if (e.key === "Enter") { e.preventDefault(); - const command = (e.target as HTMLInputElement).value + const command = (e.target as HTMLInputElement).value; if (command === "clear") { clearInput(input); historyClear(); diff --git a/components/REPL/index.tsx b/components/REPL/index.tsx index a279bce..cf03d88 100644 --- a/components/REPL/index.tsx +++ b/components/REPL/index.tsx @@ -11,7 +11,7 @@ const REPL: NextPage<{inputRef: MutableRefObject}> = const focusInput = () => { if (inputRef.current) inputRef.current.focus(); - } + }; return (
diff --git a/lib/commands/definitions.ts b/lib/commands/definitions.ts index c0c8b88..2408d86 100644 --- a/lib/commands/definitions.ts +++ b/lib/commands/definitions.ts @@ -184,21 +184,21 @@ const exitCmd: Command = { execute: () => { if (typeof window !== undefined) { window.opener = null; - window.open('', '_self'); + window.open("", "_self"); window.close(); } return [ "If you can read this, closing the window did not work.", "This is most likely because of a restriction in JavaScript.", "#{Read more here|https://developer.mozilla.org/en-US/docs/Web/API/Window/close}." - ] + ]; } -} +}; const clear: Command = { name: "clear", desc: "Clears the output on screen.", execute: () => [] -} +}; export const commandList = [about, help, man, project, exitCmd, clear]; \ No newline at end of file diff --git a/pages/index.tsx b/pages/index.tsx index c9d65d0..924dbb7 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -9,9 +9,7 @@ import styles from "../styles/Home.module.css"; const Home: NextPage = () => { const inputRef = useRef(); - const focusInput = () => { - console.log("Focus") - if (inputRef.current) inputRef.current.focus();}; + const focusInput = () => {if (inputRef.current) inputRef.current.focus();}; return (<>