fix eslint config

This commit is contained in:
Nathaniel Tampus
2023-05-12 19:23:00 +08:00
parent e990ed9f57
commit c71ee3056d
7 changed files with 17 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
{ {
"extends": ["next/core-web-vitals", "prettier"], "extends": ["eslint:recommended", "next/core-web-vitals", "prettier"],
"settings": { "settings": {
"next": { "next": {
"rootDir": "./client" "rootDir": "client/"
} }
} }
} }

View File

@@ -1,7 +1,9 @@
import "@/styles/globals.css"; import "@/styles/globals.css";
import Header from "@/components/Header"; import type { ReactNode } from "react";
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
import Header from "@/components/Header";
import AuthModal from "@/components/auth/AuthModal"; import AuthModal from "@/components/auth/AuthModal";
import ContextProvider from "@/context/ContextProvider"; import ContextProvider from "@/context/ContextProvider";
@@ -34,7 +36,7 @@ export const metadata = {
metadataBase: new URL(process.env.VERCEL ? "https://ches.su" : "http://localhost:3000") metadataBase: new URL(process.env.VERCEL ? "https://ches.su" : "http://localhost:3000")
}; };
export default function RootLayout({ children }: { children: React.ReactNode }) { export default function RootLayout({ children }: { children: ReactNode }) {
return ( return (
<html lang="en" className="overflow-x-hidden"> <html lang="en" className="overflow-x-hidden">
<body className="overflow-x-hidden"> <body className="overflow-x-hidden">

View File

@@ -1,12 +1,13 @@
"use client"; "use client";
import type { User } from "@chessu/types"; import type { User } from "@chessu/types";
import type { ReactNode } from "react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { fetchSession } from "@/lib/auth"; import { fetchSession } from "@/lib/auth";
import { SessionContext } from "./session"; import { SessionContext } from "./session";
export default function ContextProvider({ children }: { children: React.ReactNode }) { export default function ContextProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<User | null>({}); const [user, setUser] = useState<User | null>({});
async function getSession() { async function getSession() {

View File

@@ -11,7 +11,9 @@ export const fetchSession = async () => {
const user: User = await res.json(); const user: User = await res.json();
return user; return user;
} }
} catch (err) {} } catch (err) {
// do nothing
}
}; };
export const setGuestSession = async (name: string) => { export const setGuestSession = async (name: string) => {

View File

@@ -10,8 +10,8 @@
], ],
"scripts": { "scripts": {
"dev": "concurrently \"npm run dev -w client\" \"npm run dev -w server\"", "dev": "concurrently \"npm run dev -w client\" \"npm run dev -w server\"",
"lint": "eslint .", "lint": "eslint . --ignore-path .gitignore",
"lint-fix": "eslint --fix .", "lint-fix": "eslint --fix . --ignore-path .gitignore",
"format": "prettier --write . --ignore-path .gitignore" "format": "prettier --write . --ignore-path .gitignore"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -9,11 +9,13 @@ import { db } from "../db/index.js";
const PGSession = PGSimple(session); const PGSession = PGSimple(session);
declare module "express-session" { declare module "express-session" {
// eslint-disable-next-line no-unused-vars
interface SessionData { interface SessionData {
user: User; user: User;
} }
} }
declare module "http" { declare module "http" {
// eslint-disable-next-line no-unused-vars
interface IncomingMessage { interface IncomingMessage {
session: Session & { session: Session & {
user: User; user: User;

View File

@@ -152,6 +152,7 @@ export async function claimAbandoned(this: Socket, type: "win" | "draw") {
activeGames.splice(activeGames.indexOf(game), 1); activeGames.splice(activeGames.indexOf(game), 1);
} }
// eslint-disable-next-line no-unused-vars
export async function getLatestGame(this: Socket) { export async function getLatestGame(this: Socket) {
const game = activeGames.find((g) => g.code === Array.from(this.rooms)[1]); const game = activeGames.find((g) => g.code === Array.from(this.rooms)[1]);
if (game) this.emit("receivedLatestGame", game); if (game) this.emit("receivedLatestGame", game);
@@ -219,6 +220,7 @@ export async function sendMove(this: Socket, m: { from: string; to: string; prom
} }
} }
// eslint-disable-next-line no-unused-vars
export async function joinAsPlayer(this: Socket) { export async function joinAsPlayer(this: Socket) {
const game = activeGames.find((g) => g.code === Array.from(this.rooms)[1]); const game = activeGames.find((g) => g.code === Array.from(this.rooms)[1]);
if (!game) return; if (!game) return;