|
| 1 | +{ |
| 2 | + "hooks": { |
| 3 | + "PreToolUse": [ |
| 4 | + { |
| 5 | + "matcher": "Bash", |
| 6 | + "hooks": [ |
| 7 | + { |
| 8 | + "type": "command", |
| 9 | + "command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q -- '--no-verify'; then echo '{\"decision\": \"block\", \"reason\": \"Do not skip pre-commit hooks. Fix the underlying issue instead.\"}'; exit 2; fi", |
| 10 | + "description": "Block --no-verify on git commits" |
| 11 | + }, |
| 12 | + { |
| 13 | + "type": "command", |
| 14 | + "command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -qE '(from\\s+@mui|import.*@mui|@emotion)'; then echo '{\"decision\": \"block\", \"reason\": \"Do not use MUI or @emotion. Use components from openmetadata-ui-core-components instead. See CLAUDE.md for details.\"}'; exit 2; fi", |
| 15 | + "description": "Block new MUI/emotion imports" |
| 16 | + } |
| 17 | + ] |
| 18 | + } |
| 19 | + ], |
| 20 | + "PostToolUse": [ |
| 21 | + { |
| 22 | + "matcher": "Edit", |
| 23 | + "hooks": [ |
| 24 | + { |
| 25 | + "type": "command", |
| 26 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.java$'; then echo 'Reminder: run `mvn spotless:apply` before committing Java changes.'; fi", |
| 27 | + "description": "Remind to format Java after edits" |
| 28 | + }, |
| 29 | + { |
| 30 | + "type": "command", |
| 31 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE 'openmetadata-spec/src/main/resources/json/schema/.*\\.json$'; then echo 'Schema file modified. Remember to run `make generate` to regenerate Pydantic models and rebuild dependent modules.'; fi", |
| 32 | + "description": "Remind to regenerate after schema changes" |
| 33 | + }, |
| 34 | + { |
| 35 | + "type": "command", |
| 36 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE 'openmetadata-spec/src/main/resources/json/schema/entity/services/connections/.*\\.json$'; then echo 'Connection schema modified. Remember to run `yarn parse-schema` to update resolved schemas for the UI.'; fi", |
| 37 | + "description": "Remind to parse connection schemas for UI" |
| 38 | + }, |
| 39 | + { |
| 40 | + "type": "command", |
| 41 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); CONTENT=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.new_string // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.(ts|tsx)$' && echo \"$CONTENT\" | grep -qE ': any[^A-Za-z]|: any$|<any>|as any'; then echo 'Warning: `any` type detected in TypeScript. Use proper types, `unknown` with type guards, or import from generated types. See CLAUDE.md.'; fi", |
| 42 | + "description": "Warn about any type in TypeScript" |
| 43 | + }, |
| 44 | + { |
| 45 | + "type": "command", |
| 46 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); CONTENT=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.new_string // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.(ts|tsx)$' && echo \"$CONTENT\" | grep -qE 'console\\.(log|warn|error|info|debug)'; then echo 'Warning: `console.*` detected in TypeScript. Remove before committing — CI lint-src will fail (no-console rule).'; fi", |
| 47 | + "description": "Warn about console.log in TypeScript" |
| 48 | + }, |
| 49 | + { |
| 50 | + "type": "command", |
| 51 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE 'locale/languages/en-us\\.json$'; then echo 'i18n key added. Run `yarn i18n` to sync all 17 locale files before committing — CI i18n-sync will fail otherwise.'; fi", |
| 52 | + "description": "Remind to run i18n sync after adding keys" |
| 53 | + } |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "matcher": "Write", |
| 58 | + "hooks": [ |
| 59 | + { |
| 60 | + "type": "command", |
| 61 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.java$'; then echo 'Reminder: run `mvn spotless:apply` before committing Java changes.'; fi", |
| 62 | + "description": "Remind to format Java after writes" |
| 63 | + }, |
| 64 | + { |
| 65 | + "type": "command", |
| 66 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); CONTENT=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.content // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.(ts|tsx)$' && echo \"$CONTENT\" | grep -qE 'import.*from.*@mui|import.*from.*@emotion'; then echo 'Warning: MUI/@emotion import detected. Use components from openmetadata-ui-core-components instead. See CLAUDE.md.'; fi", |
| 67 | + "description": "Warn about MUI imports in new files" |
| 68 | + }, |
| 69 | + { |
| 70 | + "type": "command", |
| 71 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); CONTENT=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.content // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.(ts|tsx|js|jsx)$'; then HAS_LICENSE=$(echo \"$CONTENT\" | head -5 | grep -c 'Copyright.*Collate'); if [ \"$HAS_LICENSE\" -eq 0 ]; then echo 'Warning: New file missing Apache 2.0 license header. CI license-header check will fail. Add the standard header or run `yarn license-header-fix`.'; fi; fi", |
| 72 | + "description": "Warn about missing license header in new files" |
| 73 | + }, |
| 74 | + { |
| 75 | + "type": "command", |
| 76 | + "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.file_path // empty' 2>/dev/null); CONTENT=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.content // empty' 2>/dev/null); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE '\\.(ts|tsx)$' && echo \"$CONTENT\" | grep -qE 'console\\.(log|warn|error|info|debug)'; then echo 'Warning: `console.*` in new file. CI lint-src will fail (no-console rule). Use the logger or remove.'; fi", |
| 77 | + "description": "Warn about console.log in new files" |
| 78 | + } |
| 79 | + ] |
| 80 | + } |
| 81 | + ] |
| 82 | + } |
| 83 | +} |
0 commit comments