diff --git a/e2e/global.setup.ts b/e2e/global.setup.ts index 343921f..b85a632 100644 --- a/e2e/global.setup.ts +++ b/e2e/global.setup.ts @@ -2,8 +2,8 @@ import { test as setup } from '@playwright/test' import fs from 'fs' import { ADMIN_AUTH_FILE, USER_AUTH_FILE } from './tests/constants' -import LoginPage from './tests/pages/login.page' -import SettingsPage from './tests/pages/settings.page' +import { LoginPage } from './tests/pages/login.page' +import { SettingsPage } from './tests/pages/settings.page' setup('authenticate as user', async ({ page, request }) => { if (fs.existsSync(USER_AUTH_FILE)) { diff --git a/e2e/tests/fixtures.ts b/e2e/tests/fixtures.ts index a14a17c..dc8f109 100644 --- a/e2e/tests/fixtures.ts +++ b/e2e/tests/fixtures.ts @@ -1,8 +1,8 @@ import { test as base } from '@playwright/test' -import BookPage from './pages/book.page' -import CatalogPage from './pages/catalog.page' -import SettingsPage from './pages/settings.page' +import { BookPage } from './pages/book.page' +import { CatalogPage } from './pages/catalog.page' +import { SettingsPage } from './pages/settings.page' export * from '@playwright/test' diff --git a/e2e/tests/helpers/prisma.ts b/e2e/tests/helpers/prisma.ts deleted file mode 100644 index 4590932..0000000 --- a/e2e/tests/helpers/prisma.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { PrismaClient } from '@prisma/client' - -const prisma = new PrismaClient() - -export default prisma diff --git a/e2e/tests/helpers/ulid.ts b/e2e/tests/helpers/ulid.ts deleted file mode 100644 index 52196e4..0000000 --- a/e2e/tests/helpers/ulid.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ulid as base } from 'ulid' - -export function ulid(index: number) { - return base().slice(0, 14) + suffix(index) -} - -export function suffix(index: number) { - return 'WORKER' + String(index).padStart(4, '0') -} - -export default ulid diff --git a/e2e/tests/pages/book.page.ts b/e2e/tests/pages/book.page.ts index 6739aa0..b351c3d 100644 --- a/e2e/tests/pages/book.page.ts +++ b/e2e/tests/pages/book.page.ts @@ -1,9 +1,9 @@ import { Page } from '@playwright/test' import { ulid } from 'ulid' -import prisma from '../helpers/prisma' +import { prisma } from '@/lib/prisma/prisma' -class BookPage { +export class BookPage { constructor(private readonly page: Page) {} async goto(id?: string) { @@ -63,5 +63,3 @@ class BookPage { await prisma.book.deleteMany({ where: { id: { in: ids } } }) } } - -export default BookPage diff --git a/e2e/tests/pages/catalog.page.ts b/e2e/tests/pages/catalog.page.ts index 7ecd50f..a76717e 100644 --- a/e2e/tests/pages/catalog.page.ts +++ b/e2e/tests/pages/catalog.page.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test' -class CatalogPage { +export class CatalogPage { constructor(private readonly page: Page) {} async goto() { @@ -27,5 +27,3 @@ class CatalogPage { .waitFor({ state: 'visible' }) } } - -export default CatalogPage diff --git a/e2e/tests/pages/login.page.ts b/e2e/tests/pages/login.page.ts index e498ee6..2a3a4e0 100644 --- a/e2e/tests/pages/login.page.ts +++ b/e2e/tests/pages/login.page.ts @@ -1,6 +1,6 @@ import { Page } from '@playwright/test' -class LoginPage { +export class LoginPage { constructor(private readonly page: Page) {} async goto() { @@ -28,5 +28,3 @@ class LoginPage { return webMailPage } } - -export default LoginPage diff --git a/e2e/tests/pages/settings.page.ts b/e2e/tests/pages/settings.page.ts index 84cc8cb..6333b28 100644 --- a/e2e/tests/pages/settings.page.ts +++ b/e2e/tests/pages/settings.page.ts @@ -1,10 +1,9 @@ import { Page } from '@playwright/test' -import gravatar from '@/lib/utils/gravatar' +import { prisma } from '@/lib/prisma/prisma' +import { gravatar } from '@/lib/utils/gravatar' -import prisma from '../helpers/prisma' - -class SettingsPage { +export class SettingsPage { constructor(private readonly page: Page) {} async goto() { @@ -47,5 +46,3 @@ class SettingsPage { }) } } - -export default SettingsPage diff --git a/package.json b/package.json index eb5b9ab..29f4cf2 100644 --- a/package.json +++ b/package.json @@ -160,6 +160,7 @@ "eqeqeq": "error", "import/first": "error", "import/newline-after-import": "error", + "import/no-default-export": "error", "import/no-duplicates": "error", "no-shadow": "off", "simple-import-sort/exports": "error", @@ -171,6 +172,20 @@ "unicorn/no-useless-undefined": "off", "unicorn/prefer-node-protocol": "off", "unused-imports/no-unused-imports": "error" - } + }, + "overrides": [ + { + "files": [ + "./src/app/**/*.{tsx,ts,js,jsx}", + "./stories/**/*.{tsx,ts,js,jsx}" + ], + "excludedFiles": [ + "./src/app/**/{actions,components}/*.{tsx,ts,js,jsx}" + ], + "rules": { + "import/no-default-export": "off" + } + } + ] } } diff --git a/src/app/(auth)/signin/_components/sign-in-email-form/actions.ts b/src/app/(auth)/actions/sign-in-action.ts similarity index 92% rename from src/app/(auth)/signin/_components/sign-in-email-form/actions.ts rename to src/app/(auth)/actions/sign-in-action.ts index e96c22e..9ad07d4 100644 --- a/src/app/(auth)/signin/_components/sign-in-email-form/actions.ts +++ b/src/app/(auth)/actions/sign-in-action.ts @@ -3,7 +3,7 @@ import { z } from 'zod' import { signIn } from '@/lib/auth/auth' -import FormResponse from '@/lib/zod/form-response' +import { FormResponse } from '@/lib/zod/form-response' export interface SignInForm { email?: string diff --git a/src/app/(auth)/signout/_components/sign-out-form/actions.ts b/src/app/(auth)/actions/sign-out-action.ts similarity index 100% rename from src/app/(auth)/signout/_components/sign-out-form/actions.ts rename to src/app/(auth)/actions/sign-out-action.ts diff --git a/src/app/(auth)/_components/auth-card/auth-card-footer.tsx b/src/app/(auth)/components/auth-card-footer.tsx similarity index 83% rename from src/app/(auth)/_components/auth-card/auth-card-footer.tsx rename to src/app/(auth)/components/auth-card-footer.tsx index 217fb39..e8e1d67 100644 --- a/src/app/(auth)/_components/auth-card/auth-card-footer.tsx +++ b/src/app/(auth)/components/auth-card-footer.tsx @@ -9,7 +9,7 @@ function useController(properties: AuthModalFooterProperties) { return { ...properties } } -export default function AuthCardFooter(properties: AuthModalFooterProperties) { +export function AuthCardFooter(properties: AuthModalFooterProperties) { const { children } = useController(properties) return ( diff --git a/src/app/(auth)/_components/auth-card/auth-card-header.tsx b/src/app/(auth)/components/auth-card-header.tsx similarity index 87% rename from src/app/(auth)/_components/auth-card/auth-card-header.tsx rename to src/app/(auth)/components/auth-card-header.tsx index 4d011b7..1eae483 100644 --- a/src/app/(auth)/_components/auth-card/auth-card-header.tsx +++ b/src/app/(auth)/components/auth-card-header.tsx @@ -6,7 +6,7 @@ interface AuthModalHeaderProperties { title: string } -export default function AuthCardHeader(properties: AuthModalHeaderProperties) { +export function AuthCardHeader(properties: AuthModalHeaderProperties) { const { children, title } = { ...properties } return ( diff --git a/src/app/(auth)/_components/auth-card/auth-card.tsx b/src/app/(auth)/components/auth-card.tsx similarity index 84% rename from src/app/(auth)/_components/auth-card/auth-card.tsx rename to src/app/(auth)/components/auth-card.tsx index 357b880..a708e42 100644 --- a/src/app/(auth)/_components/auth-card/auth-card.tsx +++ b/src/app/(auth)/components/auth-card.tsx @@ -1,13 +1,13 @@ import { Card, CardHeader } from '@nextui-org/react' import React, { ReactNode } from 'react' -import ThemeImage from '@/components/theme-image/theme-image' +import { ThemeImage } from '@/components/image/theme-image' interface AuthModalProperties { children: ReactNode } -export default function AuthCard(properties: AuthModalProperties) { +export function AuthCard(properties: AuthModalProperties) { const { children } = { ...properties } return ( <> diff --git a/src/app/(auth)/signin/_components/sign-in-email-form/sign-in-email-form.tsx b/src/app/(auth)/components/sign-in-email-form.tsx similarity index 82% rename from src/app/(auth)/signin/_components/sign-in-email-form/sign-in-email-form.tsx rename to src/app/(auth)/components/sign-in-email-form.tsx index b85754d..49f9e42 100644 --- a/src/app/(auth)/signin/_components/sign-in-email-form/sign-in-email-form.tsx +++ b/src/app/(auth)/components/sign-in-email-form.tsx @@ -5,11 +5,11 @@ import { Button } from '@nextui-org/react' import React from 'react' import { useFormState } from 'react-dom' -import { signInAction } from '@/app/(auth)/signin/_components/sign-in-email-form/actions' -import InputForm from '@/components/input-form/input-form' -import FormResponse from '@/lib/zod/form-response' +import { signInAction } from '@/app/(auth)/actions/sign-in-action' +import { InputForm } from '@/components/form/input-form' +import { FormResponse } from '@/lib/zod/form-response' -export default function SignInEmailForm() { +export function SignInEmailForm() { const [state, action] = useFormState( signInAction, FormResponse.initialState({ diff --git a/src/app/(auth)/signout/_components/sign-out-form/sign-out-form.tsx b/src/app/(auth)/components/sign-out-form.tsx similarity index 80% rename from src/app/(auth)/signout/_components/sign-out-form/sign-out-form.tsx rename to src/app/(auth)/components/sign-out-form.tsx index 6b60f9b..114e2d1 100644 --- a/src/app/(auth)/signout/_components/sign-out-form/sign-out-form.tsx +++ b/src/app/(auth)/components/sign-out-form.tsx @@ -4,9 +4,9 @@ import { ArrowRightStartOnRectangleIcon } from '@heroicons/react/24/outline' import { Button } from '@nextui-org/react' import React from 'react' -import { signOutAction } from '@/app/(auth)/signout/_components/sign-out-form/actions' +import { signOutAction } from '@/app/(auth)/actions/sign-out-action' -export default function SignOutForm() { +export function SignOutForm() { return (