fix(frontend): remove linter workarounds

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2024-11-01 17:22:35 +01:00
parent 932ecac326
commit 8ce40bc4cd
2 changed files with 11 additions and 5 deletions

View file

@ -74,8 +74,7 @@ export class NodeToReactTransformer {
* @return the created react element * @return the created react element
*/ */
private translateElementToReactElement(element: Element, index: number | string): ValidReactDomElement { private translateElementToReactElement(element: Element, index: number | string): ValidReactDomElement {
const numericIndex = typeof index === 'number' ? index : Number.parseInt(index) const elementKey = this.calculateUniqueKey(element).orElseGet(() => `-${index}`)
const elementKey = this.calculateUniqueKey(element).orElseGet(() => (-numericIndex).toString())
const replacement = this.findElementReplacement(element, elementKey) const replacement = this.findElementReplacement(element, elementKey)
if (replacement === null) { if (replacement === null) {
return null return null

View file

@ -57,9 +57,15 @@ const initialConfig: FrontendConfig = {
let currentConfig: FrontendConfig = initialConfig let currentConfig: FrontendConfig = initialConfig
const handler = (req: NextApiRequest, res: NextApiResponse) => { const handler = (req: NextApiRequest, res: NextApiResponse) => {
// This is shorter than storing the return boolean in a variable and then calling respondToTestRequest with if const responseSuccessful = respondToMatchingRequest<FrontendConfig>(
// eslint-disable-next-line @typescript-eslint/no-unused-expressions HttpMethod.GET,
respondToMatchingRequest<FrontendConfig>(HttpMethod.GET, req, res, currentConfig, 200, false) || req,
res,
currentConfig,
200,
false
)
if (!responseSuccessful) {
respondToTestRequest<FrontendConfig>(req, res, () => { respondToTestRequest<FrontendConfig>(req, res, () => {
currentConfig = { currentConfig = {
...initialConfig, ...initialConfig,
@ -68,5 +74,6 @@ const handler = (req: NextApiRequest, res: NextApiResponse) => {
return currentConfig return currentConfig
}) })
} }
}
export default handler export default handler