From 9228eb3102b5343e2754f666d260e018fc4bff76 Mon Sep 17 00:00:00 2001 From: icarus Date: Mon, 15 Sep 2025 07:18:38 +0800 Subject: [PATCH] chore: replace prettier with biome for code formatting Remove all prettier-related configuration, dependencies, and references Update formatting scripts and documentation to use biome instead Adjust electron-builder config to exclude biome.jsonc --- .prettierignore | 14 ---- .prettierrc | 13 ---- .vscode/extensions.json | 1 - CLAUDE.md | 2 +- electron-builder.yml | 92 +++++++++++----------- package.json | 3 - scripts/update-languages.ts | 16 ++-- yarn.lock | 150 +----------------------------------- 8 files changed, 57 insertions(+), 234 deletions(-) delete mode 100644 .prettierignore delete mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 163c9ac20e..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,14 +0,0 @@ -out/ -dist/ -build/ -.yarn/ -.github/ -.husky/ -.vscode/ -*.yaml -*.yml -*.mjs -*.cjs -*.md -*.json -src/main/integration/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 7a06761104..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "bracketSameLine": true, - "endOfLine": "lf", - "jsonRecursiveSort": true, - "jsonSortOrder": "{\"*\": \"lexical\"}", - "plugins": ["prettier-plugin-sort-json", "prettier-plugin-tailwindcss"], - "printWidth": 120, - "semi": false, - "singleQuote": true, - "tailwindFunctions": ["clsx"], - "tailwindStylesheet": "./src/renderer/src/assets/styles/tailwind.css", - "trailingComma": "none" -} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index bf561fb395..6e35f94739 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode", "editorconfig.editorconfig", "lokalise.i18n-ally", "biomejs.biome" diff --git a/CLAUDE.md b/CLAUDE.md index e7feaa981d..5c66ab4fed 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,7 +21,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - **Run E2E Tests**: `yarn test:e2e` - Playwright end-to-end tests - **Type Check**: `yarn typecheck` - Checks TypeScript for both node and web - **Lint**: `yarn lint` - ESLint with auto-fix -- **Format**: `yarn format` - Prettier formatting +- **Format**: `yarn format` - Biome formatting ### Build & Release diff --git a/electron-builder.yml b/electron-builder.yml index cf8d4553d8..80722308e4 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -17,52 +17,52 @@ protocols: schemes: - cherrystudio files: - - '**/*' - - '!**/{.vscode,.yarn,.yarn-lock,.github,.cursorrules,.prettierrc}' - - '!electron.vite.config.{js,ts,mjs,cjs}}' - - '!**/{.eslintignore,.eslintrc.js,.eslintrc.json,.eslintcache,root.eslint.config.js,eslint.config.js,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,eslint.config.mjs,dev-app-update.yml,CHANGELOG.md,README.md}' - - '!**/{.env,.env.*,.npmrc,pnpm-lock.yaml}' - - '!**/{tsconfig.json,tsconfig.tsbuildinfo,tsconfig.node.json,tsconfig.web.json}' - - '!**/{.editorconfig,.jekyll-metadata}' - - '!src' - - '!scripts' - - '!local' - - '!docs' - - '!packages' - - '!.swc' - - '!.bin' - - '!._*' - - '!*.log' - - '!stats.html' - - '!*.md' - - '!**/*.{iml,o,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}' - - '!**/*.{map,ts,tsx,jsx,less,scss,sass,css.d.ts,d.cts,d.mts,md,markdown,yaml,yml}' - - '!**/{test,tests,__tests__,powered-test,coverage}/**' - - '!**/{example,examples}/**' - - '!**/*.{spec,test}.{js,jsx,ts,tsx}' - - '!**/*.min.*.map' - - '!**/*.d.ts' - - '!**/dist/es6/**' - - '!**/dist/demo/**' - - '!**/amd/**' - - '!**/{.DS_Store,Thumbs.db,thumbs.db,__pycache__}' - - '!**/{LICENSE,license,LICENSE.*,*.LICENSE.txt,NOTICE.txt,README.md,readme.md,CHANGELOG.md}' - - '!node_modules/rollup-plugin-visualizer' - - '!node_modules/js-tiktoken' - - '!node_modules/@tavily/core/node_modules/js-tiktoken' - - '!node_modules/pdf-parse/lib/pdf.js/{v1.9.426,v1.10.88,v2.0.550}' - - '!node_modules/mammoth/{mammoth.browser.js,mammoth.browser.min.js}' - - '!node_modules/selection-hook/prebuilds/**/*' # we rebuild .node, don't use prebuilds - - '!node_modules/selection-hook/node_modules' # we don't need what in the node_modules dir - - '!node_modules/selection-hook/src' # we don't need source files - - '!node_modules/tesseract.js-core/{tesseract-core.js,tesseract-core.wasm,tesseract-core.wasm.js}' # we don't need source files - - '!node_modules/tesseract.js-core/{tesseract-core-lstm.js,tesseract-core-lstm.wasm,tesseract-core-lstm.wasm.js}' # we don't need source files - - '!node_modules/tesseract.js-core/{tesseract-core-simd-lstm.js,tesseract-core-simd-lstm.wasm,tesseract-core-simd-lstm.wasm.js}' # we don't need source files - - '!**/*.{h,iobj,ipdb,tlog,recipe,vcxproj,vcxproj.filters,Makefile,*.Makefile}' # filter .node build files + - "**/*" + - "!**/{.vscode,.yarn,.yarn-lock,.github,.cursorrules,.prettierrc}" + - "!electron.vite.config.{js,ts,mjs,cjs}}" + - "!**/{.eslintignore,.eslintrc.js,.eslintrc.json,.eslintcache,root.eslint.config.js,eslint.config.js,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,eslint.config.mjs,dev-app-update.yml,CHANGELOG.md,README.md,biome.jsonc}" + - "!**/{.env,.env.*,.npmrc,pnpm-lock.yaml}" + - "!**/{tsconfig.json,tsconfig.tsbuildinfo,tsconfig.node.json,tsconfig.web.json}" + - "!**/{.editorconfig,.jekyll-metadata}" + - "!src" + - "!scripts" + - "!local" + - "!docs" + - "!packages" + - "!.swc" + - "!.bin" + - "!._*" + - "!*.log" + - "!stats.html" + - "!*.md" + - "!**/*.{iml,o,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}" + - "!**/*.{map,ts,tsx,jsx,less,scss,sass,css.d.ts,d.cts,d.mts,md,markdown,yaml,yml}" + - "!**/{test,tests,__tests__,powered-test,coverage}/**" + - "!**/{example,examples}/**" + - "!**/*.{spec,test}.{js,jsx,ts,tsx}" + - "!**/*.min.*.map" + - "!**/*.d.ts" + - "!**/dist/es6/**" + - "!**/dist/demo/**" + - "!**/amd/**" + - "!**/{.DS_Store,Thumbs.db,thumbs.db,__pycache__}" + - "!**/{LICENSE,license,LICENSE.*,*.LICENSE.txt,NOTICE.txt,README.md,readme.md,CHANGELOG.md}" + - "!node_modules/rollup-plugin-visualizer" + - "!node_modules/js-tiktoken" + - "!node_modules/@tavily/core/node_modules/js-tiktoken" + - "!node_modules/pdf-parse/lib/pdf.js/{v1.9.426,v1.10.88,v2.0.550}" + - "!node_modules/mammoth/{mammoth.browser.js,mammoth.browser.min.js}" + - "!node_modules/selection-hook/prebuilds/**/*" # we rebuild .node, don't use prebuilds + - "!node_modules/selection-hook/node_modules" # we don't need what in the node_modules dir + - "!node_modules/selection-hook/src" # we don't need source files + - "!node_modules/tesseract.js-core/{tesseract-core.js,tesseract-core.wasm,tesseract-core.wasm.js}" # we don't need source files + - "!node_modules/tesseract.js-core/{tesseract-core-lstm.js,tesseract-core-lstm.wasm,tesseract-core-lstm.wasm.js}" # we don't need source files + - "!node_modules/tesseract.js-core/{tesseract-core-simd-lstm.js,tesseract-core-simd-lstm.wasm,tesseract-core-simd-lstm.wasm.js}" # we don't need source files + - "!**/*.{h,iobj,ipdb,tlog,recipe,vcxproj,vcxproj.filters,Makefile,*.Makefile}" # filter .node build files asarUnpack: - resources/** - - '**/*.{metal,exp,lib}' - - 'node_modules/@img/sharp-libvips-*/**' + - "**/*.{metal,exp,lib}" + - "node_modules/@img/sharp-libvips-*/**" win: executableName: Cherry Studio artifactName: ${productName}-${version}-${arch}-setup.${ext} @@ -88,7 +88,7 @@ mac: entitlementsInherit: build/entitlements.mac.plist notarize: false artifactName: ${productName}-${version}-${arch}.${ext} - minimumSystemVersion: '20.1.0' # 最低支持 macOS 11.0 + minimumSystemVersion: "20.1.0" # 最低支持 macOS 11.0 extendInfo: - NSCameraUsageDescription: Application requests access to the device's camera. - NSMicrophoneUsageDescription: Application requests access to the device's microphone. @@ -113,7 +113,7 @@ linux: rpm: # Workaround for electron build issue on rpm package: # https://github.com/electron/forge/issues/3594 - fpm: ['--rpm-rpmbuild-define=_build_id_links none'] + fpm: ["--rpm-rpmbuild-define=_build_id_links none"] publish: provider: generic url: https://releases.cherry-ai.com diff --git a/package.json b/package.json index 2306fdd04e..e05e040bc5 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,6 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@electron-toolkit/eslint-config-prettier": "^3.0.0", "@electron-toolkit/eslint-config-ts": "^3.0.0", "@electron-toolkit/preload": "^3.0.0", "@electron-toolkit/tsconfig": "^1.0.1", @@ -289,8 +288,6 @@ "pdf-lib": "^1.17.1", "pdf-parse": "^1.1.1", "playwright": "^1.52.0", - "prettier-plugin-sort-json": "^4.1.1", - "prettier-plugin-tailwindcss": "^0.6.14", "proxy-agent": "^6.5.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/scripts/update-languages.ts b/scripts/update-languages.ts index 58640637b1..b84bb1f94c 100644 --- a/scripts/update-languages.ts +++ b/scripts/update-languages.ts @@ -75,17 +75,17 @@ export const languages: Record = ${languagesObjectString}; } /** - * Formats a file using Prettier. + * Formats a file using Biome. * @param filePath The path to the file to format. */ -async function formatWithPrettier(filePath: string): Promise { - console.log('🎨 Formatting file with Prettier...') +async function format(filePath: string): Promise { + console.log('🎨 Formatting file with Biome...') try { - await execAsync(`yarn prettier --write ${filePath}`) - console.log('✅ Prettier formatting complete.') + await execAsync(`yarn biome format --write ${filePath}`) + console.log('✅ Biome formatting complete.') } catch (e: any) { - console.error('❌ Prettier formatting failed:', e.stdout || e.stderr) - throw new Error('Prettier formatting failed.') + console.error('❌ Biome formatting failed:', e.stdout || e.stderr) + throw new Error('Biome formatting failed.') } } @@ -116,7 +116,7 @@ async function updateLanguagesFile(): Promise { await fs.writeFile(LANGUAGES_FILE_PATH, fileContent, 'utf-8') console.log(`✅ Successfully wrote to ${LANGUAGES_FILE_PATH}`) - await formatWithPrettier(LANGUAGES_FILE_PATH) + await format(LANGUAGES_FILE_PATH) await checkTypeScript(LANGUAGES_FILE_PATH) console.log('🎉 Successfully updated languages.ts file!') diff --git a/yarn.lock b/yarn.lock index 1ee5143e64..0968f3fa61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3190,19 +3190,6 @@ __metadata: languageName: node linkType: hard -"@electron-toolkit/eslint-config-prettier@npm:^3.0.0": - version: 3.0.0 - resolution: "@electron-toolkit/eslint-config-prettier@npm:3.0.0" - dependencies: - eslint-config-prettier: "npm:^10.0.1" - eslint-plugin-prettier: "npm:^5.2.3" - peerDependencies: - eslint: ">= 9.0.0" - prettier: ">= 3.0.0" - checksum: 10c0/c17e272c83b9bcc0ce87b7d116b0eb2606920202c342f65332e0d792f89322de5382b8a345a79d291e45a21d5159eb82fc4e8ec8efbff2f535e336502bb8a998 - languageName: node - linkType: hard - "@electron-toolkit/eslint-config-ts@npm:^3.0.0": version: 3.1.0 resolution: "@electron-toolkit/eslint-config-ts@npm:3.1.0" @@ -7297,13 +7284,6 @@ __metadata: languageName: node linkType: hard -"@pkgr/core@npm:^0.2.3": - version: 0.2.4 - resolution: "@pkgr/core@npm:0.2.4" - checksum: 10c0/2528a443bbbef5d4686614e1d73f834f19ccbc975f62b2a64974a6b97bcdf677b9c5e8948e04808ac4f0d853e2f422adfaae2a06e9e9f4f5cf8af76f1adf8dc1 - languageName: node - linkType: hard - "@playwright/test@npm:^1.52.0": version: 1.52.0 resolution: "@playwright/test@npm:1.52.0" @@ -13152,7 +13132,6 @@ __metadata: "@dnd-kit/modifiers": "npm:^9.0.0" "@dnd-kit/sortable": "npm:^10.0.0" "@dnd-kit/utilities": "npm:^3.2.2" - "@electron-toolkit/eslint-config-prettier": "npm:^3.0.0" "@electron-toolkit/eslint-config-ts": "npm:^3.0.0" "@electron-toolkit/preload": "npm:^3.0.0" "@electron-toolkit/tsconfig": "npm:^1.0.1" @@ -13329,8 +13308,6 @@ __metadata: pdf-lib: "npm:^1.17.1" pdf-parse: "npm:^1.1.1" playwright: "npm:^1.52.0" - prettier-plugin-sort-json: "npm:^4.1.1" - prettier-plugin-tailwindcss: "npm:^0.6.14" proxy-agent: "npm:^6.5.0" react: "npm:^19.0.0" react-dom: "npm:^19.0.0" @@ -17116,37 +17093,6 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^10.0.1": - version: 10.1.2 - resolution: "eslint-config-prettier@npm:10.1.2" - peerDependencies: - eslint: ">=7.0.0" - bin: - eslint-config-prettier: bin/cli.js - checksum: 10c0/c22c8e29193cc8fd70becf1c2dd072513f2b3004a175c2a49404c79d1745ba4dc0edc2afd00d16b0e26d24f95813a0469e7445a25104aec218f6d84cdb1697e9 - languageName: node - linkType: hard - -"eslint-plugin-prettier@npm:^5.2.3": - version: 5.2.6 - resolution: "eslint-plugin-prettier@npm:5.2.6" - dependencies: - prettier-linter-helpers: "npm:^1.0.0" - synckit: "npm:^0.11.0" - peerDependencies: - "@types/eslint": ">=8.0.0" - eslint: ">=8.0.0" - eslint-config-prettier: ">= 7.0.0 <10.0.0 || >=10.1.0" - prettier: ">=3.0.0" - peerDependenciesMeta: - "@types/eslint": - optional: true - eslint-config-prettier: - optional: true - checksum: 10c0/9911740a5edac7933d92671381908671c61ffa32a3cee7aed667ebab89831ee2c0b69eb9530f68dbe172ca9d4b3fa3d47350762dc1eb096a3ce125fa31c0e616 - languageName: node - linkType: hard - "eslint-plugin-react-debug@npm:1.48.1": version: 1.48.1 resolution: "eslint-plugin-react-debug@npm:1.48.1" @@ -17735,7 +17681,7 @@ __metadata: languageName: node linkType: hard -"fast-diff@npm:^1.1.2, fast-diff@npm:^1.3.0": +"fast-diff@npm:^1.3.0": version: 1.3.0 resolution: "fast-diff@npm:1.3.0" checksum: 10c0/5c19af237edb5d5effda008c891a18a585f74bf12953be57923f17a3a4d0979565fc64dbc73b9e20926b9d895f5b690c618cbb969af0cf022e3222471220ad29 @@ -23803,88 +23749,6 @@ __metadata: languageName: node linkType: hard -"prettier-linter-helpers@npm:^1.0.0": - version: 1.0.0 - resolution: "prettier-linter-helpers@npm:1.0.0" - dependencies: - fast-diff: "npm:^1.1.2" - checksum: 10c0/81e0027d731b7b3697ccd2129470ed9913ecb111e4ec175a12f0fcfab0096516373bf0af2fef132af50cafb0a905b74ff57996d615f59512bb9ac7378fcc64ab - languageName: node - linkType: hard - -"prettier-plugin-sort-json@npm:^4.1.1": - version: 4.1.1 - resolution: "prettier-plugin-sort-json@npm:4.1.1" - peerDependencies: - prettier: ^3.0.0 - checksum: 10c0/b3b86ea679e95d0329c367aa860af4033d8a3b83a0656d7393f2005b2df78e20d19fbe2c40fe7b531262210e40060318a4287459c2a4f61c6a6bd1c2757e2b7d - languageName: node - linkType: hard - -"prettier-plugin-tailwindcss@npm:^0.6.14": - version: 0.6.14 - resolution: "prettier-plugin-tailwindcss@npm:0.6.14" - peerDependencies: - "@ianvs/prettier-plugin-sort-imports": "*" - "@prettier/plugin-hermes": "*" - "@prettier/plugin-oxc": "*" - "@prettier/plugin-pug": "*" - "@shopify/prettier-plugin-liquid": "*" - "@trivago/prettier-plugin-sort-imports": "*" - "@zackad/prettier-plugin-twig": "*" - prettier: ^3.0 - prettier-plugin-astro: "*" - prettier-plugin-css-order: "*" - prettier-plugin-import-sort: "*" - prettier-plugin-jsdoc: "*" - prettier-plugin-marko: "*" - prettier-plugin-multiline-arrays: "*" - prettier-plugin-organize-attributes: "*" - prettier-plugin-organize-imports: "*" - prettier-plugin-sort-imports: "*" - prettier-plugin-style-order: "*" - prettier-plugin-svelte: "*" - peerDependenciesMeta: - "@ianvs/prettier-plugin-sort-imports": - optional: true - "@prettier/plugin-hermes": - optional: true - "@prettier/plugin-oxc": - optional: true - "@prettier/plugin-pug": - optional: true - "@shopify/prettier-plugin-liquid": - optional: true - "@trivago/prettier-plugin-sort-imports": - optional: true - "@zackad/prettier-plugin-twig": - optional: true - prettier-plugin-astro: - optional: true - prettier-plugin-css-order: - optional: true - prettier-plugin-import-sort: - optional: true - prettier-plugin-jsdoc: - optional: true - prettier-plugin-marko: - optional: true - prettier-plugin-multiline-arrays: - optional: true - prettier-plugin-organize-attributes: - optional: true - prettier-plugin-organize-imports: - optional: true - prettier-plugin-sort-imports: - optional: true - prettier-plugin-style-order: - optional: true - prettier-plugin-svelte: - optional: true - checksum: 10c0/1bf635be28b30b3f171a184497eecf512601d19328e402dd2eb1ede52aa57b4f5b605eae2929f4916de9ba22526f3d730d9afa90334db09d17c59f463f7b26d8 - languageName: node - linkType: hard - "prettier@npm:^3.5.3": version: 3.5.3 resolution: "prettier@npm:3.5.3" @@ -27063,16 +26927,6 @@ __metadata: languageName: node linkType: hard -"synckit@npm:^0.11.0": - version: 0.11.4 - resolution: "synckit@npm:0.11.4" - dependencies: - "@pkgr/core": "npm:^0.2.3" - tslib: "npm:^2.8.1" - checksum: 10c0/dd2965a37c93c0b652bf07b1fd8d1639a803b65cf34c0cb1b827b8403044fc3b09ec87f681d922a324825127ee95b2e0394e7caccb502f407892d63e903c5276 - languageName: node - linkType: hard - "tailwind-merge@npm:3.3.1": version: 3.3.1 resolution: "tailwind-merge@npm:3.3.1" @@ -27715,7 +27569,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.1.0, tslib@npm:^2.4.0, tslib@npm:^2.6.2, tslib@npm:^2.8.0, tslib@npm:^2.8.1": +"tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.1.0, tslib@npm:^2.4.0, tslib@npm:^2.6.2, tslib@npm:^2.8.0": version: 2.8.1 resolution: "tslib@npm:2.8.1" checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62