1# Pre-commit configuration for Teal project
2# Install with: pip install pre-commit && pre-commit install
3# Run manually with: pre-commit run --all-files
4
5repos:
6 # General file checks
7 - repo: https://github.com/pre-commit/pre-commit-hooks
8 rev: v4.6.0
9 hooks:
10 - id: trailing-whitespace
11 - id: end-of-file-fixer
12 - id: check-yaml
13 - id: check-json
14 - id: check-toml
15 - id: check-merge-conflict
16 - id: check-added-large-files
17 args: ["--maxkb=500"]
18 - id: mixed-line-ending
19 args: ["--fix=lf"]
20
21 # TypeScript/JavaScript formatting and linting
22 - repo: local
23 hooks:
24 - id: prettier
25 name: Prettier
26 entry: pnpm prettier --write
27 language: system
28 files: \.(ts|tsx|js|jsx|json|md|yaml|yml)$
29 pass_filenames: true
30
31 - id: biome-check
32 name: Biome Check
33 entry: pnpm biome check --apply
34 language: system
35 files: \.(ts|tsx|js|jsx)$
36 pass_filenames: false
37
38 # TypeScript check temporarily disabled due to vendor compilation issues
39 # - id: typescript-check
40 # name: TypeScript Check
41 # entry: pnpm typecheck
42 # language: system
43 # files: \.(ts|tsx)$
44 # pass_filenames: false
45
46 # Rust formatting and linting
47 - repo: local
48 hooks:
49 - id: cargo-fmt-services
50 name: Cargo Format (Services Workspace)
51 entry: bash -c 'cd services && cargo fmt'
52 language: system
53 files: services/.*\.rs$
54 pass_filenames: false
55
56 - id: cargo-clippy-services
57 name: Cargo Clippy (Services Workspace)
58 entry: bash -c 'cd services && cargo clippy -- -D warnings'
59 language: system
60 files: services/.*\.rs$
61 pass_filenames: false
62
63 - id: cargo-fmt-apps
64 name: Cargo Format (Apps)
65 entry: bash -c 'for dir in apps/*/; do if [ -f "$dir/Cargo.toml" ]; then cd "$dir" && cargo fmt && cd ../..; fi; done'
66 language: system
67 files: apps/.*\.rs$
68 pass_filenames: false
69
70 - id: cargo-clippy-apps
71 name: Cargo Clippy (Apps)
72 entry: bash -c 'for dir in apps/*/; do if [ -f "$dir/Cargo.toml" ]; then cd "$dir" && cargo clippy -- -D warnings && cd ../..; fi; done'
73 language: system
74 files: apps/.*\.rs$
75 pass_filenames: false
76
77 # Lexicon validation and generation
78 - repo: local
79 hooks:
80 - id: lexicon-validate
81 name: Validate Lexicons
82 entry: pnpm lex:validate
83 language: system
84 files: lexicons/.*\.json$
85 pass_filenames: false
86
87 - id: lexicon-generate
88 name: Generate Lexicons (files ignored by .gitignore)
89 entry: pnpm lex:gen-server
90 language: system
91 files: lexicons/.*\.json$
92 pass_filenames: false
93 always_run: false
94
95 # Optional: Additional checks
96 - repo: local
97 hooks:
98 - id: no-console-log
99 name: Check for console.log
100 entry: bash -c 'if grep -r "console\.log" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" .; then echo "Found console.log statements. Please remove them."; exit 1; fi'
101 language: system
102 files: \.(ts|tsx|js|jsx)$
103 pass_filenames: false
104
105 - id: check-todos
106 name: Check for TODO/FIXME
107 entry: bash -c 'if grep -r -i "TODO\|FIXME" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.rs" .; then echo "Found TODO/FIXME comments. Consider addressing them."; fi'
108 language: system
109 files: \.(ts|tsx|js|jsx|rs)$
110 pass_filenames: false
111 verbose: true
112
113# Global settings
114default_language_version:
115 node: system
116 python: python3
117
118# Skip certain hooks for specific file patterns
119exclude: |
120 (?x)^(
121 vendor/.*|
122 node_modules/.*|
123 target/.*|
124 .git/.*|
125 .*\.lock$
126 )$