Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nathhuynh committed Sep 19, 2024
1 parent d765f33 commit 77e4b67
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**/*
15 changes: 13 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"extends": "next/core-web-vitals"
}
"extends": "next/core-web-vitals",
"rules": {
"react/no-unescaped-entities": [
"error",
{
"forbid": [
">",
"}"
]
}
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/github-actions-demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ interface LayoutProps {
children: React.ReactNode;
}

const publicRoutes = ['/signup', '/signin', '/forgot-password'];

const Layout: React.FC<LayoutProps> = ({ 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);
Expand Down
8 changes: 4 additions & 4 deletions components/withAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <P extends object>(WrappedComponent: React.ComponentType<P>) => {
const WithAuth: React.FC<P> = (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
Expand Down Expand Up @@ -38,4 +38,4 @@ const withAuth = <P extends object>(WrappedComponent: React.ComponentType<P>) =>
return WithAuth;
};

export default withAuth;
export default withAuth;
3 changes: 3 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 77e4b67

Please sign in to comment.