diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3f354c2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist/**/* \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..f058875 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,14 @@ { - "extends": "next/core-web-vitals" -} + "extends": "next/core-web-vitals", + "rules": { + "react/no-unescaped-entities": [ + "error", + { + "forbid": [ + ">", + "}" + ] + } + ] + } +} \ No newline at end of file diff --git a/.github/workflows/github-actions-demo.yaml b/.github/workflows/github-actions-demo.yaml index 8c1542e..7d3d5d1 100644 --- a/.github/workflows/github-actions-demo.yaml +++ b/.github/workflows/github-actions-demo.yaml @@ -50,7 +50,7 @@ jobs: # docker run --network host -e DATABASE_URL="postgresql://${{ secrets.DB_USER }}:${{ secrets.DB_PASSWORD }}@localhost:5432/${{ secrets.DB_NAME }}?schema=public" app:latest npm test - name: Run linting - run: docker run app:latest npm run lint + run: docker run app:latest npm run lint -- --config .eslintrc.json --ignore-path .eslintignore - name: Run type checking run: docker run app:latest npx tsc --noEmit diff --git a/components/Layout.tsx b/components/Layout.tsx index 98fed59..8ec6785 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -8,14 +8,14 @@ interface LayoutProps { children: React.ReactNode; } +const publicRoutes = ['/signup', '/signin', '/forgot-password']; + const Layout: React.FC = ({ children }) => { const { data: session, status } = useSession(); const isAuthenticated = status === 'authenticated'; const router = useRouter(); const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(false); - const publicRoutes = ['/signup', '/signin', '/forgot-password']; - useEffect(() => { if (status !== 'loading') { const isPublicRoute = publicRoutes.includes(router.pathname); diff --git a/components/withAuth.tsx b/components/withAuth.tsx index dd4e533..1839826 100644 --- a/components/withAuth.tsx +++ b/components/withAuth.tsx @@ -2,15 +2,15 @@ import { useEffect } from 'react'; import { useSession } from 'next-auth/react'; import { useRouter } from 'next/router'; +// List of public routes that don't require authentication +const publicRoutes = ['/signup', '/signin', '/forgot-password'] + const withAuth =

(WrappedComponent: React.ComponentType

) => { const WithAuth: React.FC

= (props) => { const router = useRouter(); const { data: session, status } = useSession(); const isAuthenticated = status === 'authenticated'; - // List of public routes that don't require authentication - const publicRoutes = ['/signup', '/signin', '/forgot-password']; - useEffect(() => { if (typeof window !== 'undefined') { if (status === 'loading') return; // Wait for the session to load @@ -38,4 +38,4 @@ const withAuth =

(WrappedComponent: React.ComponentType

) => return WithAuth; }; -export default withAuth; \ No newline at end of file +export default withAuth; diff --git a/env.example b/env.example index e5f543b..7dd8960 100644 --- a/env.example +++ b/env.example @@ -2,3 +2,6 @@ DATABASE_URL="DATABASE_URL" NEXTAUTH_SECRET="NEXTAUTH_SECRET_TOKEN" NEXTAUTH_JWT_SECRET="NEXTAUTH_JWT_SECRET_TOKEN" NEXTAUTH_URL=http://localhost:3000 +DB_USER=DB_USER +DB_PASSWORD=DB_PASSWORD +DB_NAME=DB_NAME