fixed lint

This commit is contained in:
MasterGordon 2024-09-19 23:58:43 +02:00
parent edafa021ee
commit ce3eb836da
7 changed files with 10 additions and 14 deletions

View File

@ -8,7 +8,7 @@ const dbs: string[] = [];
export const getTestDb = () => { export const getTestDb = () => {
const randomId = crypto.randomUUID(); const randomId = crypto.randomUUID();
dbs.push(randomId); 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`); const db = getDb(`temp_dbs/${randomId}.db`);
migrate(db, { migrationsFolder: "./backend/drizzle" }); migrate(db, { migrationsFolder: "./backend/drizzle" });
return db; return db;

View File

@ -10,6 +10,7 @@ const loadScoreboard = async (): Promise<Scoreboard[]> => {
const scoreboardFile = Bun.file("./scoreboard.json"); const scoreboardFile = Bun.file("./scoreboard.json");
const scoreboard = await scoreboardFile.json(); const scoreboard = await scoreboardFile.json();
return scoreboard; return scoreboard;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) { } catch (e) {
return []; return [];
} }

View File

@ -14,7 +14,7 @@ export const registerUser = async (
if (user.length > 0) { if (user.length > 0) {
throw new Error("User already exists"); 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 }); await db.insert(User).values({ name, password: hash });
}; };
@ -30,12 +30,7 @@ export const loginUser = async (
if (user.length === 0) { if (user.length === 0) {
throw new Error("User does not exist"); throw new Error("User does not exist");
} }
if ( if (!(await Bun.password.verify(password + Bun.env.SALT, user[0].password))) {
!(await Bun.password.verify(
password + Bun.env.SALT ?? "",
user[0].password,
))
) {
throw new Error("Incorrect password"); throw new Error("Incorrect password");
} }
return { ...user[0], password: undefined }; return { ...user[0], password: undefined };

View File

@ -22,6 +22,8 @@ function useMaxToasts(max: number) {
.forEach((t) => toast.dismiss(t.id)); // Dismiss Use toast.remove(t.id) for no exit animation .forEach((t) => toast.dismiss(t.id)); // Dismiss Use toast.remove(t.id) for no exit animation
}, [toasts, max]); }, [toasts, max]);
} }
useGameStore.getState().resetGame(4, 4, 2);
function App() { function App() {
const game = useGameStore(); const game = useGameStore();
const [scores, setScores] = useState<Score[]>([]); const [scores, setScores] = useState<Score[]>([]);
@ -34,6 +36,7 @@ function App() {
playSound(); playSound();
loseGame(game.name, game.stage); loseGame(game.name, game.stage);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [game.isGameOver]); }, [game.isGameOver]);
useEffect(() => { useEffect(() => {
@ -52,10 +55,6 @@ function App() {
return () => clearInterval(i); return () => clearInterval(i);
}, []); }, []);
useEffect(() => {
game.resetGame(4, 4, 2);
}, []);
useMaxToasts(5); useMaxToasts(5);
return ( return (

View File

@ -8,6 +8,7 @@ interface ButtonProps {
y: number; y: number;
} }
// eslint-disable-next-line react-refresh/only-export-components
export const colorMap: Record<string, string> = { export const colorMap: Record<string, string> = {
"1": "#049494", "1": "#049494",
"2": "#8c9440", "2": "#8c9440",

View File

@ -29,7 +29,7 @@ function Options() {
} }
game.resetGame(width, height, mines); game.resetGame(width, height, mines);
} }
}, [width, height, mines]); }, [width, height, mines, game]);
return ( return (
<div> <div>

View File

@ -49,7 +49,7 @@ const Timer = () => {
}, 1000); }, 1000);
return () => clearInterval(interval); return () => clearInterval(interval);
}, [game.isGameOver, game.getHasWon()]); }, [game, game.isGameOver]);
return ( return (
<> <>