Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS refactoring #434

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = {
rules: {
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
},
},

Expand Down
3 changes: 2 additions & 1 deletion frontend/__tests__/components/anchor-link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { fireEvent, render } from '@testing-library/react';

import { afterEach, describe, expect, it, vi } from 'vitest';

import { AnchorLink, type AnchorLinkProps } from '~/components/anchor-link';
import { AnchorLink } from '~/components/anchor-link';
import type { AnchorLinkProps } from '~/components/anchor-link';
import { scrollAndFocusFromAnchorLink } from '~/utils/link-utils';

vi.mock('~/utils/link-utils', () => ({
Expand Down
3 changes: 2 additions & 1 deletion frontend/__tests__/services/letters-service.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { setupServer } from 'msw/node';
import { afterAll, afterEach, beforeAll, describe, expect, expectTypeOf, it, vi } from 'vitest';

import { getLetterEntities } from '~/mocks/power-platform-api.server';
import { type LettersInfo, getLettersService } from '~/services/letters-service.server';
import { getLettersService } from '~/services/letters-service.server';
import type { LettersInfo } from '~/services/letters-service.server';

vi.mock('~/utils/logging.server', () => ({
getLogger: vi.fn().mockReturnValue({
Expand Down
3 changes: 2 additions & 1 deletion frontend/__tests__/services/wsaddress-service.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { HttpResponse, http } from 'msw';
import { setupServer } from 'msw/node';
import { afterAll, afterEach, beforeAll, describe, expectTypeOf, it, vi } from 'vitest';

import { type CorrectWSAddressResponseDTO, type ParseWSAddressResponseDTO, type ValidateWSAddressResponseDTO, getWSAddressService } from '~/services/wsaddress-service.server';
import { getWSAddressService } from '~/services/wsaddress-service.server';
import type { CorrectWSAddressResponseDTO, ParseWSAddressResponseDTO, ValidateWSAddressResponseDTO } from '~/services/wsaddress-service.server';

vi.mock('~/utils/logging.server', () => ({
getLogger: vi.fn().mockReturnValue({
Expand Down
85 changes: 0 additions & 85 deletions frontend/__tests__/types.d.test.ts

This file was deleted.

3 changes: 2 additions & 1 deletion frontend/__tests__/utils/route-utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { createRemixStub } from '@remix-run/testing';

import { describe, expect, it } from 'vitest';

import { type Breadcrumbs, type BuildInfo, coalesce, useBreadcrumbs, useBuildInfo, useI18nNamespaces, usePageIdentifier, usePageTitleI18nKey } from '~/utils/route-utils';
import { coalesce, useBreadcrumbs, useBuildInfo, useI18nNamespaces, usePageIdentifier, usePageTitleI18nKey } from '~/utils/route-utils';
import type { Breadcrumbs, BuildInfo, RouteHandleData } from '~/utils/route-utils';

describe('coalesce<T> reducer', () => {
it('expect undefined from two undefined values', () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ComponentProps, forwardRef } from 'react';
import { forwardRef } from 'react';
import type { ComponentProps } from 'react';

import { Link } from '@remix-run/react';

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/components/client-env.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ScriptProps } from '@remix-run/react/dist/components';
import type { ScriptProps } from '@remix-run/react/dist/components';

import { type PublicEnv } from '~/utils/env.server';
import type { PublicEnv } from '~/utils/env.server';

export type ClientEnvProps = ScriptProps & { env: PublicEnv };

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/input-checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode } from 'react';
import type { ReactNode } from 'react';

import { cn } from '~/utils/tw-utils';

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/input-radio.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode } from 'react';
import type { ReactNode } from 'react';

import { cn } from '~/utils/tw-utils';

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/input-select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ComponentProps, type ReactNode, forwardRef } from 'react';
import { forwardRef } from 'react';
import type { ComponentProps, ReactNode } from 'react';

import { InputError } from './input-error';
import { InputHelp } from './input-help';
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/components/language-switcher.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { type MouseEvent } from 'react';
import type { MouseEvent } from 'react';

import { useSearchParams } from '@remix-run/react';

import { useTranslation } from 'react-i18next';

import { InlineLink, type InlineLinkProps } from './inline-link';
import { InlineLink } from './inline-link';
import type { InlineLinkProps } from './inline-link';
import { getClientEnv } from '~/utils/env-utils';
import { getAltLanguage, switchLanguageCookie } from '~/utils/locale-utils';

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/nonce-context.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ReactNode, createContext } from 'react';
import { createContext } from 'react';
import type { ReactNode } from 'react';

import { randomBytes } from 'node:crypto';

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/session-timeout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useCallback, useEffect, useState } from 'react';
import { useNavigate } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
import { type IIdleTimerProps, useIdleTimer } from 'react-idle-timer';
import { useIdleTimer } from 'react-idle-timer';
import type { IIdleTimerProps } from 'react-idle-timer';

import { Button } from './buttons';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '~/components/dialog';
Expand Down
6 changes: 4 additions & 2 deletions frontend/app/components/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ComponentProps, forwardRef, useEffect } from 'react';
import { forwardRef, useEffect } from 'react';
import type { ComponentProps } from 'react';

import { AlertCircle as AlertCircleIcon, AlertTriangle as AlertTriangleIcon, CheckCircle2 as CheckCircle2Icon, XCircle as XCircleIcon } from 'lucide-react';
import { MaterialDesignContent, SnackbarProvider, enqueueSnackbar } from 'notistack';
import { useTranslation } from 'react-i18next';
import { type ToastMessage, setToastCookieOptions } from 'remix-toast';
import { setToastCookieOptions } from 'remix-toast';
import type { ToastMessage } from 'remix-toast';

import { useI18nNamespaces } from '~/utils/route-utils';
import { cn } from '~/utils/tw-utils';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EntryContext } from '@remix-run/node';
import { createReadableStreamFromReadable } from '@remix-run/node';
import type { EntryContext } from '@remix-run/node';
import { RemixServer } from '@remix-run/react';

import { isbot } from 'isbot';
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/mocks/power-platform-api.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jsonpatch, { type Operation } from 'fast-json-patch';
import jsonpatch from 'fast-json-patch';
import type { Operation } from 'fast-json-patch';
import { HttpResponse, http } from 'msw';
import { z } from 'zod';

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/mocks/raoidc.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpResponse, http } from 'msw';
import { privateKeyPemToCryptoKey, publicKeyPemToCryptoKey } from '~/utils/crypto-utils.server';
import { getEnv } from '~/utils/env.server';
import { getLogger } from '~/utils/logging.server';
import { type JWKSet, type ServerMetadata, type TokenEndpointResponse, type UserinfoResponse } from '~/utils/raoidc-utils.server';
import type { JWKSet, ServerMetadata, TokenEndpointResponse, UserinfoResponse } from '~/utils/raoidc-utils.server';

const log = getLogger('raoidc.server');

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Suspense, useContext } from 'react';

import { type LinksFunction, type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { LinksFunction, LoaderFunctionArgs } from '@remix-run/node';
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
1 change: 1 addition & 0 deletions frontend/app/routes/_gcweb-app.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Trans, useTranslation } from 'react-i18next';
import { InlineLink } from '~/components/inline-link';
import { PageTitle } from '~/components/page-title';
import { getTypedI18nNamespaces } from '~/utils/locale-utils';
import type { RouteHandleData } from '~/utils/route-utils';

const i18nNamespaces = getTypedI18nNamespaces('gcweb');

Expand Down
4 changes: 3 additions & 1 deletion frontend/app/routes/_gcweb-app._index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { ComponentProps, ReactNode } from 'react';

import { type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { LoaderFunctionArgs } from '@remix-run/node';
import { Link, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';

import { getRaoidcService } from '~/services/raoidc-service.server';
import { getUserService } from '~/services/user-service.server';
import { getTypedI18nNamespaces } from '~/utils/locale-utils';
import type { RouteHandleData } from '~/utils/route-utils';

const i18nNamespaces = getTypedI18nNamespaces('index');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type LoaderFunctionArgs } from '@remix-run/node';
import type { LoaderFunctionArgs } from '@remix-run/node';

import { getCCTService } from '~/services/cct-service.server';
import { getRaoidcService } from '~/services/raoidc-service.server';
Expand Down
7 changes: 5 additions & 2 deletions frontend/app/routes/_gcweb-app.letters._index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { type ChangeEvent, useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import type { ChangeEvent } from 'react';

import { type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { LoaderFunctionArgs } from '@remix-run/node';
import { Link, useLoaderData, useSearchParams } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand All @@ -11,6 +13,7 @@ import { getLettersService } from '~/services/letters-service.server';
import { getRaoidcService } from '~/services/raoidc-service.server';
import { getUserService } from '~/services/user-service.server';
import { getTypedI18nNamespaces } from '~/utils/locale-utils';
import type { RouteHandleData } from '~/utils/route-utils';

const i18nNamespaces = getTypedI18nNamespaces('letters');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';

import { type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { LoaderFunctionArgs } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand All @@ -12,6 +13,7 @@ import { getLookupService } from '~/services/lookup-service.server';
import { getRaoidcService } from '~/services/raoidc-service.server';
import { getUserService } from '~/services/user-service.server';
import { getNameByLanguage, getTypedI18nNamespaces } from '~/utils/locale-utils';
import type { RouteHandleData } from '~/utils/route-utils';

const i18nNamespaces = getTypedI18nNamespaces('personal-information');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, json, redirect } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';

import { type ActionFunctionArgs, type LoaderFunctionArgs, json, redirect } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand All @@ -9,15 +10,16 @@ import { z } from 'zod';
import { Button, ButtonLink } from '~/components/buttons';
import { ErrorSummary, createErrorSummaryItems, hasErrors, scrollAndFocusToErrorSummary } from '~/components/error-summary';
import { InputField } from '~/components/input-field';
import { type InputOptionProps } from '~/components/input-option';
import type { InputOptionProps } from '~/components/input-option';
import { InputSelect } from '~/components/input-select';
import { getAddressService } from '~/services/address-service.server';
import { type RegionInfo } from '~/services/lookup-service.server';
import { getLookupService } from '~/services/lookup-service.server';
import type { RegionInfo } from '~/services/lookup-service.server';
import { getRaoidcService } from '~/services/raoidc-service.server';
import { getSessionService } from '~/services/session-service.server';
import { getUserService } from '~/services/user-service.server';
import { getTypedI18nNamespaces } from '~/utils/locale-utils';
import type { RouteHandleData } from '~/utils/route-utils';

const i18nNamespaces = getTypedI18nNamespaces('personal-information', 'gcweb');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, json, redirect } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, json, redirect } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, json } from '@remix-run/node';
import { json } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { useTranslation } from 'react-i18next';
Expand Down
Loading