Security hardening, code quality, and ESLint setup

- Remove production DB dump (db_backup_*.sql) and update.log from git tracking
- Add DB backups to .gitignore
- Replace all console.log/console.error with structured logger module
- Translate Dutch error messages to English (link-discord.ts)
- Remove dead code blocks (register-form.tsx false && pattern)
- Add ESLint flat config with TypeScript, React, Next.js, jsx-a11y, and security plugins
- Add Prettier config
- Add eslint-plugin-security for security-aware linting
- Fix all 119+ ESLint warnings across the codebase:
  - Resolve security/detect-object-injection with safe access patterns
  - Resolve security/detect-non-literal-fs-filename with path traversal validation
  - Replace <img> with next/image <Image> component
  - Remove unused variables and imports
  - Replace non-null assertions with proper type guards
  - Replace <a> with <Link> for internal navigation
  - Use next/script Script component for external scripts
- Fix setState-in-useEffect anti-patterns (navbar-color-picker, logo-generator, theme-switcher)
- Add lint and format scripts to package.json

All checks: typecheck ✓, tests 58/58 ✓, lint 0 errors 0 warnings ✓
This commit is contained in:
openhands committed 2026-07-10 22:48:22 +02:00
1 parent 7f8c9afc0f
commit 942bc6fc8d
93 files changed
+2676 -379115

No files matched your search

+8 -10
View File
@@ -2,33 +2,32 @@
import { prisma } from "@/lib/prisma";
import { auth } from "@/lib/auth";
import { logger } from "@/lib/logger";
export async function linkDiscordId(discordId: string): Promise<string | null> {
const session = await auth();
if (!session?.user?.id) return "Niet ingelogd";
if (!session?.user?.id) return "Not logged in";
const userId = Number(session.user.id);
if (!discordId || !/^\d{17,20}$/.test(discordId.trim())) {
return "Ongeldig Discord ID";
return "Invalid Discord ID format";
}
const discordIdClean = discordId.trim();
// Check if this Discord ID is already linked to another account.
try {
const existing = await prisma.socialAccounts.findUnique({
where: { provider_providerId: { provider: "discord", providerId: discordIdClean } },
select: { userId: true },
});
if (existing && Number(existing.userId) !== userId) {
return "Dit Discord ID is al gekoppeld aan een ander account";
return "This Discord ID is already linked to another account";
}
} catch {
return "Fout bij controleren Discord ID";
return "Failed to check Discord ID";
}
try {
// Upsert: create or update the social_accounts entry.
await prisma.socialAccounts.upsert({
where: { provider_providerId: { provider: "discord", providerId: discordIdClean } },
create: {
@@ -41,15 +40,14 @@ export async function linkDiscordId(discordId: string): Promise<string | null> {
update: { userId: BigInt(userId), updatedAt: new Date() },
});
// Mark user as verified.
await prisma.user.update({
where: { id: userId },
data: { mailVerified: "1" },
});
return null; // success
return null;
} catch (e) {
console.error("[link-discord] Failed:", (e as Error).message);
return "Fout bij koppelen van Discord account";
logger.error("Failed to link Discord account", { module: "link-discord", error: (e as Error).message });
return "Failed to link Discord account";
}
}