From 9d2ea2ad513596fba6f6496112614f4559ac295f Mon Sep 17 00:00:00 2001 From: zhangmo8 Date: Thu, 26 Mar 2026 15:18:46 +0800 Subject: [PATCH] chore: migrate to oxfmt --- .oxfmtrc.json | 36 +++++++++++++++++++ .prettierignore | 26 -------------- .prettierrc.yaml | 4 --- .vscode/extensions.json | 2 +- AGENTS.md | 2 +- CONTRIBUTING.md | 2 +- CONTRIBUTING.zh.md | 2 +- package.json | 13 +++---- .../components/NotificationsHooksSettings.vue | 2 +- .../src/components/sidepanel/BrowserPanel.vue | 2 +- 10 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 .oxfmtrc.json delete mode 100644 .prettierignore delete mode 100644 .prettierrc.yaml diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 000000000..196e94c16 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,36 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "singleQuote": true, + "semi": false, + "printWidth": 100, + "trailingComma": "none", + "sortPackageJson": false, + "ignorePatterns": [ + "out", + "dist", + "pnpm-lock.yaml", + "LICENSE.md", + "tsconfig.json", + "tsconfig.*.json", + "CONTRIBUTING*.md", + "README*.md", + "docs", + "resources", + "runtime", + "scripts", + "build", + "*.yaml", + "tailwind.config.js", + "vitest.config.*", + "Dockerfile*", + ".env*", + "src/renderer/src/components/ui/*", + ".github", + ".cursor", + ".vscode", + "electron.vite.config.ts", + "*.md", + "scripts/*", + "src/shadcn/**/*" + ] +} diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 15ed9cf1a..000000000 --- a/.prettierignore +++ /dev/null @@ -1,26 +0,0 @@ -out -dist -pnpm-lock.yaml -LICENSE.md -tsconfig.json -tsconfig.*.json -CONTRIBUTING*.md -README*.md -docs -resources -runtime -scripts -build -*.yaml -tailwind.config.js -vitest.config.* -Dockerfile* -.env* -src/renderer/src/components/ui/* -.github -.cursor -.vscode -electron.vite.config.ts -*.md -scripts/* -src/shadcn/**/* diff --git a/.prettierrc.yaml b/.prettierrc.yaml deleted file mode 100644 index 35893b3be..000000000 --- a/.prettierrc.yaml +++ /dev/null @@ -1,4 +0,0 @@ -singleQuote: true -semi: false -printWidth: 100 -trailingComma: none diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 347bc4222..faedcd1a2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["dbaeumer.vscode-eslint", "lokalise.i18n-ally", "esbenp.prettier-vscode", "TypeScriptTeam.native-preview"] + "recommendations": ["dbaeumer.vscode-eslint", "lokalise.i18n-ally", "oxc.oxc-vscode", "TypeScriptTeam.native-preview"] } diff --git a/AGENTS.md b/AGENTS.md index a791b851b..4625e17de 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,7 +22,7 @@ ## Coding Style & Naming Conventions - TypeScript + Vue 3 Composition API; Pinia for state; Tailwind for styles. - i18n: all user-facing strings use vue-i18n keys in `src/renderer/src/i18n`. -- Prettier: single quotes, no semicolons, width 100. Run `pnpm run format`. +- Oxfmt: single quotes, no semicolons, width 100. Run `pnpm run format`. - OxLint for JS/TS; hooks run `lint-staged` and `typecheck`. - Names: Vue components PascalCase (`ChatInput.vue`); variables/functions `camelCase`; types/classes `PascalCase`; constants `SCREAMING_SNAKE_CASE`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7dddb53ed..cf3e7bb7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -168,7 +168,7 @@ We use GitHub to host code, to track issues and feature requests, as well as acc ## Code Style - TypeScript + Vue 3 Composition API + Pinia; Tailwind + shadcn/ui for styling. -- Prettier enforces single quotes and no semicolons; `pnpm run format` before committing. +- Oxfmt enforces single quotes, no semicolons, and width 100; `pnpm run format` before committing. - OxLint is used for linting (`pnpm run lint`). Type checking via `pnpm run typecheck` (node + web targets). - Tests use Vitest (`test/main`, `test/renderer`). Name tests `*.test.ts`/`*.spec.ts`. - Follow naming conventions: PascalCase components/types, camelCase variables/functions, SCREAMING_SNAKE_CASE constants. diff --git a/CONTRIBUTING.zh.md b/CONTRIBUTING.zh.md index 81465a38b..32224b6f5 100644 --- a/CONTRIBUTING.zh.md +++ b/CONTRIBUTING.zh.md @@ -168,7 +168,7 @@ pnpm run dev ## 代码风格 - TypeScript + Vue 3 Composition API + Pinia;样式使用 Tailwind + shadcn/ui。 -- Prettier:单引号、无分号;提交前请执行 `pnpm run format`。 +- Oxfmt:单引号、无分号、宽度 100;提交前请执行 `pnpm run format`。 - OxLint 用于代码检查(`pnpm run lint`);类型检查 `pnpm run typecheck`(node + web 双目标)。 - 测试使用 Vitest(`test/main`、`test/renderer`),命名 `*.test.ts` / `*.spec.ts`。 - 命名约定:组件/类型 PascalCase,变量/函数 camelCase,常量 SCREAMING_SNAKE_CASE。 diff --git a/package.json b/package.json index 17d53b24c..fd82ea685 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "test:coverage": "vitest --coverage", "test:watch": "vitest --watch", "test:ui": "vitest --ui", - "format:check": "prettier --check .", - "format": "prettier --cache --write .", + "format:check": "oxfmt --check .", + "format": "oxfmt .", "lint": "pnpm run lint:agent-cleanup && oxlint .", "lint:agent-cleanup": "node scripts/agent-cleanup-guard.mjs", "typecheck:node": "tsgo --noEmit -p tsconfig.node.json --composite false", @@ -160,10 +160,10 @@ "mermaid": "^11.12.2", "minimatch": "^10.1.1", "monaco-editor": "^0.52.2", + "oxfmt": "^0.42.0", "oxlint": "^1.35.0", "picocolors": "^1.1.1", "pinia": "^3.0.4", - "prettier": "^3.7.4", "reka-ui": "^2.7.0", "simple-git-hooks": "^2.13.1", "stream-monaco": "^0.0.15", @@ -195,11 +195,8 @@ "commit-msg": "node scripts/verify-commit.js \"$1\"" }, "lint-staged": { - "*.js": [ - "prettier --write" - ], - "*.ts": [ - "prettier --parser=typescript --write" + "*.{js,ts}": [ + "oxfmt --no-error-on-unmatched-pattern" ] }, "pnpm": { diff --git a/src/renderer/settings/components/NotificationsHooksSettings.vue b/src/renderer/settings/components/NotificationsHooksSettings.vue index 75536c750..3a9423f16 100644 --- a/src/renderer/settings/components/NotificationsHooksSettings.vue +++ b/src/renderer/settings/components/NotificationsHooksSettings.vue @@ -468,7 +468,7 @@ const confirmoAvailable = computed(() => confirmoStatus.value?.available ?? fals const eventNames = HOOK_EVENT_NAMES -const buildEventRecord = (value: T) => +const buildEventRecord = (value: T) => Object.fromEntries(eventNames.map((name) => [name, value])) as Record const commandTesting = ref>(buildEventRecord(false)) diff --git a/src/renderer/src/components/sidepanel/BrowserPanel.vue b/src/renderer/src/components/sidepanel/BrowserPanel.vue index bed3ebc82..f0df8d0ad 100644 --- a/src/renderer/src/components/sidepanel/BrowserPanel.vue +++ b/src/renderer/src/components/sidepanel/BrowserPanel.vue @@ -111,7 +111,7 @@ const isPresenterError = (value: unknown): value is { error: string } => { ) } -const callPresenter = async ( +const callPresenter = async ( action: string, promise: Promise ): Promise => {