fix: resolve TypeScript and ESLint errors across the codebase

- Fixed @typescript-eslint/no-unused-vars errors (31 instances)
- Fixed @typescript-eslint/no-explicit-any errors in backend (~22 instances)
- Fixed @typescript-eslint/no-explicit-any errors in frontend (~60 instances)
- Fixed prefer-const errors (5 instances)
- Fixed no-empty-object-type and rules-of-hooks errors
- Added proper type assertions for database operations
- Improved type safety in authentication and encryption modules
- Enhanced type definitions for API routes and SSH operations

All TypeScript compilation errors resolved. Application builds and runs successfully.
This commit is contained in:
ZacharyZcR
2025-10-09 23:05:55 +08:00
parent eb76f416bf
commit 8f102bf971
45 changed files with 494 additions and 217 deletions

View File

@@ -66,8 +66,9 @@ export function TOTPSetup({
setSecret(response.secret);
setSetupStep("qr");
setIsSettingUp(true);
} catch (err: any) {
setError(err?.response?.data?.error || "Failed to start TOTP setup");
} catch (err: unknown) {
const error = err as { response?: { data?: { error?: string } } };
setError(error?.response?.data?.error || "Failed to start TOTP setup");
} finally {
setLoading(false);
}
@@ -86,8 +87,9 @@ export function TOTPSetup({
setBackupCodes(response.backup_codes);
setSetupStep("backup");
toast.success(t("auth.twoFactorEnabledSuccess"));
} catch (err: any) {
setError(err?.response?.data?.error || "Invalid verification code");
} catch (err: unknown) {
const error = err as { response?: { data?: { error?: string } } };
setError(error?.response?.data?.error || "Invalid verification code");
} finally {
setLoading(false);
}
@@ -105,8 +107,9 @@ export function TOTPSetup({
setDisableCode("");
onStatusChange?.(false);
toast.success(t("auth.twoFactorDisabled"));
} catch (err: any) {
setError(err?.response?.data?.error || "Failed to disable TOTP");
} catch (err: unknown) {
const error = err as { response?: { data?: { error?: string } } };
setError(error?.response?.data?.error || "Failed to disable TOTP");
} finally {
setLoading(false);
}
@@ -122,8 +125,11 @@ export function TOTPSetup({
);
setBackupCodes(response.backup_codes);
toast.success(t("auth.newBackupCodesGenerated"));
} catch (err: any) {
setError(err?.response?.data?.error || "Failed to generate backup codes");
} catch (err: unknown) {
const error = err as { response?: { data?: { error?: string } } };
setError(
error?.response?.data?.error || "Failed to generate backup codes",
);
} finally {
setLoading(false);
}