chore(格式化): 改用 Bun 自带的 bun fmt,格式检查从 2.7 秒降到 0.1 秒
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
647186e276
commit
530e1a3d5d
4 files changed
+16
-21
No files matched your search
@@ -48,8 +48,8 @@ bun run dev # api(3000) + worker + web(5173) 一起起
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
bunx vp run verify # 下面这些一次跑完,带缓存(没改过的直接跳过)
|
bunx vp run verify # 下面这些一次跑完,带缓存(没改过的直接跳过)
|
||||||
bun run check # 格式 + lint(vp check),不含类型检查
|
bun run check # 格式检查 + lint,不含类型检查
|
||||||
bun run fmt # 格式化(Oxfmt),全仓一把
|
bun run fmt # 格式化(bun fmt),全仓一把
|
||||||
bun run lint # lint(Oxlint),有一条 warning 就算失败
|
bun run lint # lint(Oxlint),有一条 warning 就算失败
|
||||||
bun run --filter '@oj2/api' typecheck # 后端类型检查
|
bun run --filter '@oj2/api' typecheck # 后端类型检查
|
||||||
bun run --filter '@oj2/api' check:routes # 路由遮蔽检查,加完路由跑一下
|
bun run --filter '@oj2/api' check:routes # 路由遮蔽检查,加完路由跑一下
|
||||||
@@ -58,9 +58,11 @@ cd apps/web && bun run type-check # 前端类型检查
|
|||||||
cd apps/web && bun run build # 前端构建(不在 verify 里)
|
cd apps/web && bun run build # 前端构建(不在 verify 里)
|
||||||
```
|
```
|
||||||
|
|
||||||
**格式化、lint、任务编排都走 Vite+**(`vite-plus`,`vp` 命令),配置只有根目录的
|
**lint 和任务编排走 Vite+**(`vite-plus`,`vp` 命令),**格式化走 Bun 自带的 `bun fmt`**,
|
||||||
`vite.config.ts` 一份:`fmt` 块(Oxfmt,`semi: false`,行宽用默认的 100)、`lint` 块
|
配置都只在根目录的 `vite.config.ts` 一份:`fmt` 块(Oxfmt 的写法,`bun fmt` 直接读它;
|
||||||
(Oxlint,`denyWarnings`)、`run.tasks`(`verify` 和它依赖的四个检查)。前端自己的构建
|
`semi: false`,行宽用默认的 100)、`lint` 块(Oxlint,`denyWarnings`)、`run.tasks`
|
||||||
|
(`verify` 和它依赖的四个检查)。**别用 `vp fmt` / `vp check`**:Oxfmt 和 `bun fmt` 只在
|
||||||
|
长 CSS 值列表的折行上不一样,混着跑会把 `apps/web/public/style.css` 来回改。前端自己的构建
|
||||||
配置在 `apps/web/vite.config.ts`,和根目录那份无关。
|
配置在 `apps/web/vite.config.ts`,和根目录那份无关。
|
||||||
|
|
||||||
- 格式化只管代码:`.md` / `.yml` / `.json` / `.toml` 在 `fmt.ignorePatterns` 里排掉了
|
- 格式化只管代码:`.md` / `.yml` / `.json` / `.toml` 在 `fmt.ignorePatterns` 里排掉了
|
||||||
|
|||||||
@@ -315,18 +315,8 @@
|
|||||||
Naive UI 的 body 规则是运行时插进来的,晚于这份文件,所以这里用 html body 提一级优先级 */
|
Naive UI 的 body 规则是运行时插进来的,晚于这份文件,所以这里用 html body 提一级优先级 */
|
||||||
html body {
|
html body {
|
||||||
font-family:
|
font-family:
|
||||||
"OJ Emoji Lead",
|
"OJ Emoji Lead", v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif,
|
||||||
v-sans,
|
"Apple Color Emoji", "Noto Color Emoji", "OJ Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
system-ui,
|
|
||||||
-apple-system,
|
|
||||||
BlinkMacSystemFont,
|
|
||||||
"Segoe UI",
|
|
||||||
sans-serif,
|
|
||||||
"Apple Color Emoji",
|
|
||||||
"Noto Color Emoji",
|
|
||||||
"OJ Emoji",
|
|
||||||
"Segoe UI Emoji",
|
|
||||||
"Segoe UI Symbol";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.md-editor-preview .md-editor-code .md-editor-code-head {
|
.md-editor-preview .md-editor-code .md-editor-code-head {
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@
|
|||||||
"db:migrate": "bun run --filter '@oj2/api' db:migrate",
|
"db:migrate": "bun run --filter '@oj2/api' db:migrate",
|
||||||
"db:down": "docker compose -f docker/compose.dev.yml down",
|
"db:down": "docker compose -f docker/compose.dev.yml down",
|
||||||
"lint": "vp lint",
|
"lint": "vp lint",
|
||||||
"fmt": "vp fmt",
|
"fmt": "bun fmt",
|
||||||
"check": "vp check"
|
"check": "bun fmt --check && vp lint"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "1.4.4",
|
"@types/bun": "1.4.4",
|
||||||
|
|||||||
+5
-2
@@ -1,8 +1,11 @@
|
|||||||
import { defineConfig } from "vite-plus"
|
import { defineConfig } from "vite-plus"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全仓的格式化(Oxfmt)、lint(Oxlint)和任务编排(vp run)都在这一份里。
|
* 全仓的格式化、lint(Oxlint)和任务编排(vp run)都在这一份里。
|
||||||
* 前端自己的构建配置在 apps/web/vite.config.ts,和这里无关。
|
* 前端自己的构建配置在 apps/web/vite.config.ts,和这里无关。
|
||||||
|
*
|
||||||
|
* 格式化由 `bun fmt` 来跑,它直接读下面的 fmt 块(Oxfmt 的写法)。别再用 `vp fmt`:
|
||||||
|
* 两边只在长的 CSS 值列表怎么折行上不一样,混着跑会来回改 apps/web/public/style.css。
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
fmt: {
|
fmt: {
|
||||||
@@ -49,7 +52,7 @@ export default defineConfig({
|
|||||||
"check:ast": { command: "bun run check:ast", cwd: "apps/api" },
|
"check:ast": { command: "bun run check:ast", cwd: "apps/api" },
|
||||||
// 提交前、CI 里跑这一条:格式 + lint + 两边类型检查 + 路由遮蔽 + AST 节点
|
// 提交前、CI 里跑这一条:格式 + lint + 两边类型检查 + 路由遮蔽 + AST 节点
|
||||||
verify: {
|
verify: {
|
||||||
command: "vp check",
|
command: "bun run check",
|
||||||
dependsOn: ["typecheck:api", "typecheck:web", "check:routes", "check:ast"],
|
dependsOn: ["typecheck:api", "typecheck:web", "check:routes", "check:ast"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user