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

Add Eslint Config #19

Merged
merged 8 commits into from
Nov 18, 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
26 changes: 25 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"next/core-web-vitals",
"next/typescript",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"rules": {
"no-unused-vars": "error",
"no-irregular-whitespace": "error",
"no-undef": "error",
"curly": "error",
"semi": "error",
"no-trailing-spaces": "error",
"indent": ["error", 4],
"quotes": ["error", "single"],
"space-before-blocks": "error"
},
"globals": {
"React": true
}
}
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"lint:fix": "next lint --fix"
},
"dependencies": {
"next": "15.0.3",
Expand All @@ -18,6 +19,8 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"postcss": "^8",
Expand Down
35 changes: 18 additions & 17 deletions src/app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import type { NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import type { NextAuthOptions } from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';

export const options: NextAuthOptions = {
providers: [
CredentialsProvider({
name: "Credentials",
name: 'Credentials',
credentials: {
username: {
label: "Username:",
type: "text",
placeholder: "dev"
label: 'Username:',
type: 'text',
placeholder: 'dev'
},
password: {
label: "Password:",
type: "text",
placeholder: "dev"
label: 'Password:',
type: 'text',
placeholder: 'dev'
}
},
},

async authorize(credentials) {
// change this to await/async once we get a db
authorize(credentials) {
const user = {
id: "1",
name: "dev",
password: "dev"
}
id: '1',
name: 'dev',
password: 'dev'
};

if(credentials?.username === user.name && credentials?.password === user.password){
if(credentials?.username === user.name && credentials?.password === user.password) {
return user;
}

return null;
}
})
],
}
};
10 changes: 6 additions & 4 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import NextAuth from "next-auth";
import { options } from "./options";
import NextAuth from 'next-auth';
import { options } from '@/app/api/auth/[...nextauth]/options';
import { NextApiHandler } from 'next';

const handler = NextAuth(options);

export { handler as GET, handler as POST }
const handler = NextAuth(options) as NextApiHandler;

export { handler as GET, handler as POST };
22 changes: 11 additions & 11 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { Metadata } from "next";
import type { Metadata } from 'next';

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: 'Create Next App',
description: 'Generated by create next app',
};

export default function RootLayout({
children,
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}
12 changes: 6 additions & 6 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Metadata } from "next";
import { Metadata } from 'next';

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: 'Create Next App',
description: 'Generated by create next app',
};

export default function Home() {
return (
<h1>Hello World</h1>
);
return (
<h1>Hello World</h1>
);
}
12 changes: 6 additions & 6 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getServerSession } from "next-auth";
import { options } from "../api/auth/[...nextauth]/options";
import { redirect } from "next/navigation";
import { getServerSession } from 'next-auth';
import { options } from '../api/auth/[...nextauth]/options';
import { redirect } from 'next/navigation';

export default async function ProfilePage() {
const session = await getServerSession(options);

if(!session){
if(!session) {
redirect('/api/auth/signin?callbackUrl=/profile');
}

return (
<h1 className="text-9xl">Hello {session.user?.name}</h1>
)
);
}
4 changes: 2 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default } from "next-auth/middleware"
export { default } from 'next-auth/middleware';

export const config = {
matcher: ['/profile']
}
};