diff --git a/package.json b/package.json index 8b51a9ec..6ee59e8f 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,6 @@ }, "lint-staged": { "*.{js,jsx,ts,tsx}": [ - "eslint --fix", "prettier --write" ], "*.{json,css,md}": [ diff --git a/src/backend/database/database.ts b/src/backend/database/database.ts index 55f955e9..ca085f68 100644 --- a/src/backend/database/database.ts +++ b/src/backend/database/database.ts @@ -257,7 +257,7 @@ app.get("/version", authenticateJWT, async (req, res) => { localVersion = foundVersion; break; } - } catch (error) { + } catch { continue; } } @@ -372,7 +372,6 @@ app.get("/releases/rss", authenticateJWT, async (req, res) => { app.get("/encryption/status", requireAdmin, async (req, res) => { try { - const authManager = AuthManager.getInstance(); const securityStatus = { initialized: true, system: { hasSecret: true, isValid: true }, @@ -417,8 +416,6 @@ app.post("/encryption/initialize", requireAdmin, async (req, res) => { app.post("/encryption/regenerate", requireAdmin, async (req, res) => { try { - const authManager = AuthManager.getInstance(); - apiLogger.warn("System JWT secret regenerated via API", { operation: "jwt_regenerate_api", }); @@ -440,8 +437,6 @@ app.post("/encryption/regenerate", requireAdmin, async (req, res) => { app.post("/encryption/regenerate-jwt", requireAdmin, async (req, res) => { try { - const authManager = AuthManager.getInstance(); - apiLogger.warn("JWT secret regenerated via API", { operation: "jwt_secret_regenerate_api", }); @@ -968,7 +963,7 @@ app.post( try { importDb = new Database(req.file.path, { readonly: true }); - const tables = importDb + importDb .prepare("SELECT name FROM sqlite_master WHERE type='table'") .all(); } catch (sqliteError) { @@ -1059,7 +1054,7 @@ app.post( ); } } - } catch (tableError) { + } catch { apiLogger.info("ssh_data table not found in import file, skipping"); } @@ -1120,7 +1115,7 @@ app.post( ); } } - } catch (tableError) { + } catch { apiLogger.info( "ssh_credentials table not found in import file, skipping", ); @@ -1191,7 +1186,7 @@ app.post( ); } } - } catch (tableError) { + } catch { apiLogger.info(`${table} table not found in import file, skipping`); } } @@ -1229,7 +1224,7 @@ app.post( ); } } - } catch (tableError) { + } catch { apiLogger.info( "dismissed_alerts table not found in import file, skipping", ); @@ -1270,7 +1265,7 @@ app.post( ); } } - } catch (tableError) { + } catch { apiLogger.info("settings table not found in import file, skipping"); } } else { @@ -1288,7 +1283,7 @@ app.post( try { fs.unlinkSync(req.file.path); - } catch (cleanupError) { + } catch { apiLogger.warn("Failed to clean up uploaded file", { operation: "file_cleanup_warning", filePath: req.file.path, @@ -1314,7 +1309,7 @@ app.post( if (req.file?.path && fs.existsSync(req.file.path)) { try { fs.unlinkSync(req.file.path); - } catch (cleanupError) { + } catch { apiLogger.warn("Failed to clean up uploaded file after error", { operation: "file_cleanup_error", filePath: req.file.path, @@ -1337,11 +1332,7 @@ app.post( app.post("/database/export/preview", authenticateJWT, async (req, res) => { try { const userId = (req as any).userId; - const { - format = "encrypted", - scope = "user_data", - includeCredentials = true, - } = req.body; + const { scope = "user_data", includeCredentials = true } = req.body; const exportData = await UserDataExport.exportUserData(userId, { format: "encrypted", @@ -1417,7 +1408,8 @@ app.use( err: unknown, req: express.Request, res: express.Response, - next: express.NextFunction, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _next: express.NextFunction, ) => { apiLogger.error("Unhandled error in request", err, { operation: "error_handler", @@ -1430,7 +1422,6 @@ app.use( ); const HTTP_PORT = 30001; -const HTTPS_PORT = process.env.SSL_PORT || 8443; async function initializeSecurity() { try { @@ -1443,13 +1434,6 @@ async function initializeSecurity() { if (!isValid) { throw new Error("Security system validation failed"); } - - const securityStatus = { - initialized: true, - system: { hasSecret: true, isValid: true }, - activeSessions: {}, - activeSessionCount: 0, - }; } catch (error) { databaseLogger.error("Failed to initialize security system", error, { operation: "security_init_error", @@ -1481,13 +1465,17 @@ app.get( if (status.hasUnencryptedDb) { try { unencryptedSize = fs.statSync(dbPath).size; - } catch (error) {} + } catch { + // Ignore file access errors + } } if (status.hasEncryptedDb) { try { encryptedSize = fs.statSync(encryptedDbPath).size; - } catch (error) {} + } catch { + // Ignore file access errors + } } res.json({ diff --git a/src/backend/database/db/index.ts b/src/backend/database/db/index.ts index 88cca125..03c614f7 100644 --- a/src/backend/database/db/index.ts +++ b/src/backend/database/db/index.ts @@ -23,7 +23,7 @@ const enableFileEncryption = process.env.DB_FILE_ENCRYPTION !== "false"; const dbPath = path.join(dataDir, "db.sqlite"); const encryptedDbPath = `${dbPath}.encrypted`; -let actualDbPath = ":memory:"; +const actualDbPath = ":memory:"; let memoryDatabase: Database.Database; let isNewDatabase = false; let sqlite: Database.Database; @@ -31,7 +31,8 @@ let sqlite: Database.Database; async function initializeDatabaseAsync(): Promise { const systemCrypto = SystemCrypto.getInstance(); - const dbKey = await systemCrypto.getDatabaseKey(); + // Ensure database key is initialized + await systemCrypto.getDatabaseKey(); if (enableFileEncryption) { try { if (DatabaseFileEncryption.isEncryptedDatabaseFile(encryptedDbPath)) { @@ -277,7 +278,7 @@ const addColumnIfNotExists = ( FROM ${table} LIMIT 1`, ) .get(); - } catch (e) { + } catch { try { sqlite.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition};`); @@ -476,21 +477,29 @@ async function cleanupDatabase() { for (const file of files) { try { fs.unlinkSync(path.join(tempDir, file)); - } catch {} + } catch { + // Ignore cleanup errors + } } try { fs.rmdirSync(tempDir); - } catch {} + } catch { + // Ignore cleanup errors + } } - } catch (error) {} + } catch { + // Ignore cleanup errors + } } process.on("exit", () => { if (sqlite) { try { sqlite.close(); - } catch {} + } catch { + // Ignore close errors on exit + } } }); diff --git a/src/backend/database/routes/credentials.ts b/src/backend/database/routes/credentials.ts index 9c6dc909..b6a510ca 100644 --- a/src/backend/database/routes/credentials.ts +++ b/src/backend/database/routes/credentials.ts @@ -970,7 +970,7 @@ router.post( try { let privateKeyObj; - let parseAttempts = []; + const parseAttempts = []; try { privateKeyObj = crypto.createPrivateKey({ @@ -1521,7 +1521,7 @@ router.post( const hostData = targetHost[0]; - let hostConfig = { + const hostConfig = { ip: hostData.ip, port: hostData.port, username: hostData.username, diff --git a/src/backend/database/routes/users.ts b/src/backend/database/routes/users.ts index 3c2303cc..43e1794d 100644 --- a/src/backend/database/routes/users.ts +++ b/src/backend/database/routes/users.ts @@ -606,7 +606,7 @@ router.get("/oidc/callback", async (req, res) => { const tokenData = (await tokenResponse.json()) as any; let userInfo: any = null; - let userInfoUrls: string[] = []; + const userInfoUrls: string[] = []; const normalizedIssuerUrl = config.issuer_url.endsWith("/") ? config.issuer_url.slice(0, -1) diff --git a/src/backend/ssh/file-manager.ts b/src/backend/ssh/file-manager.ts index 99ce1e95..33b38439 100644 --- a/src/backend/ssh/file-manager.ts +++ b/src/backend/ssh/file-manager.ts @@ -461,7 +461,7 @@ app.get("/ssh/file_manager/ssh/listFiles", (req, res) => { const size = parseInt(parts[4], 10); let dateStr = ""; - let nameStartIndex = 8; + const nameStartIndex = 8; if (parts[5] && parts[6] && parts[7]) { dateStr = `${parts[5]} ${parts[6]} ${parts[7]}`; diff --git a/src/ui/Desktop/Apps/File Manager/FileManager.tsx b/src/ui/Desktop/Apps/File Manager/FileManager.tsx index 73ac9bc6..fdf26575 100644 --- a/src/ui/Desktop/Apps/File Manager/FileManager.tsx +++ b/src/ui/Desktop/Apps/File Manager/FileManager.tsx @@ -709,7 +709,7 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) { } try { - let currentSessionId = sshSessionId; + const currentSessionId = sshSessionId; try { const status = await getSSHStatus(currentSessionId); if (!status.connected) { diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index c1f2a660..57360fe4 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -320,7 +320,7 @@ function isDev(): boolean { ); } -let apiHost = import.meta.env.VITE_API_HOST || "localhost"; +const apiHost = import.meta.env.VITE_API_HOST || "localhost"; let apiPort = 30001; let configuredServerUrl: string | null = null;