原来只有 `apps/web` 在 Prettier 下(配置在 `apps/web/.prettierrc.toml`、脚本在 web 的 package.json),后端和契约从来没格式化过 —— 手写在 100 列上下,`db/schema.ts` 还是 drizzle-kit pull 留下的 tab 缩进。两套口径分叉久了,跨端改一处就得记着「这边 什么风格」。 - 配置搬到根目录 `.prettierrc.toml`,内容不变(`semi=false`,其余全默认, printWidth 80 —— 和前端已有的格式一致,不另立一套宽度); - 脚本统一成根目录 `bun run fmt`,覆盖 `apps/*/src`、`apps/web/tests` 和两个构建 配置;web 自己那份 `fmt` 和重复的 prettier 依赖删掉; - `.prettierignore` 挡掉两类不该碰的:drizzle-kit 生成的 `src/db/meta/` 结构快照 (它是 db:generate 的比对输入,只该由 drizzle-kit 写)、unplugin 每次 dev 都会 重写的 `auto-imports.d.ts` / `components.d.ts`; - 全量跑了一遍。纯格式,无行为改动:api typecheck / check:routes / check:ast、 前端 type-check 全过,起 api 打了接口确认正常。前端这 39 个文件的小改动是 prettier 版本漂移(类型断言的换行口径变了),不是新配置带来的。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,14 +81,16 @@ export const statisticInfoSchema = z.looseObject({
|
||||
err_info: z.string().optional(),
|
||||
time_cost: z.number().optional(),
|
||||
memory_cost: z.number().optional(),
|
||||
ast_results: z.array(
|
||||
z.object({
|
||||
description: z.string(),
|
||||
passed: z.boolean(),
|
||||
/** count_* 规则实际数到的次数,判题机只在这两个引擎上写 */
|
||||
actual: z.number().optional(),
|
||||
}),
|
||||
).optional(),
|
||||
ast_results: z
|
||||
.array(
|
||||
z.object({
|
||||
description: z.string(),
|
||||
passed: z.boolean(),
|
||||
/** count_* 规则实际数到的次数,判题机只在这两个引擎上写 */
|
||||
actual: z.number().optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
|
||||
export const createSubmissionRequestSchema = z.object({
|
||||
@@ -100,7 +102,10 @@ export const createSubmissionRequestSchema = z.object({
|
||||
* 学生看到的是「系统错误」而不是「语言不对」。
|
||||
*/
|
||||
language: problemLanguageSchema,
|
||||
code: z.string().min(1).max(1024 * 1024),
|
||||
code: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(1024 * 1024),
|
||||
contestId: z.number().int().positive().optional(),
|
||||
/**
|
||||
* 来源题单。学生从 `/problemset/:id/problem/:pid` 那个入口提交时前端带上,
|
||||
@@ -146,10 +151,12 @@ export const submissionDetailSchema = z.object({
|
||||
* SQL 题(`judge/run.ts` 遇到被杀的测试点会 break,total 偏小)、没有逐点结果
|
||||
* (待判、编译失败)。
|
||||
*/
|
||||
caseSummary: z.object({
|
||||
passed: z.number().int(),
|
||||
total: z.number().int(),
|
||||
}).nullable(),
|
||||
caseSummary: z
|
||||
.object({
|
||||
passed: z.number().int(),
|
||||
total: z.number().int(),
|
||||
})
|
||||
.nullable(),
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -164,7 +171,13 @@ export const embeddedSubmissionSchema = submissionDetailSchema
|
||||
// problemDisplayId 也要去掉:下面的 problem 就是它,同一个值留两份,
|
||||
// 而路由只填了 problem —— 这里漏 omit 的那阵子,凡是收到过站内信的人
|
||||
// 打开消息页都是 500(parse 抛在缺失的 problemDisplayId 上,列表为空时才碰巧不炸)。
|
||||
.omit({ info: true, contestId: true, problemId: true, problemDisplayId: true, caseSummary: true })
|
||||
.omit({
|
||||
info: true,
|
||||
contestId: true,
|
||||
problemId: true,
|
||||
problemDisplayId: true,
|
||||
caseSummary: true,
|
||||
})
|
||||
// 旧 SubmissionSafeModelSerializer 里 problem 是
|
||||
// `SlugRelatedField(slug_field="_id")`,即**展示用题号**而非数字主键。
|
||||
// 站内信页面拿它拼 `/problem/<题号>` 链接,给数字 id 会拼出打不开的地址。
|
||||
@@ -407,7 +420,9 @@ export type AttemptedStudent = z.infer<typeof attemptedStudentSchema>
|
||||
export type SubmissionListItem = z.infer<typeof submissionListItemSchema>
|
||||
export type SubmissionList = z.infer<typeof submissionListSchema>
|
||||
export type EmbeddedSubmission = z.infer<typeof embeddedSubmissionSchema>
|
||||
export type CreateSubmissionResponse = z.infer<typeof createSubmissionResponseSchema>
|
||||
export type CreateSubmissionResponse = z.infer<
|
||||
typeof createSubmissionResponseSchema
|
||||
>
|
||||
export type FormatCodeResponse = z.infer<typeof formatCodeResponseSchema>
|
||||
|
||||
export type FormatCodeRequest = z.infer<typeof formatCodeRequestSchema>
|
||||
|
||||
Reference in New Issue
Block a user