From 3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 Mon Sep 17 00:00:00 2001
From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>
Date: Fri, 16 Jan 2026 08:30:14 +0900
Subject: updates
---
ui/shadcn/.claude/hooks/check-accessibility.sh | 197 +++++++++++++++++++++++++
ui/shadcn/.claude/hooks/format-tailwind.sh | 76 ++++++++++
ui/shadcn/.claude/hooks/optimize-imports.sh | 121 +++++++++++++++
ui/shadcn/.claude/hooks/validate-components.sh | 131 ++++++++++++++++
4 files changed, 525 insertions(+)
create mode 100755 ui/shadcn/.claude/hooks/check-accessibility.sh
create mode 100755 ui/shadcn/.claude/hooks/format-tailwind.sh
create mode 100755 ui/shadcn/.claude/hooks/optimize-imports.sh
create mode 100755 ui/shadcn/.claude/hooks/validate-components.sh
(limited to 'ui/shadcn/.claude/hooks')
diff --git a/ui/shadcn/.claude/hooks/check-accessibility.sh b/ui/shadcn/.claude/hooks/check-accessibility.sh
new file mode 100755
index 0000000..24be077
--- /dev/null
+++ b/ui/shadcn/.claude/hooks/check-accessibility.sh
@@ -0,0 +1,197 @@
+#!/bin/bash
+
+# Check accessibility compliance after component modifications
+# This hook runs after Write/Edit/MultiEdit operations
+
+# Colors for output
+RED='\033[0;31m'
+YELLOW='\033[1;33m'
+GREEN='\033[0;32m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+# Read tool result from stdin
+TOOL_RESULT=$(cat)
+TOOL_NAME=$(echo "$TOOL_RESULT" | jq -r '.tool_name // empty' 2>/dev/null)
+
+# Only process if it's a file modification tool
+if [[ "$TOOL_NAME" != "Write" ]] && [[ "$TOOL_NAME" != "Edit" ]] && [[ "$TOOL_NAME" != "MultiEdit" ]]; then
+ echo "$TOOL_RESULT"
+ exit 0
+fi
+
+# Extract file path
+FILE_PATH=$(echo "$TOOL_RESULT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
+
+# Only process component files
+if [[ ! "$FILE_PATH" =~ \.(tsx?|jsx?)$ ]] || [[ ! "$FILE_PATH" =~ component ]]; then
+ echo "$TOOL_RESULT"
+ exit 0
+fi
+
+# Check if file exists
+if [ ! -f "$FILE_PATH" ]; then
+ echo "$TOOL_RESULT"
+ exit 0
+fi
+
+echo -e "${BLUE}🔍 Checking accessibility in $FILE_PATH...${NC}" >&2
+
+# Initialize counters
+ISSUES=0
+WARNINGS=0
+
+# Function to check patterns
+check_pattern() {
+ local pattern="$1"
+ local message="$2"
+ local type="$3" # "error" or "warning"
+
+ if grep -q "$pattern" "$FILE_PATH"; then
+ if [ "$type" = "error" ]; then
+ echo -e "${RED}❌ A11y Issue: $message${NC}" >&2
+ ((ISSUES++))
+ else
+ echo -e "${YELLOW}⚠️ A11y Warning: $message${NC}" >&2
+ ((WARNINGS++))
+ fi
+ return 1
+ fi
+ return 0
+}
+
+# Function to check for missing patterns
+check_missing() {
+ local pattern="$1"
+ local context="$2"
+ local message="$3"
+
+ if grep -q "$context" "$FILE_PATH"; then
+ if ! grep -q "$pattern" "$FILE_PATH"; then
+ echo -e "${YELLOW}⚠️ A11y Warning: $message${NC}" >&2
+ ((WARNINGS++))
+ return 1
+ fi
+ fi
+ return 0
+}
+
+# Check for interactive elements without keyboard support
+if grep -qE '<(button|a|input|select|textarea)' "$FILE_PATH"; then
+ # Check for onClick without onKeyDown/onKeyPress
+ if grep -q 'onClick=' "$FILE_PATH"; then
+ if ! grep -qE '(onKeyDown|onKeyPress|onKeyUp)=' "$FILE_PATH"; then
+ echo -e "${YELLOW}⚠️ A11y Warning: onClick handlers should have keyboard alternatives${NC}" >&2
+ ((WARNINGS++))
+ fi
+ fi
+
+ # Check for proper button usage
+ if grep -q '
instead of
with onClick for interactive elements${NC}" >&2
+ ((WARNINGS++))
+ fi
+fi
+
+# Check for images without alt text
+if grep -qE ']*>' "$FILE_PATH"; then
+ IMG_TAGS=$(grep -o ']*>' "$FILE_PATH")
+ while IFS= read -r img; do
+ if ! echo "$img" | grep -q 'alt='; then
+ echo -e "${RED}❌ A11y Issue: Image missing alt attribute${NC}" >&2
+ ((ISSUES++))
+ fi
+ done <<< "$IMG_TAGS"
+fi
+
+# Check for form elements
+if grep -qE '<(input|select|textarea)' "$FILE_PATH"; then
+ # Check for labels
+ check_missing "label" "input\|select\|textarea" "Form elements should have associated labels"
+
+ # Check for aria-required on required fields
+ if grep -q 'required' "$FILE_PATH"; then
+ check_missing "aria-required" "required" "Required fields should have aria-required attribute"
+ fi
+
+ # Check for error messages
+ if grep -q 'error' "$FILE_PATH"; then
+ check_missing "aria-describedby\|aria-errormessage" "error" "Error messages should be associated with form fields"
+ fi
+fi
+
+# Check for ARIA attributes
+if grep -q '