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 = () => {
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;

View File

@ -10,6 +10,7 @@ const loadScoreboard = async (): Promise<Scoreboard[]> => {
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 [];
}

View File

@ -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 };

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
}, [toasts, max]);
}
useGameStore.getState().resetGame(4, 4, 2);
function App() {
const game = useGameStore();
const [scores, setScores] = useState<Score[]>([]);
@ -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 (

View File

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

View File

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

View File

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