فهرست منبع

feat: 配置 Biome 代码格式化与校验工具

添加 biome.json 配置(formatter + linter + organizeImports),
.editorconfig 统一编辑器配置,package.json 新增 lint/format scripts。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
claude-code-best 3 هفته پیش
والد
کامیت
074ea844dc
4فایلهای تغییر یافته به همراه106 افزوده شده و 2 حذف شده
  1. 16 0
      .editorconfig
  2. 7 1
      TODO.md
  3. 79 0
      biome.json
  4. 4 1
      package.json

+ 16 - 0
.editorconfig

@@ -0,0 +1,16 @@
+root = true
+
+[*]
+indent_style = tab
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{json,yml,yaml}]
+indent_style = space
+indent_size = 2

+ 7 - 1
TODO.md

@@ -13,4 +13,10 @@
 <!-- - [ ] `@ant/computer-use-swift` — Computer Use Swift 原生模块
 - [ ] `@ant/computer-use-mcp` — Computer Use MCP 服务
 - [ ] `@ant/computer-use-input` — Computer Use 输入模块
-- [ ] `@ant/claude-for-chrome-mcp` — Chrome MCP 扩展 -->
+- [ ] `@ant/claude-for-chrome-mcp` — Chrome MCP 扩展 -->
+
+## 工程化能力
+
+- [x] 代码格式化与校验
+- [ ] 冗余代码检查
+- [ ] git hook 的配置

+ 79 - 0
biome.json

@@ -0,0 +1,79 @@
+{
+	"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
+	"vcs": {
+		"enabled": true,
+		"clientKind": "git",
+		"useIgnoreFile": true
+	},
+	"files": {
+		"includes": ["**", "!!**/dist", "!!**/packages/@ant"]
+	},
+	"formatter": {
+		"enabled": true,
+		"indentStyle": "tab",
+		"lineWidth": 120
+	},
+	"linter": {
+		"enabled": true,
+		"rules": {
+			"recommended": true,
+			"suspicious": {
+				"noExplicitAny": "off",
+				"noAssignInExpressions": "off",
+				"noDoubleEquals": "off",
+				"noRedeclare": "off",
+				"noImplicitAnyLet": "off",
+				"noGlobalIsNan": "off",
+				"noFallthroughSwitchClause": "off",
+				"noShadowRestrictedNames": "off"
+			},
+			"style": {
+				"useConst": "off",
+				"noNonNullAssertion": "off",
+				"noParameterAssign": "off",
+				"useDefaultParameterLast": "off",
+				"noUnusedTemplateLiteral": "off",
+				"useTemplate": "off",
+				"useNumberNamespace": "off"
+			},
+			"complexity": {
+				"noForEach": "off",
+				"noBannedTypes": "off",
+				"noUselessConstructor": "off",
+				"noStaticOnlyClass": "off",
+				"useOptionalChain": "off",
+				"noUselessSwitchCase": "off",
+				"noUselessFragments": "off",
+				"noUselessTernary": "off",
+				"noUselessLoneBlockStatements": "off"
+			},
+			"correctness": {
+				"noUnusedVariables": "off",
+				"noUnusedImports": "off",
+				"useExhaustiveDependencies": "off",
+				"noSwitchDeclarations": "off",
+				"noUnreachable": "off",
+				"useHookAtTopLevel": "off"
+			},
+			"a11y": {
+				"recommended": false
+			},
+			"nursery": {
+				"recommended": false
+			}
+		}
+	},
+	"javascript": {
+		"formatter": {
+			"quoteStyle": "double"
+		}
+	},
+	"assist": {
+		"enabled": true,
+		"actions": {
+			"source": {
+				"organizeImports": "on"
+			}
+		}
+	}
+}

+ 4 - 1
package.json

@@ -12,7 +12,10 @@
     "scripts": {
         "build": "bun build src/entrypoints/cli.tsx --outdir dist --target bun",
         "dev": "bun run src/entrypoints/cli.tsx",
-        "prepublishOnly": "bun run build"
+        "prepublishOnly": "bun run build",
+        "lint": "biome check src/",
+        "lint:fix": "biome check --fix src/",
+        "format": "biome format --write src/"
     },
     "dependencies": {
         "@alcalzone/ansi-tokenize": "^0.3.0",