From 12fd624780ef2b34dad9a777505405ca98590169 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 22 Feb 2025 17:09:38 +0100 Subject: [PATCH] refactor(source): define more types (#149) * define more types * lint fixes * update snapshot and reduce coverage * revert role change, since it incompatible with directus --- src/Components/AppShell/Content.tsx | 3 +- src/Components/AppShell/ContextWrapper.tsx | 4 +-- src/Components/Gaming/hooks/useQuests.tsx | 10 ++++-- src/Components/Input/SelectBox.tsx | 8 ++--- src/Components/Input/TextAreaInput.tsx | 20 +++++------ src/Components/Input/TextInput.tsx | 21 ++++++------ .../__snapshots__/TextInput.spec.tsx.snap | 6 ++-- src/Components/Map/hooks/useDebounce.tsx | 3 +- src/Components/Map/hooks/useLayers.tsx | 5 ++- src/Components/Map/hooks/usePermissions.tsx | 34 +++++++++++-------- vite.config.ts | 4 +-- 11 files changed, 58 insertions(+), 60 deletions(-) diff --git a/src/Components/AppShell/Content.tsx b/src/Components/AppShell/Content.tsx index 42dfbf5f..9adaf028 100644 --- a/src/Components/AppShell/Content.tsx +++ b/src/Components/AppShell/Content.tsx @@ -1,5 +1,4 @@ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ -type ContentProps = { +interface ContentProps { children?: React.ReactNode } diff --git a/src/Components/AppShell/ContextWrapper.tsx b/src/Components/AppShell/ContextWrapper.tsx index cde23c2d..ece603ad 100644 --- a/src/Components/AppShell/ContextWrapper.tsx +++ b/src/Components/AppShell/ContextWrapper.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { useContext, createContext } from 'react' import { BrowserRouter as Router, useLocation } from 'react-router-dom' @@ -19,8 +18,7 @@ import { AppStateProvider } from './hooks/useAppState' // Helper context to determine if the ContextWrapper is already present. const ContextCheckContext = createContext(false) -// eslint-disable-next-line react/prop-types -export const ContextWrapper = ({ children }) => { +export const ContextWrapper = ({ children }: { children: React.ReactNode }) => { const isWrapped = useContext(ContextCheckContext) // Check if we are already inside a Router diff --git a/src/Components/Gaming/hooks/useQuests.tsx b/src/Components/Gaming/hooks/useQuests.tsx index 336d7a8f..1b3cc1d4 100644 --- a/src/Components/Gaming/hooks/useQuests.tsx +++ b/src/Components/Gaming/hooks/useQuests.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/prop-types */ /* eslint-disable @typescript-eslint/no-empty-function */ import { useCallback, useState, createContext, useContext } from 'react' @@ -22,10 +21,15 @@ function useQuestsManager(initialOpen: boolean): { return { open, setQuestsOpen } } -export const QuestsProvider: React.FunctionComponent<{ +interface QuestProviderProps { initialOpen: boolean children?: React.ReactNode -}> = ({ initialOpen, children }) => ( +} + +export const QuestsProvider: React.FunctionComponent = ({ + initialOpen, + children, +}: QuestProviderProps) => ( {children} ) diff --git a/src/Components/Input/SelectBox.tsx b/src/Components/Input/SelectBox.tsx index c4d4282e..f91ed194 100644 --- a/src/Components/Input/SelectBox.tsx +++ b/src/Components/Input/SelectBox.tsx @@ -1,9 +1,7 @@ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon' import { useState } from 'react' -type SelectBoxProps = { +interface SelectBoxProps { labelTitle?: string labelStyle?: string type?: string @@ -40,9 +38,9 @@ export function SelectBox(props: SelectBoxProps) { } return ( -
+
{labelTitle ? ( -