fix(lint): resolve all eslint errors across monorepo
- Type response bodies in gameController.test.ts to fix no-unsafe-member-access - Replace async methods with Promise.resolve() in InMemoryGameSessionStore and InMemoryLobbyGameStore to satisfy require-await rule - Add argsIgnorePattern and varsIgnorePattern to eslint config so underscore-prefixed params are globally ignored - Fix no-misused-promises in ws/index.ts, lobbyHandlers, gameHandlers, __root.tsx, login.tsx and play.tsx by using void + .catch() - Fix no-floating-promises on navigate calls in login.tsx - Move API_URL outside Play component to fix useCallback dependency warning - Type fetch response bodies in play.tsx to fix no-unsafe-assignment - Add only-throw-error: off for route files (TanStack Router throw redirect) - Remove unused WebSocket import from express.d.ts - Fix unsafe return in connections.ts by typing empty Map constructor - Exclude scripts/ folder from eslint - Add targeted override for better-auth auth-client.ts (upstream typing issue)
This commit is contained in:
parent
a6d8ddec3b
commit
ce19740cc8
12 changed files with 160 additions and 91 deletions
|
|
@ -24,9 +24,13 @@ const RootLayout = () => {
|
|||
{session ? (
|
||||
<button
|
||||
className="text-sm text-gray-600 hover:text-gray-900"
|
||||
onClick={async () => {
|
||||
await signOut();
|
||||
navigate({ to: "/" });
|
||||
onClick={() => {
|
||||
void (async () => {
|
||||
await signOut();
|
||||
void navigate({ to: "/" });
|
||||
})().catch((err) => {
|
||||
console.error("Sign out error:", err);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Sign out ({session.user.name})
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const LoginPage = () => {
|
|||
if (isPending) return <div className="p-4">Loading...</div>;
|
||||
|
||||
if (session) {
|
||||
navigate({ to: "/" });
|
||||
void navigate({ to: "/" });
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -17,23 +17,25 @@ const LoginPage = () => {
|
|||
<h1 className="text-2xl font-bold">sign in to lila</h1>
|
||||
<button
|
||||
className="w-64 rounded bg-gray-800 px-4 py-2 text-white hover:bg-gray-700"
|
||||
onClick={() =>
|
||||
signIn.social({
|
||||
provider: "github",
|
||||
callbackURL: window.location.origin,
|
||||
})
|
||||
}
|
||||
onClick={() => {
|
||||
void signIn
|
||||
.social({ provider: "github", callbackURL: window.location.origin })
|
||||
.catch((err) => {
|
||||
console.error("GitHub sign in error:", err);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Continue with GitHub
|
||||
</button>
|
||||
<button
|
||||
className="w-64 rounded bg-blue-600 px-4 py-2 text-white hover:bg-blue-500"
|
||||
onClick={() =>
|
||||
signIn.social({
|
||||
provider: "google",
|
||||
callbackURL: window.location.origin,
|
||||
})
|
||||
}
|
||||
onClick={() => {
|
||||
void signIn
|
||||
.social({ provider: "google", callbackURL: window.location.origin })
|
||||
.catch((err) => {
|
||||
console.error("Google sign in error:", err);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Continue with Google
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import { ScoreScreen } from "../components/game/ScoreScreen";
|
|||
import { GameSetup } from "../components/game/GameSetup";
|
||||
import { authClient } from "../lib/auth-client";
|
||||
|
||||
function Play() {
|
||||
const API_URL = import.meta.env["VITE_API_URL"] || "";
|
||||
type GameStartResponse = { success: true; data: GameSession };
|
||||
type GameAnswerResponse = { success: true; data: AnswerResult };
|
||||
|
||||
const API_URL = (import.meta.env["VITE_API_URL"] as string) || "";
|
||||
|
||||
function Play() {
|
||||
const [gameSession, setGameSession] = useState<GameSession | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
|
||||
|
|
@ -17,13 +20,15 @@ function Play() {
|
|||
|
||||
const startGame = useCallback(async (settings: GameRequest) => {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await fetch(`${API_URL}/api/v1/game/start`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
body: JSON.stringify(settings),
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
const data = (await response.json()) as GameStartResponse;
|
||||
setGameSession(data.data);
|
||||
setCurrentQuestionIndex(0);
|
||||
setResults([]);
|
||||
|
|
@ -55,7 +60,7 @@ function Play() {
|
|||
selectedOptionId: optionId,
|
||||
}),
|
||||
});
|
||||
const data = await response.json();
|
||||
const data = (await response.json()) as GameAnswerResponse;
|
||||
setCurrentResult(data.data);
|
||||
};
|
||||
|
||||
|
|
@ -70,7 +75,13 @@ function Play() {
|
|||
if (!gameSession && !isLoading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-linear-to-b from-purple-100 to-pink-50 flex items-center justify-center p-6">
|
||||
<GameSetup onStart={startGame} />
|
||||
<GameSetup
|
||||
onStart={(settings) => {
|
||||
void startGame(settings).catch((err) => {
|
||||
console.error("Start game error:", err);
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -99,11 +110,15 @@ function Play() {
|
|||
return (
|
||||
<div className="min-h-screen bg-linear-to-b from-purple-100 to-pink-50 flex items-center justify-center p-6">
|
||||
<QuestionCard
|
||||
onAnswer={(optionId) => {
|
||||
void handleAnswer(optionId).catch((err) => {
|
||||
console.error("Answer error:", err);
|
||||
});
|
||||
}}
|
||||
question={question}
|
||||
questionNumber={currentQuestionIndex + 1}
|
||||
totalQuestions={gameSession.questions.length}
|
||||
currentResult={currentResult}
|
||||
onAnswer={handleAnswer}
|
||||
onNext={handleNext}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue