mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
docs: add mandatory lint check convention for AI
Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
### 变更
|
||||
- **用户 Token**:将用户的 `personalToken` 从 32 位 UUID 缩短为 8 位十六进制字符串,提升易用性。
|
||||
- **数据库迁移**:完善了数据库迁移流程,在 `db:migrate:deploy` 中集成了存量用户 Token 的自动缩短逻辑,确保线上环境数据的一致性。
|
||||
- **AI 规范**:更新了 `copilot-context.md`,明确要求 AI 在每次修改代码后必须进行代码风格和 Lint 检查。
|
||||
|
||||
## [1.2.5] - 2026-01-15
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import { db } from "./index";
|
||||
import { migrateUserTokens } from "./migrate";
|
||||
|
||||
async function main() {
|
||||
await migrateUserTokens(db);
|
||||
process.exit(0);
|
||||
await migrateUserTokens(db);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
@@ -9,7 +9,7 @@ const connectionString =
|
||||
process.env.DATABASE_URL ||
|
||||
"postgres://postgres:password@localhost:5432/alert_message_center";
|
||||
|
||||
export async function migrateUserTokens(db: any) {
|
||||
export async function migrateUserTokens(db: ReturnType<typeof drizzle>) {
|
||||
console.log("⏳ Checking for user tokens that need shortening...");
|
||||
try {
|
||||
const allUsers = await db.select().from(users);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { db } from "./db";
|
||||
import { alertLogs, alertTasks, topics, users } from "./db/schema";
|
||||
import { feishuClient } from "./feishu";
|
||||
import { logger } from "./lib/logger";
|
||||
import { uuid } from "zod/v4";
|
||||
|
||||
type FeishuReceiveIdType = "open_id" | "user_id" | "email" | "chat_id";
|
||||
|
||||
@@ -144,21 +143,22 @@ webhook.post("/:token/topic/:slug", async (c) => {
|
||||
} else {
|
||||
// 2. Pass-through strategy: Use rest of body as content
|
||||
// Exclude keys that are definitely not part of content
|
||||
// biome-ignore lint/performance/noDelete: usage is limited
|
||||
const { msg_type, token, ...rest } = body;
|
||||
content = rest;
|
||||
|
||||
// 3. Infer msgType if missing
|
||||
if (!msgType) {
|
||||
if (body.post) msgType = "post";
|
||||
else if (body.file_key && body.image_key)
|
||||
msgType = "media"; // Media has both
|
||||
else if (body.image_key) msgType = "image";
|
||||
else if (body.file_key && body.image_key) msgType = "media"; // Media has both
|
||||
else if (body.file_key) msgType = "file";
|
||||
else if (body.audio_key) msgType = "audio";
|
||||
else if (body.sticker_key) msgType = "sticker";
|
||||
else if (body.chat_id) msgType = "share_chat";
|
||||
else if (body.user_id) msgType = "share_user";
|
||||
else if (body.header || body.elements) msgType = "interactive"; // Unwrapped card
|
||||
else if (body.header || body.elements)
|
||||
msgType = "interactive"; // Unwrapped card
|
||||
else {
|
||||
// Fallback to text
|
||||
msgType = "text";
|
||||
|
||||
@@ -198,7 +198,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
|
||||
- Framework: [Biome](https://biomejs.dev/).
|
||||
- **Rules**: Strict configuration for `a11y`, `suspicious`, `style`, and `correctness`.
|
||||
- **Tailwind**: `noUnknownAtRules` is configured to ignore Tailwind directives (`@tailwind`, `@apply`, etc.).
|
||||
- **Enforcement**: CI/CD runs `biome check` to ensure compliance. Avoid Use of `as any` is strictly prohibited except for specialized cases like `import.meta as any` (for Vite env) or very complex JSON spread operations. In those rare cases, use `// biome-ignore` with a clear explanation.
|
||||
- **Enforcement**: CI/CD runs `biome check` to ensure compliance. **AI assistants MUST run `bun x biome check --write .` (or equivalent) in the respective app directory after every code modification to verify and fix lint/formatting issues before finalizing.** Avoid Use of `as any` is strictly prohibited except for specialized cases like `import.meta as any` (for Vite env) or very complex JSON spread operations. In those rare cases, use `// biome-ignore` with a clear explanation.
|
||||
- **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.
|
||||
|
||||
Reference in New Issue
Block a user