From f5bd5270588636a95ac5cd9e682bd1d7aacc602f Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Sat, 17 Jan 2026 15:51:11 +0800 Subject: [PATCH] docs: Add a formatting guideline for trailing newlines and `package.json` formatting to `copilot-context.md`. --- apps/server/package.json | 2 +- apps/web/package.json | 2 +- docs/copilot-context.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/server/package.json b/apps/server/package.json index f1a57de..343e5e3 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -25,4 +25,4 @@ "drizzle-kit": "^0.31.8", "pino-pretty": "^13.1.3" } -} \ No newline at end of file +} diff --git a/apps/web/package.json b/apps/web/package.json index fdcec21..b868989 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -29,4 +29,4 @@ "@types/node": "^20.0.0", "bun-types": "latest" } -} \ No newline at end of file +} diff --git a/docs/copilot-context.md b/docs/copilot-context.md index b6cb428..23415bf 100644 --- a/docs/copilot-context.md +++ b/docs/copilot-context.md @@ -215,6 +215,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`. - **Hono RPC**: Utilize the type-safe client (`client.api...`) to ensure end-to-end type safety between backend and frontend. - **No Type Casting**: Avoid `as any` or `` casts. Use type guards (`if`, `switch`, `instanceof`) or Zod schema validation to narrow types safely. - **AI Responsibility**: AI assistants MUST ensure every new or modified piece of code passes strict TypeScript and Biome checks. If a type is unknown, research the schema rather than defaulting to `any`. + - **Formatting**: All files MUST end with a single trailing newline (enforced by Biome). Ensure `package.json` and other configuration files are correctly formatted before committing. - **Vite Env Access**: When accessing Vite environment variables via `import.meta.env` (or casting `import.meta as any`), **always use optional chaining** (e.g., `meta.env?.VITE_...`). This prevents crashes if the environment is not initialized or if the code runs in a non-browser context during pre-rendering/testing. - **Frontend Resilience**: - Always check `res.ok` before attempting to parse or use API responses.