From 625c5c2b5b06cad0270aaac1b12b6976fced952f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20H=C3=A9on?= Date: Thu, 15 Aug 2024 13:48:13 -0400 Subject: [PATCH] fix: changes Array to T[] + Eslint rule for it (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Charles Héon --- frontend/.eslintrc.cjs | 1 + .../src/app/components/fieldHelperText/FieldHelperText.tsx | 4 ++-- frontend/src/app/components/table/Table.tsx | 2 +- frontend/src/app/components/tableRow/TableRow.tsx | 2 +- frontend/src/app/containers/cookieConsent/CookieConsent.tsx | 4 ++-- .../app/containers/cookieConsent/cookieConsent.config.ts | 2 +- .../containers/cookieConsent/cookieModal/CookieModal.tsx | 6 +++--- .../cookieConsent/interfaces/ICookiePreferences.ts | 2 +- .../containers/cookieConsent/interfaces/ICookieSection.ts | 4 ++-- frontend/src/app/forms/auth/loginForm/LoginForm.tsx | 2 +- frontend/src/app/routes/findRoute.ts | 4 ++-- 11 files changed, 17 insertions(+), 16 deletions(-) diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index e4d5533..dd4fa2d 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -32,6 +32,7 @@ module.exports = { "react-hooks/exhaustive-deps": WARNING, "react-hooks/rules-of-hooks": ERROR, eqeqeq: ERROR, + "@typescript-eslint/array-type": [WARNING, { default: "array-simple" }], // "sort-keys": WARNING, }, settings: { diff --git a/frontend/src/app/components/fieldHelperText/FieldHelperText.tsx b/frontend/src/app/components/fieldHelperText/FieldHelperText.tsx index 8bfb7f2..c4e8190 100644 --- a/frontend/src/app/components/fieldHelperText/FieldHelperText.tsx +++ b/frontend/src/app/components/fieldHelperText/FieldHelperText.tsx @@ -4,8 +4,8 @@ import { useTranslation } from "react-i18next"; import { ValidationError } from "yup"; interface IFormHelper { - fieldNames: Array | string; - formErrors?: Array; + fieldNames: string[] | string; + formErrors?: ValidationError[]; helperText?: string; } diff --git a/frontend/src/app/components/table/Table.tsx b/frontend/src/app/components/table/Table.tsx index 0964c54..bfb550e 100644 --- a/frontend/src/app/components/table/Table.tsx +++ b/frontend/src/app/components/table/Table.tsx @@ -9,7 +9,7 @@ import { } from "@mui/material"; interface ITable extends TableProps { - columnTitles: Array; + columnTitles: string[]; } export default function Table({ children, columnTitles, ...props }: ITable) { diff --git a/frontend/src/app/components/tableRow/TableRow.tsx b/frontend/src/app/components/tableRow/TableRow.tsx index 600372c..1325809 100644 --- a/frontend/src/app/components/tableRow/TableRow.tsx +++ b/frontend/src/app/components/tableRow/TableRow.tsx @@ -7,7 +7,7 @@ import { import style from "@styles/style.module.scss"; interface ITableRow extends TableRowProps { - columns: Array; + columns: string[]; } const StyledMuiTableRow = styled(MuiTableRow)({ diff --git a/frontend/src/app/containers/cookieConsent/CookieConsent.tsx b/frontend/src/app/containers/cookieConsent/CookieConsent.tsx index c7aa598..b8633bf 100644 --- a/frontend/src/app/containers/cookieConsent/CookieConsent.tsx +++ b/frontend/src/app/containers/cookieConsent/CookieConsent.tsx @@ -15,9 +15,9 @@ export default function CookieConsent() { const [cookieModalOpen, setCookieModalOpen] = useState(false); const [cookieBannerOpen, setCookieBannerOpen] = useState(false); const [cookiePreferences, setCookiePreferences] = - useState>(ALL_COOKIE_TYPES); + useState(ALL_COOKIE_TYPES); - const handleAccept = useCallback((preferences: Array) => { + const handleAccept = useCallback((preferences: string[]) => { setCookieBannerOpen(false); setCookieModalOpen(false); const cookieConsentPreferences: ICookiePreferences = { diff --git a/frontend/src/app/containers/cookieConsent/cookieConsent.config.ts b/frontend/src/app/containers/cookieConsent/cookieConsent.config.ts index c1242f4..a7fb3c8 100644 --- a/frontend/src/app/containers/cookieConsent/cookieConsent.config.ts +++ b/frontend/src/app/containers/cookieConsent/cookieConsent.config.ts @@ -1,6 +1,6 @@ import ICookieSection from "@containers/cookieConsent/interfaces/ICookieSection"; -const cookieConsentConfig: Array = [ +const cookieConsentConfig: ICookieSection[] = [ { id: "necessary", title: "cookie_modal__necessary_title", diff --git a/frontend/src/app/containers/cookieConsent/cookieModal/CookieModal.tsx b/frontend/src/app/containers/cookieConsent/cookieModal/CookieModal.tsx index 2c071ac..201c5d6 100644 --- a/frontend/src/app/containers/cookieConsent/cookieModal/CookieModal.tsx +++ b/frontend/src/app/containers/cookieConsent/cookieModal/CookieModal.tsx @@ -25,9 +25,9 @@ interface ICookieModal { handleAcceptAll: () => void; handleAcceptSelection: () => void; closeModal: () => void; - cookieTypes: Array; - cookiePreferences: Array; - setCookiePreferences: Dispatch>>; + cookieTypes: ICookieSection[]; + cookiePreferences: string[]; + setCookiePreferences: Dispatch>; } export default function CookieModal({ diff --git a/frontend/src/app/containers/cookieConsent/interfaces/ICookiePreferences.ts b/frontend/src/app/containers/cookieConsent/interfaces/ICookiePreferences.ts index 92105b0..a0f1890 100644 --- a/frontend/src/app/containers/cookieConsent/interfaces/ICookiePreferences.ts +++ b/frontend/src/app/containers/cookieConsent/interfaces/ICookiePreferences.ts @@ -1,4 +1,4 @@ export default interface ICookiePreferences { consentDate: number; - preferences: Array; + preferences: string[]; } diff --git a/frontend/src/app/containers/cookieConsent/interfaces/ICookieSection.ts b/frontend/src/app/containers/cookieConsent/interfaces/ICookieSection.ts index af983f9..2d30f94 100644 --- a/frontend/src/app/containers/cookieConsent/interfaces/ICookieSection.ts +++ b/frontend/src/app/containers/cookieConsent/interfaces/ICookieSection.ts @@ -3,7 +3,7 @@ import ICookieInfo from "@containers/cookieConsent/interfaces/ICookieInfo"; export default interface ICookieSection { id: string; title: string; - description: Array; + description: string[]; required?: boolean; - cookies?: Array; + cookies?: ICookieInfo[]; } diff --git a/frontend/src/app/forms/auth/loginForm/LoginForm.tsx b/frontend/src/app/forms/auth/loginForm/LoginForm.tsx index 918536c..c088a0c 100644 --- a/frontend/src/app/forms/auth/loginForm/LoginForm.tsx +++ b/frontend/src/app/forms/auth/loginForm/LoginForm.tsx @@ -32,7 +32,7 @@ export default function LoginForm({ setIsLoading }: ILoginForm) { password: "", }); const [loginFormValidated, setLoginFormValidated] = useState(false); - const [formErrors, setFormErrors] = useState>([]); + const [formErrors, setFormErrors] = useState([]); const onSubmit = useCallback( (event: FormEvent) => { diff --git a/frontend/src/app/routes/findRoute.ts b/frontend/src/app/routes/findRoute.ts index 959aea1..7857de3 100644 --- a/frontend/src/app/routes/findRoute.ts +++ b/frontend/src/app/routes/findRoute.ts @@ -1,8 +1,8 @@ import routes from "@routes/routes"; const findRoute = (path: string, locale: string): string => { - let segmentValues: Array = []; - let segmentNames: Array = []; + let segmentValues: string[] = []; + let segmentNames: string[] = []; const route = routes.find((route) => { return Object.values(route.paths).some((pattern) => {