From 39a08199458208c3b9da4b0f56d2b4e043825ff0 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Thu, 11 Apr 2024 15:31:53 +0100 Subject: [PATCH] Linting --- src/components/App.tsx | 65 +++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 1737d852..72424988 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useRef, useState, - type ReactNode + type ReactNode, } from 'react'; import cliCursor from 'cli-cursor'; import AppContext from './AppContext.js'; @@ -48,7 +48,7 @@ class InternalAppErrorBoundary extends Component< } override state = { - error: undefined + error: undefined, }; override componentDidCatch(error: Error) { @@ -75,10 +75,10 @@ export default function App({ stderr, stdout, writeToStderr, - writeToStdout + writeToStdout, }: Props) { const rawModeEnabledCountRef = useRef(0); - const internal_eventEmitterRef = useRef(new EventEmitter()); + const eventEmitterRef = useRef(new EventEmitter()); const [activeFocusId, setActiveFocusId] = useState(); const [isFocusEnabled, setIsFocusEnabled] = useState(true); const [focusables, setFocusables] = useState([]); @@ -102,11 +102,11 @@ export default function App({ if (!isRawModeSupported) { if (stdin === process.stdin) { throw new Error( - 'Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported' + 'Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported', ); } else { throw new Error( - 'Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported' + 'Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported', ); } } @@ -157,7 +157,8 @@ export default function App({ focusPrevious(); } } - internal_eventEmitterRef.current.emit('input', chunk); + + eventEmitterRef.current.emit('input', chunk); } } @@ -197,7 +198,7 @@ export default function App({ const lastFocusableId = focusables.at(-1)?.id; const previousFocusableId = findPreviousFocusable( focusables, - activeFocusId + activeFocusId, ); setActiveFocusId(previousFocusableId ?? lastFocusableId); } @@ -207,13 +208,14 @@ export default function App({ if (!nextFocusId && autoFocus) { nextFocusId = id; } + setActiveFocusId(nextFocusId); setFocusables([ ...focusables, { id, - isActive: true - } + isActive: true, + }, ]); } @@ -222,7 +224,7 @@ export default function App({ setFocusables( focusables.filter(focusable => { return focusable.id !== id; - }) + }), ); } @@ -235,9 +237,9 @@ export default function App({ return { id, - isActive: true + isActive: true, }; - }) + }), ); } @@ -251,42 +253,43 @@ export default function App({ return { id, - isActive: false + isActive: false, }; - }) + }), ); } return ( + {/* eslint-disable-next-line react/jsx-no-bind */} {children} @@ -314,11 +318,12 @@ export default function App({ ); } + App.displayName = 'InternalApp'; function findPreviousFocusable( focusables: Focusable[], - activeFocusId: string | undefined + activeFocusId: string | undefined, ): string | undefined { const activeIndex = focusables.findIndex(focusable => { return focusable.id === activeFocusId; @@ -337,7 +342,7 @@ function findPreviousFocusable( function findNextFocusable( focusables: Focusable[], - activeFocusId: string | undefined + activeFocusId: string | undefined, ): string | undefined { const activeIndex = focusables.findIndex(focusable => { return focusable.id === activeFocusId;