diff --git a/.eslintignore b/.eslintignore index 7f87bd5b..8b8ee1e3 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ **/*.test.ts **/*.test.tsx **/*.test.js -**/*.test.jsx \ No newline at end of file +**/*.test.jsx +next-env.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index f20f5dc3..9b8ab8a6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -135,6 +135,19 @@ "rules": { "no-unused-vars": "off" } + }, + { + "files": ["playwright.config.ts"], + "rules": { + "no-undefined": "off" + } + }, + { + "files": ["functions/userAuth.js"], + "rules": { + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-var-requires": "off" + } } ] -} \ No newline at end of file +} diff --git a/context/AuthContextProvider.tsx b/context/AuthContextProvider.tsx index 18cfd4c5..78b4ee7d 100644 --- a/context/AuthContextProvider.tsx +++ b/context/AuthContextProvider.tsx @@ -11,6 +11,7 @@ import type { DataStore } from '@/store/dataStore'; import { IUser } from '@/api/apiFunctions.interface'; import { getCurrentUser } from '@/api/apiFunctions'; import { loginAccount } from './AuthHelper'; +import { usePathname } from 'next/navigation'; type UserCredentials = { email: string; @@ -43,6 +44,7 @@ export const AuthContextProvider = ({ (state) => state, ); const router = useRouter(); + const pathname = usePathname(); useEffect(() => { if (user.id === '' || user.email === '') { @@ -87,7 +89,9 @@ export const AuthContextProvider = ({ */ const getUser = async (): Promise => { if (!isSessionInLocalStorage()) { - router.push('/login'); + if (pathname !== '/register') { + router.push('/login'); + } return; } diff --git a/jest.setup.js b/jest.setup.js index 7b0828bf..cd6191a1 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1 +1,4 @@ +// Copyright (c) Gridiron Survivor. +// Licensed under the MIT License. + import '@testing-library/jest-dom'; diff --git a/middleware.ts b/middleware.ts index 812863a2..47eb3880 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,6 +1,14 @@ +// Copyright (c) Gridiron Survivor. +// Licensed under the MIT License. + import { NextResponse, type NextRequest } from 'next/server' -export async function middleware(request: NextRequest) { +/** + * Checks if the request is a POST request and if so, returns the response object + * @param request - The request object + * @returns {NextResponse} - The response object + */ +export async function middleware(request: NextRequest): Promise { try { return NextResponse.next({ request: { diff --git a/next.config.js b/next.config.js index 23b8fe40..faeb7f39 100644 --- a/next.config.js +++ b/next.config.js @@ -20,4 +20,8 @@ module.exports = { images: { domains: ['a.espncdn.com'], }, -} \ No newline at end of file + eslint: { + ignoreDuringBuilds: false, + dirs: ["."], + } +} diff --git a/package.json b/package.json index ea37daf4..afbf208a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "storybook-docs": "storybook dev --docs", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", - "lint": "next lint --quiet" + "lint": "npx next lint --dir ." }, "dependencies": { "@hookform/resolvers": "^3.3.4", diff --git a/playwright.config.ts b/playwright.config.ts index b27035c9..0887b801 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,7 +1,13 @@ +// Copyright (c) Gridiron Survivor. +// Licensed under the MIT License. + import { defineConfig, devices } from '@playwright/test'; import { execSync } from 'child_process'; -// Get the current branch +/** + * Get the current branch + * @returns {void} + */ function getCurrentBranch(): string { try { const branch = execSync('git rev-parse --abbrev-ref HEAD') diff --git a/postcss.config.js b/postcss.config.js index 33ad091d..4c0b8a04 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,3 +1,6 @@ +// Copyright (c) Gridiron Survivor. +// Licensed under the MIT License. + module.exports = { plugins: { tailwindcss: {}, diff --git a/prettier.config.js b/prettier.config.js index 53ba7d6b..2e572d05 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,7 +1,10 @@ +// Copyright (c) Gridiron Survivor. +// Licensed under the MIT License. + module.exports = { printWidth: 80, semi: true, singleQuote: true, tabWidth: 2, trailingComma: 'all', -}; \ No newline at end of file +}; diff --git a/tsconfig.json b/tsconfig.json index f8f40260..53965031 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,6 +30,6 @@ "**/*.tsx", ".next/types/**/*.ts", "jest.config.ts" - ], +, "functions/userAuth.ts" ], "exclude": ["node_modules"] -} \ No newline at end of file +}