ccjk 14.1.11 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/chunks/config.mjs +17 -2
  2. package/dist/chunks/doctor.mjs +171 -2
  3. package/dist/chunks/index10.mjs +18 -4
  4. package/dist/chunks/mcp-cli.mjs +1 -1
  5. package/dist/chunks/package.mjs +1 -1
  6. package/dist/cli.mjs +0 -0
  7. package/dist/templates/agents/README.md +78 -0
  8. package/dist/templates/common/error-prevention.md +267 -0
  9. package/dist/templates/common/karpathy-baseline.md +83 -0
  10. package/dist/templates/common/output-styles/zh-CN/carmack-mode.md +381 -0
  11. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +265 -0
  12. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +539 -0
  13. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +369 -0
  14. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +135 -0
  15. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +221 -0
  16. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +628 -0
  17. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +628 -0
  18. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +187 -0
  19. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +191 -0
  20. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +249 -0
  21. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +277 -0
  22. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +29 -0
  23. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +115 -0
  24. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +91 -0
  25. package/dist/templates/common/workflow/essential/en/feat.md +92 -0
  26. package/dist/templates/common/workflow/essential/en/goal.md +147 -0
  27. package/dist/templates/common/workflow/essential/en/init-project.md +53 -0
  28. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +29 -0
  29. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +115 -0
  30. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +91 -0
  31. package/dist/templates/common/workflow/essential/zh-CN/feat.md +315 -0
  32. package/dist/templates/common/workflow/essential/zh-CN/goal.md +146 -0
  33. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +53 -0
  34. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +102 -0
  35. package/dist/templates/common/workflow/git/en/git-commit.md +205 -0
  36. package/dist/templates/common/workflow/git/en/git-rollback.md +90 -0
  37. package/dist/templates/common/workflow/git/en/git-worktree.md +276 -0
  38. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +102 -0
  39. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +205 -0
  40. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +90 -0
  41. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +276 -0
  42. package/dist/templates/common/workflow/interview/en/interview.md +67 -0
  43. package/dist/templates/common/workflow/interview/zh-CN/interview.md +67 -0
  44. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +651 -0
  45. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +752 -0
  46. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +516 -0
  47. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +812 -0
  48. package/dist/templates/common/workflow/sixStep/en/workflow.md +83 -0
  49. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +359 -0
  50. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +364 -0
  51. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +366 -0
  52. package/dist/templates/hooks/README.md +212 -0
  53. package/dist/templates/hooks/git-workflow-hooks.md +551 -0
  54. package/dist/templates/hooks/post-test-coverage.md +434 -0
  55. package/dist/templates/hooks/pre-commit-black.md +274 -0
  56. package/dist/templates/hooks/pre-commit-eslint.md +153 -0
  57. package/dist/templates/hooks/pre-commit-gofmt.md +284 -0
  58. package/dist/templates/hooks/pre-commit-prettier.md +212 -0
  59. package/dist/templates/hooks/pre-commit-type-check.md +377 -0
  60. package/dist/templates/skills/ccjk-init.md +154 -0
  61. package/dist/templates/skills/ccjk-mcp-setup.md +205 -0
  62. package/dist/templates/skills/ccjk-troubleshoot.md +228 -0
  63. package/dist/templates/skills/django-patterns.md +1016 -0
  64. package/dist/templates/skills/git-workflow.md +748 -0
  65. package/dist/templates/skills/go-idioms.md +963 -0
  66. package/dist/templates/skills/nextjs-optimization.md +694 -0
  67. package/dist/templates/skills/python-pep8.md +852 -0
  68. package/dist/templates/skills/react-patterns.md +686 -0
  69. package/dist/templates/skills/rust-patterns.md +1057 -0
  70. package/dist/templates/skills/security-best-practices.md +1413 -0
  71. package/dist/templates/skills/testing-best-practices.md +1315 -0
  72. package/dist/templates/skills/ts-best-practices.md +354 -0
  73. package/package.json +40 -43
  74. package/templates/common/karpathy-baseline.md +83 -0
  75. package/templates/common/output-styles/zh-CN/carmack-mode.md +14 -0
  76. package/templates/common/output-styles/zh-CN/dhh-mode.md +14 -0
  77. package/templates/common/output-styles/zh-CN/evan-you-mode.md +14 -0
  78. package/templates/common/output-styles/zh-CN/jobs-mode.md +14 -0
  79. package/templates/common/output-styles/zh-CN/linus-mode.md +14 -0
  80. package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +14 -0
  81. package/templates/common/workflow/linearMethod/zh-CN/linear-method.md +2 -0
  82. package/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +2 -0
  83. package/templates/common/workflow/sixStep/zh-CN/workflow.md +2 -0
  84. package/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +2 -0
@@ -0,0 +1,153 @@
1
+ ---
2
+ id: pre-commit-eslint
3
+ type: PreToolUse
4
+ name: ESLint Pre-commit Hook
5
+ description: Automatically run ESLint with auto-fix before git commits
6
+ priority: 10
7
+ matcher: Bash(git commit *)
8
+ command: npx eslint --fix .
9
+ timeout: 30000
10
+ enabled: true
11
+ applicableTo: [typescript, javascript, react, vue, node]
12
+ ---
13
+
14
+ # ESLint Pre-commit Hook
15
+
16
+ ## Description
17
+
18
+ This hook automatically runs ESLint with the `--fix` flag before every git commit, ensuring code quality and consistent formatting. It will attempt to automatically fix linting issues and prevent commits if unfixable errors remain.
19
+
20
+ ## 描述
21
+
22
+ 此钩子在每次 git 提交前自动运行 ESLint 并使用 `--fix` 标志,确保代码质量和一致的格式。它会尝试自动修复 lint 问题,如果存在无法修复的错误则阻止提交。
23
+
24
+ ## When it runs
25
+
26
+ - **Trigger**: Before any `git commit` command
27
+ - **Condition**: When ESLint configuration is detected (`.eslintrc.*` or `eslint` in package.json)
28
+ - **Scope**: Runs on all staged files
29
+
30
+ ## 运行时机
31
+
32
+ - **触发器**: 任何 `git commit` 命令之前
33
+ - **条件**: 检测到 ESLint 配置时(`.eslintrc.*` 或 package.json 中的 `eslint`)
34
+ - **范围**: 在所有暂存文件上运行
35
+
36
+ ## Configuration
37
+
38
+ ### Prerequisites
39
+ ```bash
40
+ # Install ESLint if not already installed
41
+ npm install --save-dev eslint
42
+
43
+ # Initialize ESLint configuration
44
+ npx eslint --init
45
+ ```
46
+
47
+ ### Custom ESLint Configuration
48
+ ```json
49
+ // .eslintrc.json
50
+ {
51
+ "extends": ["@antfu/eslint-config"],
52
+ "rules": {
53
+ "no-console": "warn",
54
+ "no-unused-vars": "error"
55
+ }
56
+ }
57
+ ```
58
+
59
+ ### Hook Configuration
60
+ ```yaml
61
+ # In your CCJK configuration
62
+ hooks:
63
+ pre-commit-eslint:
64
+ enabled: true
65
+ command: "npx eslint --fix ."
66
+ timeout: 30000
67
+ failOnError: true
68
+ ```
69
+
70
+ ## 配置
71
+
72
+ ### 前置条件
73
+ ```bash
74
+ # 如果尚未安装 ESLint,请安装
75
+ npm install --save-dev eslint
76
+
77
+ # 初始化 ESLint 配置
78
+ npx eslint --init
79
+ ```
80
+
81
+ ### 自定义 ESLint 配置
82
+ ```json
83
+ // .eslintrc.json
84
+ {
85
+ "extends": ["@antfu/eslint-config"],
86
+ "rules": {
87
+ "no-console": "warn",
88
+ "no-unused-vars": "error"
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## Customization
94
+
95
+ ### Skip Hook for Specific Commits
96
+ ```bash
97
+ # Skip all pre-commit hooks
98
+ git commit --no-verify -m "emergency fix"
99
+
100
+ # Or use environment variable
101
+ SKIP_HOOKS=true git commit -m "skip hooks"
102
+ ```
103
+
104
+ ### Custom Command Override
105
+ ```yaml
106
+ hooks:
107
+ pre-commit-eslint:
108
+ command: "npx eslint --fix --ext .js,.ts,.vue src/"
109
+ include: ["src/**/*"]
110
+ exclude: ["dist/**/*", "node_modules/**/*"]
111
+ ```
112
+
113
+ ### Integration with Staged Files Only
114
+ ```yaml
115
+ hooks:
116
+ pre-commit-eslint:
117
+ command: "npx lint-staged"
118
+ # Requires lint-staged configuration in package.json
119
+ ```
120
+
121
+ ## 自定义
122
+
123
+ ### 跳过特定提交的钩子
124
+ ```bash
125
+ # 跳过所有预提交钩子
126
+ git commit --no-verify -m "紧急修复"
127
+
128
+ # 或使用环境变量
129
+ SKIP_HOOKS=true git commit -m "跳过钩子"
130
+ ```
131
+
132
+ ### 自定义命令覆盖
133
+ ```yaml
134
+ hooks:
135
+ pre-commit-eslint:
136
+ command: "npx eslint --fix --ext .js,.ts,.vue src/"
137
+ include: ["src/**/*"]
138
+ exclude: ["dist/**/*", "node_modules/**/*"]
139
+ ```
140
+
141
+ ## Error Handling
142
+
143
+ - **Auto-fixable errors**: Automatically fixed and commit continues
144
+ - **Non-fixable errors**: Commit is blocked with error details
145
+ - **Timeout**: Hook fails after 30 seconds
146
+ - **Missing ESLint**: Hook is skipped with warning
147
+
148
+ ## 错误处理
149
+
150
+ - **可自动修复的错误**: 自动修复并继续提交
151
+ - **不可修复的错误**: 阻止提交并显示错误详情
152
+ - **超时**: 30 秒后钩子失败
153
+ - **缺少 ESLint**: 跳过钩子并显示警告
@@ -0,0 +1,284 @@
1
+ ---
2
+ id: pre-commit-gofmt
3
+ type: PreToolUse
4
+ name: Go Format Pre-commit Hook
5
+ description: Automatically format Go code with gofmt before git commits
6
+ priority: 10
7
+ matcher: Bash(git commit *)
8
+ command: gofmt -w .
9
+ timeout: 30000
10
+ enabled: true
11
+ applicableTo: [go, golang]
12
+ ---
13
+
14
+ # Go Format Pre-commit Hook
15
+
16
+ ## Description
17
+
18
+ This hook automatically runs `gofmt` to format Go code before every git commit. Go's official formatter ensures consistent code formatting across all Go projects with zero configuration.
19
+
20
+ ## 描述
21
+
22
+ 此钩子在每次 git 提交前自动运行 `gofmt` 格式化 Go 代码。Go 的官方格式化工具确保所有 Go 项目的代码格式一致,无需任何配置。
23
+
24
+ ## When it runs
25
+
26
+ - **Trigger**: Before any `git commit` command
27
+ - **Condition**: When Go files (`.go`) are detected in the project
28
+ - **Scope**: Runs on all Go files in the project recursively
29
+
30
+ ## 运行时机
31
+
32
+ - **触发器**: 任何 `git commit` 命令之前
33
+ - **条件**: 在项目中检测到 Go 文件(`.go`)时
34
+ - **范围**: 递归地在项目中所有 Go 文件上运行
35
+
36
+ ## Configuration
37
+
38
+ ### Prerequisites
39
+ ```bash
40
+ # Go should be installed with gofmt included
41
+ go version
42
+
43
+ # Verify gofmt is available
44
+ gofmt -h
45
+ ```
46
+
47
+ ### Basic Hook Configuration
48
+ ```yaml
49
+ # In your CCJK configuration
50
+ hooks:
51
+ pre-commit-gofmt:
52
+ enabled: true
53
+ command: "gofmt -w ."
54
+ timeout: 30000
55
+ recursive: true
56
+ ```
57
+
58
+ ### Go Module Structure
59
+ ```
60
+ project/
61
+ ├── go.mod
62
+ ├── go.sum
63
+ ├── main.go
64
+ ├── cmd/
65
+ │ └── app/
66
+ │ └── main.go
67
+ ├── internal/
68
+ │ ├── handler/
69
+ │ │ └── handler.go
70
+ │ └── service/
71
+ │ └── service.go
72
+ └── pkg/
73
+ └── utils/
74
+ └── utils.go
75
+ ```
76
+
77
+ ## 配置
78
+
79
+ ### 前置条件
80
+ ```bash
81
+ # 应该安装 Go,其中包含 gofmt
82
+ go version
83
+
84
+ # 验证 gofmt 可用
85
+ gofmt -h
86
+ ```
87
+
88
+ ### 基本钩子配置
89
+ ```yaml
90
+ # 在您的 CCJK 配置中
91
+ hooks:
92
+ pre-commit-gofmt:
93
+ enabled: true
94
+ command: "gofmt -w ."
95
+ timeout: 30000
96
+ recursive: true
97
+ ```
98
+
99
+ ## Customization
100
+
101
+ ### Format Specific Directories Only
102
+ ```yaml
103
+ hooks:
104
+ pre-commit-gofmt:
105
+ command: "gofmt -w ./cmd ./internal ./pkg"
106
+ include: ["cmd/**/*.go", "internal/**/*.go", "pkg/**/*.go"]
107
+ ```
108
+
109
+ ### Check Format Without Writing
110
+ ```yaml
111
+ hooks:
112
+ pre-commit-gofmt:
113
+ command: "gofmt -d ."
114
+ failOnUnformatted: true
115
+ description: "Check Go formatting without modifying files"
116
+ ```
117
+
118
+ ### Use goimports Instead
119
+ ```yaml
120
+ hooks:
121
+ pre-commit-goimports:
122
+ command: "goimports -w ."
123
+ priority: 10
124
+ description: "Format Go code and organize imports"
125
+ ```
126
+
127
+ ### Combine with Other Go Tools
128
+ ```yaml
129
+ hooks:
130
+ pre-commit-gofmt:
131
+ command: "gofmt -w ."
132
+ priority: 12
133
+ pre-commit-goimports:
134
+ command: "goimports -w ."
135
+ priority: 11
136
+ pre-commit-golint:
137
+ command: "golangci-lint run --fix"
138
+ priority: 10
139
+ ```
140
+
141
+ ### Exclude Generated Files
142
+ ```yaml
143
+ hooks:
144
+ pre-commit-gofmt:
145
+ command: "find . -name '*.go' -not -path './vendor/*' -not -name '*_gen.go' -exec gofmt -w {} +"
146
+ exclude: ["vendor/**/*", "*_gen.go", "*.pb.go"]
147
+ ```
148
+
149
+ ## 自定义
150
+
151
+ ### 仅格式化特定目录
152
+ ```yaml
153
+ hooks:
154
+ pre-commit-gofmt:
155
+ command: "gofmt -w ./cmd ./internal ./pkg"
156
+ include: ["cmd/**/*.go", "internal/**/*.go", "pkg/**/*.go"]
157
+ ```
158
+
159
+ ### 检查格式而不写入
160
+ ```yaml
161
+ hooks:
162
+ pre-commit-gofmt:
163
+ command: "gofmt -d ."
164
+ failOnUnformatted: true
165
+ description: "检查 Go 格式而不修改文件"
166
+ ```
167
+
168
+ ### 使用 goimports 替代
169
+ ```yaml
170
+ hooks:
171
+ pre-commit-goimports:
172
+ command: "goimports -w ."
173
+ priority: 10
174
+ description: "格式化 Go 代码并整理导入"
175
+ ```
176
+
177
+ ## Error Handling
178
+
179
+ - **Formatting applied**: Go files are automatically formatted and commit continues
180
+ - **Syntax errors**: Commit is blocked with Go syntax error details
181
+ - **Timeout**: Hook fails after 30 seconds
182
+ - **Missing gofmt**: Hook is skipped with Go installation instructions
183
+ - **Permission errors**: Hook fails with file access error details
184
+
185
+ ## 错误处理
186
+
187
+ - **应用格式化**: Go 文件自动格式化并继续提交
188
+ - **语法错误**: 阻止提交并显示 Go 语法错误详情
189
+ - **超时**: 30 秒后钩子失败
190
+ - **缺少 gofmt**: 跳过钩子并显示 Go 安装说明
191
+ - **权限错误**: 钩子失败并显示文件访问错误详情
192
+
193
+ ## Advanced Configuration
194
+
195
+ ### Integration with Go Modules
196
+ ```yaml
197
+ hooks:
198
+ pre-commit-go-mod-tidy:
199
+ command: "go mod tidy"
200
+ priority: 13
201
+ pre-commit-gofmt:
202
+ command: "gofmt -w ."
203
+ priority: 12
204
+ pre-commit-go-vet:
205
+ command: "go vet ./..."
206
+ priority: 11
207
+ ```
208
+
209
+ ### Custom gofmt Options
210
+ ```yaml
211
+ hooks:
212
+ pre-commit-gofmt:
213
+ command: "gofmt -s -w ." # -s flag simplifies code
214
+ description: "Format and simplify Go code"
215
+ ```
216
+
217
+ ### Cross-Platform Compatibility
218
+ ```yaml
219
+ hooks:
220
+ pre-commit-gofmt:
221
+ command: |
222
+ if command -v gofmt >/dev/null 2>&1; then
223
+ gofmt -w .
224
+ else
225
+ echo "gofmt not found, please install Go"
226
+ exit 1
227
+ fi
228
+ ```
229
+
230
+ ## 高级配置
231
+
232
+ ### 与 Go Modules 集成
233
+ ```yaml
234
+ hooks:
235
+ pre-commit-go-mod-tidy:
236
+ command: "go mod tidy"
237
+ priority: 13
238
+ pre-commit-gofmt:
239
+ command: "gofmt -w ."
240
+ priority: 12
241
+ pre-commit-go-vet:
242
+ command: "go vet ./..."
243
+ priority: 11
244
+ ```
245
+
246
+ ### 自定义 gofmt 选项
247
+ ```yaml
248
+ hooks:
249
+ pre-commit-gofmt:
250
+ command: "gofmt -s -w ." # -s 标志简化代码
251
+ description: "格式化并简化 Go 代码"
252
+ ```
253
+
254
+ ## Performance Tips
255
+
256
+ ### Use Go Build Cache
257
+ ```bash
258
+ # Enable Go build cache for faster operations
259
+ export GOCACHE=$(go env GOCACHE)
260
+ ```
261
+
262
+ ### Parallel Processing for Large Projects
263
+ ```yaml
264
+ hooks:
265
+ pre-commit-gofmt:
266
+ command: "find . -name '*.go' -not -path './vendor/*' | xargs -P 4 -I {} gofmt -w {}"
267
+ description: "Format Go files in parallel"
268
+ ```
269
+
270
+ ## 性能提示
271
+
272
+ ### 使用 Go 构建缓存
273
+ ```bash
274
+ # 启用 Go 构建缓存以加快操作速度
275
+ export GOCACHE=$(go env GOCACHE)
276
+ ```
277
+
278
+ ### 大型项目的并行处理
279
+ ```yaml
280
+ hooks:
281
+ pre-commit-gofmt:
282
+ command: "find . -name '*.go' -not -path './vendor/*' | xargs -P 4 -I {} gofmt -w {}"
283
+ description: "并行格式化 Go 文件"
284
+ ```
@@ -0,0 +1,212 @@
1
+ ---
2
+ id: pre-commit-prettier
3
+ type: PreToolUse
4
+ name: Prettier Pre-commit Hook
5
+ description: Automatically format code with Prettier before git commits
6
+ priority: 9
7
+ matcher: Bash(git commit *)
8
+ command: npx prettier --write .
9
+ timeout: 30000
10
+ enabled: true
11
+ applicableTo: [all]
12
+ ---
13
+
14
+ # Prettier Pre-commit Hook
15
+
16
+ ## Description
17
+
18
+ This hook automatically runs Prettier to format code before every git commit, ensuring consistent code formatting across the entire project. It supports all file types that Prettier can handle.
19
+
20
+ ## 描述
21
+
22
+ 此钩子在每次 git 提交前自动运行 Prettier 格式化代码,确保整个项目的代码格式一致。它支持 Prettier 能够处理的所有文件类型。
23
+
24
+ ## When it runs
25
+
26
+ - **Trigger**: Before any `git commit` command
27
+ - **Condition**: When Prettier configuration is detected (`.prettierrc.*` or `prettier` in package.json)
28
+ - **Scope**: Runs on all supported files in the project
29
+
30
+ ## 运行时机
31
+
32
+ - **触发器**: 任何 `git commit` 命令之前
33
+ - **条件**: 检测到 Prettier 配置时(`.prettierrc.*` 或 package.json 中的 `prettier`)
34
+ - **范围**: 在项目中所有支持的文件上运行
35
+
36
+ ## Configuration
37
+
38
+ ### Prerequisites
39
+ ```bash
40
+ # Install Prettier if not already installed
41
+ npm install --save-dev prettier
42
+
43
+ # Create basic configuration
44
+ echo '{}' > .prettierrc.json
45
+ ```
46
+
47
+ ### Prettier Configuration
48
+ ```json
49
+ // .prettierrc.json
50
+ {
51
+ "semi": false,
52
+ "singleQuote": true,
53
+ "tabWidth": 2,
54
+ "trailingComma": "es5",
55
+ "printWidth": 100,
56
+ "endOfLine": "lf"
57
+ }
58
+ ```
59
+
60
+ ### Ignore Files
61
+ ```gitignore
62
+ # .prettierignore
63
+ dist/
64
+ build/
65
+ coverage/
66
+ node_modules/
67
+ *.min.js
68
+ *.min.css
69
+ ```
70
+
71
+ ### Hook Configuration
72
+ ```yaml
73
+ # In your CCJK configuration
74
+ hooks:
75
+ pre-commit-prettier:
76
+ enabled: true
77
+ command: "npx prettier --write ."
78
+ timeout: 30000
79
+ checkFormatted: true
80
+ ```
81
+
82
+ ## 配置
83
+
84
+ ### 前置条件
85
+ ```bash
86
+ # 如果尚未安装 Prettier,请安装
87
+ npm install --save-dev prettier
88
+
89
+ # 创建基本配置
90
+ echo '{}' > .prettierrc.json
91
+ ```
92
+
93
+ ### Prettier 配置
94
+ ```json
95
+ // .prettierrc.json
96
+ {
97
+ "semi": false,
98
+ "singleQuote": true,
99
+ "tabWidth": 2,
100
+ "trailingComma": "es5",
101
+ "printWidth": 100,
102
+ "endOfLine": "lf"
103
+ }
104
+ ```
105
+
106
+ ## Customization
107
+
108
+ ### Format Specific File Types Only
109
+ ```yaml
110
+ hooks:
111
+ pre-commit-prettier:
112
+ command: "npx prettier --write '**/*.{js,ts,json,md,yml,yaml}'"
113
+ include: ["src/**/*", "docs/**/*"]
114
+ ```
115
+
116
+ ### Check Format Without Writing
117
+ ```yaml
118
+ hooks:
119
+ pre-commit-prettier:
120
+ command: "npx prettier --check ."
121
+ failOnUnformatted: true
122
+ ```
123
+
124
+ ### Integration with lint-staged
125
+ ```json
126
+ // package.json
127
+ {
128
+ "lint-staged": {
129
+ "*.{js,ts,json,md,yml,yaml}": ["prettier --write"]
130
+ }
131
+ }
132
+ ```
133
+
134
+ ```yaml
135
+ hooks:
136
+ pre-commit-prettier:
137
+ command: "npx lint-staged"
138
+ ```
139
+
140
+ ### Skip Specific Files
141
+ ```yaml
142
+ hooks:
143
+ pre-commit-prettier:
144
+ command: "npx prettier --write . --ignore-path .prettierignore"
145
+ exclude: ["legacy/**/*", "vendor/**/*"]
146
+ ```
147
+
148
+ ## 自定义
149
+
150
+ ### 仅格式化特定文件类型
151
+ ```yaml
152
+ hooks:
153
+ pre-commit-prettier:
154
+ command: "npx prettier --write '**/*.{js,ts,json,md,yml,yaml}'"
155
+ include: ["src/**/*", "docs/**/*"]
156
+ ```
157
+
158
+ ### 检查格式而不写入
159
+ ```yaml
160
+ hooks:
161
+ pre-commit-prettier:
162
+ command: "npx prettier --check ."
163
+ failOnUnformatted: true
164
+ ```
165
+
166
+ ## Error Handling
167
+
168
+ - **Formatting applied**: Files are automatically formatted and commit continues
169
+ - **Parse errors**: Commit is blocked with syntax error details
170
+ - **Timeout**: Hook fails after 30 seconds
171
+ - **Missing Prettier**: Hook is skipped with warning
172
+ - **Permission errors**: Hook fails with file access error details
173
+
174
+ ## 错误处理
175
+
176
+ - **应用格式化**: 文件自动格式化并继续提交
177
+ - **解析错误**: 阻止提交并显示语法错误详情
178
+ - **超时**: 30 秒后钩子失败
179
+ - **缺少 Prettier**: 跳过钩子并显示警告
180
+ - **权限错误**: 钩子失败并显示文件访问错误详情
181
+
182
+ ## Performance Tips
183
+
184
+ ### Use .prettierignore for Large Projects
185
+ ```gitignore
186
+ # .prettierignore
187
+ node_modules/
188
+ dist/
189
+ build/
190
+ coverage/
191
+ *.min.*
192
+ public/vendor/
193
+ ```
194
+
195
+ ### Optimize for Staged Files Only
196
+ ```bash
197
+ # Use with lint-staged for better performance
198
+ npx lint-staged
199
+ ```
200
+
201
+ ## 性能提示
202
+
203
+ ### 为大型项目使用 .prettierignore
204
+ ```gitignore
205
+ # .prettierignore
206
+ node_modules/
207
+ dist/
208
+ build/
209
+ coverage/
210
+ *.min.*
211
+ public/vendor/
212
+ ```