Shell
#!/bin/bash
# Accessibility Check: Ensures UI components are accessible
FILE_PATH="$1"
FILE_EXT="${FILE_PATH##*.}"
# Only check React/UI components
if [[ "$FILE_EXT" == "tsx" ]] || [[ "$FILE_EXT" == "jsx" ]]; then
# Check for common accessibility issues
ISSUES=0
# Check for buttons without aria-labels
if grep -q "<button" "$FILE_PATH"; then
if ! grep -q "aria-label" "$FILE_PATH"; then
echo "⚠️ Accessibility: Buttons should have aria-labels"
ISSUES=$((ISSUES + 1))
fi
fi
# Check for images without alt text
if grep -q "<img" "$FILE_PATH"; then
if ! grep -q "alt=" "$FILE_PATH"; then
echo "⚠️ Accessibility: Images should have alt text"
ISSUES=$((ISSUES + 1))
fi
fi
# Check for form inputs without labels
if grep -q "<input" "$FILE_PATH"; then
if ! grep -qE "(aria-label|<label)" "$FILE_PATH"; then
echo "⚠️ Accessibility: Form inputs should have labels"
ISSUES=$((ISSUES + 1))
fi
fi
if [ $ISSUES -gt 0 ]; then
echo "♿ Found $ISSUES accessibility issues - Claude will fix"
echo "CLAUDE_ACTION: fix_accessibility"
exit 1
fi
fi
exit 0