From 8ce40bc4cd9d4802a1f502870e9cb1994808ee3a Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Fri, 1 Nov 2024 17:22:35 +0100 Subject: [PATCH] fix(frontend): remove linter workarounds Signed-off-by: Erik Michelson --- .../utils/node-to-react-transformer.tsx | 3 +-- frontend/src/pages/api/private/config.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/markdown-renderer/markdown-to-react/utils/node-to-react-transformer.tsx b/frontend/src/components/markdown-renderer/markdown-to-react/utils/node-to-react-transformer.tsx index 025f5e303..0dd07c6da 100644 --- a/frontend/src/components/markdown-renderer/markdown-to-react/utils/node-to-react-transformer.tsx +++ b/frontend/src/components/markdown-renderer/markdown-to-react/utils/node-to-react-transformer.tsx @@ -74,8 +74,7 @@ export class NodeToReactTransformer { * @return the created react element */ private translateElementToReactElement(element: Element, index: number | string): ValidReactDomElement { - const numericIndex = typeof index === 'number' ? index : Number.parseInt(index) - const elementKey = this.calculateUniqueKey(element).orElseGet(() => (-numericIndex).toString()) + const elementKey = this.calculateUniqueKey(element).orElseGet(() => `-${index}`) const replacement = this.findElementReplacement(element, elementKey) if (replacement === null) { return null diff --git a/frontend/src/pages/api/private/config.ts b/frontend/src/pages/api/private/config.ts index 48d991cfc..74973cb08 100644 --- a/frontend/src/pages/api/private/config.ts +++ b/frontend/src/pages/api/private/config.ts @@ -57,9 +57,15 @@ const initialConfig: FrontendConfig = { let currentConfig: FrontendConfig = initialConfig const handler = (req: NextApiRequest, res: NextApiResponse) => { - // This is shorter than storing the return boolean in a variable and then calling respondToTestRequest with if - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - respondToMatchingRequest(HttpMethod.GET, req, res, currentConfig, 200, false) || + const responseSuccessful = respondToMatchingRequest( + HttpMethod.GET, + req, + res, + currentConfig, + 200, + false + ) + if (!responseSuccessful) { respondToTestRequest(req, res, () => { currentConfig = { ...initialConfig, @@ -67,6 +73,7 @@ const handler = (req: NextApiRequest, res: NextApiResponse) => { } return currentConfig }) + } } export default handler