From ce3eb836da3d84cd753e94caf6652c2ea8f3eb11 Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Thu, 19 Sep 2024 23:58:43 +0200 Subject: [PATCH] fixed lint --- backend/database/getTestDb.ts | 2 +- backend/index.ts | 1 + backend/services/user.ts | 9 ++------- src/App.tsx | 7 +++---- src/Button.tsx | 1 + src/Options.tsx | 2 +- src/Timer.tsx | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/database/getTestDb.ts b/backend/database/getTestDb.ts index ee6725b..ec2f6c5 100644 --- a/backend/database/getTestDb.ts +++ b/backend/database/getTestDb.ts @@ -8,7 +8,7 @@ const dbs: string[] = []; export const getTestDb = () => { const randomId = crypto.randomUUID(); dbs.push(randomId); - fs.existsSync("temp_dbs") || fs.mkdirSync("temp_dbs"); + if (!fs.existsSync("temp_dbs")) fs.mkdirSync("temp_dbs"); const db = getDb(`temp_dbs/${randomId}.db`); migrate(db, { migrationsFolder: "./backend/drizzle" }); return db; diff --git a/backend/index.ts b/backend/index.ts index 30394e7..c211b8c 100644 --- a/backend/index.ts +++ b/backend/index.ts @@ -10,6 +10,7 @@ const loadScoreboard = async (): Promise => { const scoreboardFile = Bun.file("./scoreboard.json"); const scoreboard = await scoreboardFile.json(); return scoreboard; + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { return []; } diff --git a/backend/services/user.ts b/backend/services/user.ts index dd157b4..821480d 100644 --- a/backend/services/user.ts +++ b/backend/services/user.ts @@ -14,7 +14,7 @@ export const registerUser = async ( if (user.length > 0) { throw new Error("User already exists"); } - const hash = await Bun.password.hash(password + Bun.env.SALT ?? ""); + const hash = await Bun.password.hash(password + Bun.env.SALT); await db.insert(User).values({ name, password: hash }); }; @@ -30,12 +30,7 @@ export const loginUser = async ( if (user.length === 0) { throw new Error("User does not exist"); } - if ( - !(await Bun.password.verify( - password + Bun.env.SALT ?? "", - user[0].password, - )) - ) { + if (!(await Bun.password.verify(password + Bun.env.SALT, user[0].password))) { throw new Error("Incorrect password"); } return { ...user[0], password: undefined }; diff --git a/src/App.tsx b/src/App.tsx index a9711fb..26d2d6c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,8 @@ function useMaxToasts(max: number) { .forEach((t) => toast.dismiss(t.id)); // Dismiss – Use toast.remove(t.id) for no exit animation }, [toasts, max]); } + +useGameStore.getState().resetGame(4, 4, 2); function App() { const game = useGameStore(); const [scores, setScores] = useState([]); @@ -34,6 +36,7 @@ function App() { playSound(); loseGame(game.name, game.stage); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [game.isGameOver]); useEffect(() => { @@ -52,10 +55,6 @@ function App() { return () => clearInterval(i); }, []); - useEffect(() => { - game.resetGame(4, 4, 2); - }, []); - useMaxToasts(5); return ( diff --git a/src/Button.tsx b/src/Button.tsx index 9a65254..0c73c6f 100644 --- a/src/Button.tsx +++ b/src/Button.tsx @@ -8,6 +8,7 @@ interface ButtonProps { y: number; } +// eslint-disable-next-line react-refresh/only-export-components export const colorMap: Record = { "1": "#049494", "2": "#8c9440", diff --git a/src/Options.tsx b/src/Options.tsx index b3fc970..ccfc56e 100644 --- a/src/Options.tsx +++ b/src/Options.tsx @@ -29,7 +29,7 @@ function Options() { } game.resetGame(width, height, mines); } - }, [width, height, mines]); + }, [width, height, mines, game]); return (
diff --git a/src/Timer.tsx b/src/Timer.tsx index 573f8d5..8359db3 100644 --- a/src/Timer.tsx +++ b/src/Timer.tsx @@ -49,7 +49,7 @@ const Timer = () => { }, 1000); return () => clearInterval(interval); - }, [game.isGameOver, game.getHasWon()]); + }, [game, game.isGameOver]); return ( <>