From 2f653ebfd07c96efe2d3c8d92280c46911a18169 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 12 Sep 2024 13:50:18 -0400 Subject: [PATCH] new-log-viewer: Fix lint errors introduced in #59. (#70) --- new-log-viewer/src/components/MenuBar/PageNumInput.tsx | 3 ++- new-log-viewer/src/utils/config.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/new-log-viewer/src/components/MenuBar/PageNumInput.tsx b/new-log-viewer/src/components/MenuBar/PageNumInput.tsx index e8ad1489..33da7e4a 100644 --- a/new-log-viewer/src/components/MenuBar/PageNumInput.tsx +++ b/new-log-viewer/src/components/MenuBar/PageNumInput.tsx @@ -55,7 +55,8 @@ const PageNumInput = () => { return; } inputRef.current.style.width = "0"; - inputRef.current.style.width = `${inputRef.current.scrollWidth + PAGE_NUM_INPUT_FIT_EXTRA_WIDTH}px`; + inputRef.current.style.width = + `${inputRef.current.scrollWidth + PAGE_NUM_INPUT_FIT_EXTRA_WIDTH}px`; }; const handleInputChange = () => { diff --git a/new-log-viewer/src/utils/config.ts b/new-log-viewer/src/utils/config.ts index 0661702d..1d78a364 100644 --- a/new-log-viewer/src/utils/config.ts +++ b/new-log-viewer/src/utils/config.ts @@ -31,6 +31,7 @@ const CONFIG_DEFAULT: ConfigMap = Object.freeze({ * @param props.key * @param props.value * @return `null` if the value is valid, or an error message otherwise. + * @throws {Error} If the config item cannot be managed by these config utilities. */ const testConfig = ({key, value}: ConfigUpdate): Nullable => { let result = null; @@ -41,7 +42,7 @@ const testConfig = ({key, value}: ConfigUpdate): Nullable => { } break; case CONFIG_KEY.THEME: - throw new Error(`${key} should be handled by JoyUI instead.`); + throw new Error(`"${key}" cannot be managed using these utilities.`); case CONFIG_KEY.PAGE_SIZE: if (0 >= value || MAX_PAGE_SIZE < value) { result = `Page size must be greater than 0 and less than ${MAX_PAGE_SIZE + 1}.`; @@ -61,6 +62,7 @@ const testConfig = ({key, value}: ConfigUpdate): Nullable => { * @param props.key * @param props.value * @return `null` if the update succeeds, or an error message otherwise. + * @throws {Error} If the config item cannot be managed by these config utilities. */ const setConfig = ({key, value}: ConfigUpdate): Nullable => { const error = testConfig({key, value} as ConfigUpdate); @@ -86,7 +88,7 @@ const setConfig = ({key, value}: ConfigUpdate): Nullable => { ); break; case CONFIG_KEY.THEME: - throw new Error(`${key} should be handled by JoyUI instead.`); + throw new Error(`"${key}" cannot be managed using these utilities.`); case CONFIG_KEY.PAGE_SIZE: window.localStorage.setItem(LOCAL_STORAGE_KEY.PAGE_SIZE, value.toString()); break; @@ -101,6 +103,7 @@ const setConfig = ({key, value}: ConfigUpdate): Nullable => { * * @param key * @return The value. + * @throws {Error} If the config item cannot be managed by these config utilities. */ const getConfig = (key: T): ConfigMap[T] => { let value = null; @@ -121,7 +124,7 @@ const getConfig = (key: T): ConfigMap[T] => { } as DecoderOptionsType; break; case CONFIG_KEY.THEME: - throw new Error(`${key} should be handled by JoyUI instead.`); + throw new Error(`"${key}" cannot be managed using these utilities.`); case CONFIG_KEY.PAGE_SIZE: value = window.localStorage.getItem(LOCAL_STORAGE_KEY.PAGE_SIZE); break;