diff --git a/.prettierrc b/.prettierrc index 4e6236837..1bf6f85af 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,7 +3,13 @@ "tabWidth": 2, "singleQuote": true, "quoteProps": "consistent", - "importOrder": ["^react$", "^@testing-library/(.*)$", "", "^[./]"], + "importOrder": [ + "^react$", + "^@testing-library/(.*)$", + "", + "^[./]" + ], "importOrderSeparation": true, - "importOrderSortSpecifiers": true -} \ No newline at end of file + "importOrderSortSpecifiers": true, + "plugins": ["@trivago/prettier-plugin-sort-imports"] +} diff --git a/__tests__/components/DateSelectField.test.tsx b/__tests__/components/DateSelectField.test.tsx index afd1cb5cd..e46fc6de7 100644 --- a/__tests__/components/DateSelectField.test.tsx +++ b/__tests__/components/DateSelectField.test.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - import '@testing-library/jest-dom/extend-expect' import { render, screen } from '@testing-library/react' @@ -10,7 +8,7 @@ import DateSelectField from '../../src/components/DateSelectField' expect.extend(toHaveNoViolations) -const DateSelectMock: FC = ({ label }: DateSelectProps) => { +const DateSelectMock = ({ label }: DateSelectProps) => { return
{label}
} diff --git a/__tests__/components/IdleTimeout.test.tsx b/__tests__/components/IdleTimeout.test.tsx index fe8e5991e..813e76fc8 100644 --- a/__tests__/components/IdleTimeout.test.tsx +++ b/__tests__/components/IdleTimeout.test.tsx @@ -1,12 +1,10 @@ -import { FC } from 'react' - import '@testing-library/jest-dom/extend-expect' import { render, screen, waitFor } from '@testing-library/react' import IdleTimeout from '../../src/components/IdleTimeout' import { ModalProps } from '../../src/components/Modal' -const ModalMock: FC = ({ open }: ModalProps) => { +const ModalMock = ({ open }: ModalProps) => { return
{open ? 'modal-opened' : 'modal-closed'}
} @@ -31,7 +29,7 @@ describe('IdleTimeout', () => { expect(modal).toBeInTheDocument() expect(modal.textContent).toMatch('modal-opened') }, - { timeout: 3000 } + { timeout: 3000 }, ) }) }) diff --git a/src/components/ActionButton.tsx b/src/components/ActionButton.tsx index fb051cbfb..102cdedf6 100644 --- a/src/components/ActionButton.tsx +++ b/src/components/ActionButton.tsx @@ -1,4 +1,4 @@ -import { FC, MouseEventHandler } from 'react' +import { MouseEventHandler } from 'react' export type ActionButtonSize = 'xs' | 'sm' | 'md' | 'lg' @@ -29,7 +29,7 @@ const styles = { 'border-blue-dark bg-blue-dark text-basic-white hover:bg-blue-normal active:bg-blue-active focus:bg-blue-normal focus:text-basic-white', } -const ActionButton: FC = ({ +const ActionButton = ({ disabled, fullWidth, id, @@ -38,7 +38,7 @@ const ActionButton: FC = ({ style, text, type, -}) => { +}: ActionButtonProps) => { const baseClasses = 'align-middle border font-display inline-flex items-center justify-center shadow-sm disabled:cursor-not-allowed disabled:opacity-70 disabled:pointer-events-none disabled:shadow-none focus:ring-1 focus:ring-black focus:ring-offset-2' const fullWidthClasses = fullWidth ? 'w-full' : undefined diff --git a/src/components/AlertBlock.tsx b/src/components/AlertBlock.tsx index 4c474ba95..c2cad9380 100644 --- a/src/components/AlertBlock.tsx +++ b/src/components/AlertBlock.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - import { useTranslation } from 'next-i18next' import { AlertPage } from '../lib/types' @@ -12,7 +10,7 @@ export interface AlertBlockProps { className?: string } -const AlertBlock: FC = ({ page, className }) => { +const AlertBlock = ({ page, className }: AlertBlockProps) => { const { data } = useAlerts({ page }) const { i18n } = useTranslation() diff --git a/src/components/AlertSection.tsx b/src/components/AlertSection.tsx index 6d01051c4..cbd6284bf 100644 --- a/src/components/AlertSection.tsx +++ b/src/components/AlertSection.tsx @@ -1,8 +1,8 @@ -import { FC, PropsWithChildren } from 'react' +import { PropsWithChildren } from 'react' import { AlertType } from '../lib/types' -export interface AlertSectionProps { +export interface AlertSectionProps extends PropsWithChildren { type: AlertType className?: string } @@ -72,11 +72,7 @@ const svg = (type: AlertType) => { } } -const AlertSection: FC> = ({ - children, - type, - className, -}) => { +const AlertSection = ({ children, type, className }: AlertSectionProps) => { const borderColor = borderColors[type] return ( diff --git a/src/components/ApplicationNameBar.tsx b/src/components/ApplicationNameBar.tsx index 6976b704f..401faf691 100644 --- a/src/components/ApplicationNameBar.tsx +++ b/src/components/ApplicationNameBar.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - import Link from 'next/link' export interface ApplicationNameBarProps { @@ -7,7 +5,7 @@ export interface ApplicationNameBarProps { href: string } -const ApplicationNameBar: FC = ({ text, href }) => { +const ApplicationNameBar = ({ text, href }: ApplicationNameBarProps) => { return (
diff --git a/src/components/Banner.tsx b/src/components/Banner.tsx index 5826f6e6b..44c6cd018 100644 --- a/src/components/Banner.tsx +++ b/src/components/Banner.tsx @@ -1,11 +1,9 @@ -import { FC } from 'react' - export interface BannerProps { alert: string description: string } -const Banner: FC = ({ alert, description }) => { +const Banner = ({ alert, description }: BannerProps) => { return (
diff --git a/src/components/CheckStatusInfo.tsx b/src/components/CheckStatusInfo.tsx index 0d5a204d4..9fbcc18ee 100644 --- a/src/components/CheckStatusInfo.tsx +++ b/src/components/CheckStatusInfo.tsx @@ -1,7 +1,6 @@ -import { FC, MouseEventHandler } from 'react' +import { MouseEventHandler } from 'react' -import { CheckStatusApiResponse } from '../lib/types' -import { StatusCode } from '../lib/types' +import { CheckStatusApiResponse, StatusCode } from '../lib/types' import ActionButton, { ActionButtonStyle } from './ActionButton' import CheckStatusFileBeingProcessed from './check-status-responses/CheckStatusFileBeingProcessed' import CheckStatusNoRecord from './check-status-responses/CheckStatusNoRecord' @@ -18,13 +17,13 @@ export interface CheckStatusInfoProps { checkStatusResponse?: CheckStatusApiResponse | null } -export const CheckStatusInfo: FC = ({ +export const CheckStatusInfo = ({ goBackText, id, onGoBackClick, goBackStyle, checkStatusResponse, -}) => { +}: CheckStatusInfoProps) => { //Determine which status response to render let statusComponent switch (checkStatusResponse?.status) { diff --git a/src/components/Collapse.tsx b/src/components/Collapse.tsx index 3c755102b..d8391121b 100644 --- a/src/components/Collapse.tsx +++ b/src/components/Collapse.tsx @@ -1,11 +1,11 @@ -import { FC, useId } from 'react' +import { useId } from 'react' export interface CollapseProps { title: string children?: React.ReactNode } -const Collapse: FC = ({ title, children }) => { +const Collapse = ({ title, children }: CollapseProps) => { const id = useId() return (
= ({ id, text }) => { +const DateModified = ({ id, text }: DateModifiedProps) => { return (
{text}
diff --git a/src/components/DateSelect.tsx b/src/components/DateSelect.tsx index e7842c86c..adc22f5ac 100644 --- a/src/components/DateSelect.tsx +++ b/src/components/DateSelect.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - export interface DateSelectOption { value: string label: string @@ -9,7 +7,7 @@ export type DateSelectType = 'year' | 'month' | 'day' export type DateSelectOnChangeEvent = ( e: React.ChangeEvent, - type: DateSelectType + type: DateSelectType, ) => void export interface DateSelectProps { @@ -25,7 +23,7 @@ export interface DateSelectProps { value: string } -const DateSelect: FC = ({ +const DateSelect = ({ ariaDescribedby, dateSelectLabelId, error, @@ -36,9 +34,9 @@ const DateSelect: FC = ({ required, type, value, -}) => { +}: DateSelectProps) => { const handleOnSelectChange: React.ChangeEventHandler = ( - e + e, ) => onChange(e, type) return ( diff --git a/src/components/DateSelectField.tsx b/src/components/DateSelectField.tsx index 719fa980c..6e06877f7 100644 --- a/src/components/DateSelectField.tsx +++ b/src/components/DateSelectField.tsx @@ -1,4 +1,4 @@ -import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { getDaysInMonth, isExists } from 'date-fns' import { useTranslation } from 'next-i18next' @@ -32,7 +32,7 @@ interface DateSelectState { yearValue: string } -const DateSelectField: FC = ({ +const DateSelectField = ({ errorMessage, firstYear, helpMessage, @@ -43,7 +43,7 @@ const DateSelectField: FC = ({ required, textRequired, value, -}) => { +}: DateSelectFieldProps) => { const { t } = useTranslation() const [state, setState] = useState( @@ -53,7 +53,7 @@ const DateSelectField: FC = ({ monthValue: '', yearValue: '', changeCount: 0, // HACK: Use this state as a dependency of the `useEffect` below so that `onChange` is called only when it should be. - } + }, ) const dateSelectErrorMessageId = `date-select-${id}-error` @@ -126,7 +126,7 @@ const DateSelectField: FC = ({ } }) }, - [] + [], ) // Sync from the state to the upper component through onChange when necessary. @@ -239,7 +239,7 @@ const padZero = (value: number, maxLength: number): string => { } const parseDateString = ( - dateString: string + dateString: string, ): { year: string month: string diff --git a/src/components/ErrorLayout.tsx b/src/components/ErrorLayout.tsx index 21573c113..f9c03ebdd 100644 --- a/src/components/ErrorLayout.tsx +++ b/src/components/ErrorLayout.tsx @@ -1,12 +1,10 @@ -import { FC } from 'react' +import { PropsWithChildren } from 'react' import Image from 'next/image' -export interface ErrorLayoutProps { - children?: React.ReactNode -} +export interface ErrorLayoutProps extends PropsWithChildren {} -const ErrorLayout: FC = ({ children }) => { +const ErrorLayout = ({ children }: ErrorLayoutProps) => { return (
diff --git a/src/components/ErrorSummary.tsx b/src/components/ErrorSummary.tsx index 17066d1d3..df7c8d764 100644 --- a/src/components/ErrorSummary.tsx +++ b/src/components/ErrorSummary.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect } from 'react' +import { useEffect } from 'react' import { FormikErrors, FormikValues } from 'formik' import { Namespace, TFunction } from 'i18next' @@ -16,7 +16,7 @@ export interface ErrorSummaryProps { export const getErrorSummaryItem = ( feildId: string, - errorMessage: string + errorMessage: string, ): ErrorSummaryItem => ({ feildId, errorMessage, @@ -24,7 +24,7 @@ export const getErrorSummaryItem = ( export const getErrorSummaryItems = ( formErrors: FormikErrors, - t: TFunction + t: TFunction, ) => { return Object.keys(formErrors) .filter((key) => !!formErrors[key]) @@ -33,13 +33,13 @@ export const getErrorSummaryItems = ( export const goToErrorSummary = (errorSummaryId: string) => { const errorSummaryEl = document.querySelector( - `#${errorSummaryId}` + `#${errorSummaryId}`, ) errorSummaryEl?.scrollIntoView({ behavior: 'smooth', block: 'center' }) errorSummaryEl?.focus() } -const ErrorSummary: FC = ({ id, errors, summary }) => { +const ErrorSummary = ({ id, errors, summary }: ErrorSummaryProps) => { useEffect(() => { goToErrorSummary(id) }, [id]) diff --git a/src/components/ExampleImage.tsx b/src/components/ExampleImage.tsx index 2730f5832..6fea22ee1 100644 --- a/src/components/ExampleImage.tsx +++ b/src/components/ExampleImage.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react' +import { PropsWithChildren } from 'react' import Image from 'next/image' @@ -14,11 +14,7 @@ export interface ExampleImageProps extends PropsWithChildren { imageProps: ImageProps } -const ExampleImage: FC = ({ - children, - title, - imageProps, -}) => { +const ExampleImage = ({ children, title, imageProps }: ExampleImageProps) => { return ( <> {title && ( diff --git a/src/components/ExternalLink.tsx b/src/components/ExternalLink.tsx index eb819ef66..a5aae6cbb 100644 --- a/src/components/ExternalLink.tsx +++ b/src/components/ExternalLink.tsx @@ -1,7 +1,6 @@ import { AnchorHTMLAttributes, DetailedHTMLProps, - FC, PropsWithChildren, } from 'react' @@ -16,11 +15,11 @@ export interface ExternalLinkProps href: string } -export const ExternalLink: FC = ({ +export const ExternalLink = ({ children, href, ...rest -}) => { +}: ExternalLinkProps) => { const { t } = useTranslation(['common']) return ( diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 4694cea84..920411824 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - import Image from 'next/image' import DateModified from './DateModified' @@ -43,7 +41,7 @@ export interface FooterProps { /** * footer element for all pages */ -const Footer: FC = ({ +const Footer = ({ dateModifiedText, footerHeader, footerLogo, diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 639835f5d..8b8bf0129 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,5 +1,3 @@ -import React, { FC } from 'react' - import { useTranslation } from 'next-i18next' import getConfig from 'next/config' import Image from 'next/image' @@ -14,7 +12,7 @@ export interface HeaderProps { skipToMainText: string } -const Header: FC = ({ gocLink, skipToMainText }) => { +const Header = ({ gocLink, skipToMainText }: HeaderProps) => { const config = getConfig() const { locale, asPath } = useRouter() const { t } = useTranslation('common') diff --git a/src/components/IdleTimeout.tsx b/src/components/IdleTimeout.tsx index 522764b06..b9230c477 100644 --- a/src/components/IdleTimeout.tsx +++ b/src/components/IdleTimeout.tsx @@ -1,4 +1,4 @@ -import { FC, useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { deleteCookie } from 'cookies-next' import { useTranslation } from 'next-i18next' @@ -11,7 +11,7 @@ export interface IdleTimeoutProps extends Pick, Pick {} -const IdleTimeout: FC = ({ promptBeforeIdle, timeout }) => { +const IdleTimeout = ({ promptBeforeIdle, timeout }: IdleTimeoutProps) => { const { t } = useTranslation('common') const router = useRouter() const [modalOpen, setModalOpen] = useState(false) @@ -38,7 +38,7 @@ const IdleTimeout: FC = ({ promptBeforeIdle, timeout }) => { const minutes = Math.floor(getRemainingTime() / 60000) const seconds = Math.floor((getRemainingTime() / 1000) % 60).toFixed(0) setTimeRemaining( - minutes + ':' + (parseInt(seconds) < 10 ? '0' : '') + seconds + minutes + ':' + (parseInt(seconds) < 10 ? '0' : '') + seconds, ) }, [getRemainingTime]) diff --git a/src/components/InputErrorMessage.tsx b/src/components/InputErrorMessage.tsx index 1501c07af..9ae70337a 100644 --- a/src/components/InputErrorMessage.tsx +++ b/src/components/InputErrorMessage.tsx @@ -1,11 +1,9 @@ -import { FC } from 'react' - export interface InputErrorMessageProps { id?: string message: string } -const InputErrorMessage: FC = ({ id, message }) => { +const InputErrorMessage = ({ id, message }: InputErrorMessageProps) => { return (
} -const InputField: FC = ({ +const InputField = ({ id, label, name, @@ -29,7 +27,7 @@ const InputField: FC = ({ value, max, helpMessage, -}) => { +}: InputFieldProps) => { const inputErrorMessageId = `input-${id}-error` const inputHelpMessageId = `input-${id}-help` const inputWrapperId = `input-${id}` diff --git a/src/components/InputLabel.tsx b/src/components/InputLabel.tsx index 31577191b..674b99312 100644 --- a/src/components/InputLabel.tsx +++ b/src/components/InputLabel.tsx @@ -1,5 +1,3 @@ -import { FC } from 'react' - export interface InputLabelProps { htmlFor?: string id: string @@ -8,13 +6,13 @@ export interface InputLabelProps { textRequired?: string } -const InputLabel: FC = ({ +const InputLabel = ({ htmlFor, id, label, required, textRequired, -}) => { +}: InputLabelProps) => { return (