lint using oxlint (#106)

This commit is contained in:
Will Chen
2025-05-08 17:21:35 -07:00
committed by GitHub
parent 0e8cc26fb5
commit 2537fbb342
63 changed files with 251 additions and 292 deletions

View File

@@ -1,20 +1,15 @@
import { ipcMain } from "electron";
import { db, getDatabasePath } from "../../db";
import { apps, chats, messages } from "../../db/schema";
import { desc, eq, and, gte, sql, gt } from "drizzle-orm";
import type {
App,
CreateAppParams,
SandboxConfig,
Version,
} from "../ipc_types";
import { apps, chats } from "../../db/schema";
import { desc, eq } from "drizzle-orm";
import type { App, CreateAppParams } from "../ipc_types";
import fs from "node:fs";
import path from "node:path";
import { getDyadAppPath, getUserDataPath } from "../../paths/paths";
import { spawn } from "node:child_process";
import git from "isomorphic-git";
import { promises as fsPromises } from "node:fs";
import { extractCodebase } from "../../utils/codebase";
// Import our utility modules
import { withLock } from "../utils/lock_utils";
import {
@@ -26,19 +21,17 @@ import {
processCounter,
killProcess,
removeAppIfCurrentProcess,
RunningAppInfo,
} from "../utils/process_manager";
import { ALLOWED_ENV_VARS } from "../../constants/models";
import { getEnvVar } from "../utils/read_env";
import { readSettings } from "../../main/settings";
import { Worker } from "worker_threads";
import fixPath from "fix-path";
import { getGitAuthor } from "../utils/git_author";
import killPort from "kill-port";
import util from "util";
import log from "electron-log";
import { getSupabaseProjectName } from "../../supabase_admin/supabase_management_client";
import { settings } from "happy-dom/lib/PropertySymbol.js";
const logger = log.scope("app_handlers");
@@ -138,7 +131,7 @@ async function executeAppLocalNode({
async function killProcessOnPort(port: number): Promise<void> {
try {
await killPort(port, "tcp");
} catch (err) {
} catch {
// Ignore if nothing was running on that port
}
}

View File

@@ -5,7 +5,7 @@ import { desc, eq } from "drizzle-orm";
import type { ChatSummary } from "../../lib/schemas";
import * as git from "isomorphic-git";
import * as fs from "fs";
import * as path from "path";
import log from "electron-log";
import { getDyadAppPath } from "../../paths/paths";

View File

@@ -26,7 +26,7 @@ import * as fs from "fs";
import * as path from "path";
import * as os from "os";
import * as crypto from "crypto";
import { stat, readFile, writeFile, mkdir, unlink } from "fs/promises";
import { readFile, writeFile, unlink } from "fs/promises";
const logger = log.scope("chat_stream_handlers");
@@ -61,19 +61,6 @@ if (!fs.existsSync(TEMP_DIR)) {
fs.mkdirSync(TEMP_DIR, { recursive: true });
}
// First, define the proper content types to match ai SDK
type TextContent = {
type: "text";
text: string;
};
type ImageContent = {
type: "image";
image: Buffer;
};
type MessageContent = TextContent | ImageContent;
export function registerChatStreamHandlers() {
ipcMain.handle("chat:stream", async (event, req: ChatStreamParams) => {
try {

View File

@@ -1,8 +1,8 @@
import { ipcMain, app } from "electron";
import { ipcMain } from "electron";
import { platform, arch } from "os";
import { SystemDebugInfo, ChatLogsData } from "../ipc_types";
import { readSettings } from "../../main/settings";
import { execSync } from "child_process";
import log from "electron-log";
import path from "path";
import fs from "fs";

View File

@@ -1,15 +1,10 @@
import {
ipcMain,
IpcMainEvent,
BrowserWindow,
IpcMainInvokeEvent,
} from "electron";
import { ipcMain, BrowserWindow, IpcMainInvokeEvent } from "electron";
import fetch from "node-fetch"; // Use node-fetch for making HTTP requests in main process
import { writeSettings, readSettings } from "../../main/settings";
import { updateAppGithubRepo } from "../../db/index";
import git from "isomorphic-git";
import http from "isomorphic-git/http/node";
import path from "node:path";
import fs from "node:fs";
import { getDyadAppPath } from "../../paths/paths";
import { db } from "../../db";

View File

@@ -37,7 +37,7 @@ export async function fetchLMStudioModels(): Promise<LocalModelListResponse> {
logger.info(`Successfully fetched ${models.length} models from LM Studio`);
return { models, error: null };
} catch (error) {
} catch {
return { models: [], error: "Failed to fetch models from LM Studio" };
}
}

View File

@@ -1,5 +1,5 @@
import { ipcMain, app } from "electron";
import { exec, execSync } from "child_process";
import { ipcMain } from "electron";
import { execSync } from "child_process";
import { platform, arch } from "os";
import { NodeSystemInfo } from "../ipc_types";
import fixPath from "fix-path";

View File

@@ -1,14 +1,12 @@
import { ipcMain, type IpcMainInvokeEvent } from "electron";
import type {
CodeProposal,
FileChange,
ProposalResult,
SqlQuery,
ActionProposal,
} from "../../lib/schemas";
import { db } from "../../db";
import { messages, chats } from "../../db/schema";
import { desc, eq, and, Update } from "drizzle-orm";
import { desc, eq, and } from "drizzle-orm";
import path from "node:path"; // Import path for basename
// Import tag parsers
import {
@@ -31,26 +29,9 @@ import {
import { extractCodebase } from "../../utils/codebase";
import { getDyadAppPath } from "../../paths/paths";
import { withLock } from "../utils/lock_utils";
const logger = log.scope("proposal_handlers");
// Placeholder Proposal data (can be removed or kept for reference)
// const placeholderProposal: Proposal = { ... };
// Type guard for the parsed proposal structure
interface ParsedProposal {
title: string;
files: string[];
}
function isParsedProposal(obj: any): obj is ParsedProposal {
return (
obj &&
typeof obj === "object" &&
typeof obj.title === "string" &&
Array.isArray(obj.files) &&
obj.files.every((file: any) => typeof file === "string")
);
}
// Cache for codebase token counts
interface CodebaseTokenCache {
chatId: number;

View File

@@ -5,28 +5,7 @@ import { readSettings } from "../../main/settings";
export function registerSettingsHandlers() {
ipcMain.handle("get-user-settings", async () => {
const settings = await readSettings();
// Mask API keys before sending to renderer
if (settings?.providerSettings) {
// Use optional chaining
for (const providerKey in settings.providerSettings) {
// Ensure the key is own property and providerSetting exists
if (
Object.prototype.hasOwnProperty.call(
settings.providerSettings,
providerKey,
)
) {
const providerSetting = settings.providerSettings[providerKey];
// Check if apiKey exists and is a non-empty string before masking
if (providerSetting?.apiKey?.value) {
providerSetting.apiKey = providerSetting.apiKey;
}
}
}
}
const settings = readSettings();
return settings;
});

View File

@@ -1,6 +1,6 @@
import { ipcMain } from "electron";
import { db } from "../../db";
import { chats, messages } from "../../db/schema";
import { chats } from "../../db/schema";
import { eq } from "drizzle-orm";
import { SYSTEM_PROMPT } from "../../prompts/system_prompt";
import {
@@ -11,8 +11,7 @@ import { getDyadAppPath } from "../../paths/paths";
import log from "electron-log";
import { extractCodebase } from "../../utils/codebase";
import { getSupabaseContext } from "../../supabase_admin/supabase_context";
import { readSettings } from "../../main/settings";
import { MODEL_OPTIONS } from "../../constants/models";
import { TokenCountParams } from "../ipc_types";
import { TokenCountResult } from "../ipc_types";
import { estimateTokens, getContextWindow } from "../utils/token_utils";

View File

@@ -133,12 +133,7 @@ export function registerVersionHandlers() {
});
// Process each file to revert to the state in previousVersionId
for (const [
filepath,
headStatus,
workdirStatus,
stageStatus,
] of matrix) {
for (const [filepath, headStatus, workdirStatus] of matrix) {
const fullPath = path.join(appPath, filepath);
// If file exists in HEAD (previous version)