Skip to content

Check

FieldValue
TypeSkill Resource
Source~/.copilot/skills/design/scripts/check.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
# check.sh — single entrypoint for the design skill's validation.
#
# Orchestrates the existing checks by file type; it does not reimplement any
# check's logic. For a .css file it runs Stylelint + the four Python CSS
# checks. For any .tsx/.jsx/.css it also runs the icon-grid/border heuristic
# and the design-token heuristic (raw hex, palette classes, non-system fonts,
# arbitrary radius). Missing external tools degrade to a warning, never a
# crash (see lint_css.sh). Non-zero exit on any hard failure.
#
# Usage:
# scripts/check.sh <file-or-dir>
#
# Examples:
# scripts/check.sh src/components/ui/Card.tsx
# scripts/check.sh src/components/ui/Card.css
# scripts/check.sh src/components
set -uo pipefail
TARGET="${1:-}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -z "$TARGET" || ! -e "$TARGET" ]]; then
echo "Usage: $0 <file-or-dir>" >&2
exit 2
fi
fail=0
note() { printf '\n== %s ==\n' "$1"; }
run() {
# Run a check; track failure but keep going so every check reports.
"$@"
status=$?
if [[ "$status" -ne 0 ]]; then
fail=1
fi
return 0
}
# ---------------------------------------------------------------------------
# Collect target files by extension.
# ---------------------------------------------------------------------------
css_files=()
tsx_files=()
if [[ -d "$TARGET" ]]; then
while IFS= read -r -d '' f; do css_files+=("$f"); done \
< <(find "$TARGET" -type f -name '*.css' -print0)
while IFS= read -r -d '' f; do tsx_files+=("$f"); done \
< <(find "$TARGET" -type f \( -name '*.tsx' -o -name '*.jsx' \) -print0)
else
case "$TARGET" in
*.css) css_files+=("$TARGET") ;;
*.tsx|*.jsx) tsx_files+=("$TARGET") ;;
*) echo "note: '$TARGET' is neither .css nor .tsx/.jsx — running token/style checks only" ;;
esac
fi
# ---------------------------------------------------------------------------
# CSS files: Stylelint + the four Python checks.
# ---------------------------------------------------------------------------
if [[ "${#css_files[@]}" -gt 0 ]]; then
note "stylelint (${#css_files[@]} .css file(s))"
run bash "${SCRIPT_DIR}/lint_css.sh" "${css_files[@]}"
for f in "${css_files[@]}"; do
note "contrast + theme completeness: $f"
run python3 "${SCRIPT_DIR}/check_contrast.py" "$f"
run python3 "${SCRIPT_DIR}/check_theme_completeness.py" "$f"
done
note "css budget: $TARGET"
run python3 "${SCRIPT_DIR}/check_css_budget.py" "$TARGET"
fi
if [[ -d "$TARGET" ]]; then
note "co-location: $TARGET"
run python3 "${SCRIPT_DIR}/check_colocation.py" "$TARGET"
fi
# ---------------------------------------------------------------------------
# .tsx/.jsx/.css: icon-grid + border heuristic, and token/style heuristics.
# ---------------------------------------------------------------------------
if [[ "${#tsx_files[@]}" -gt 0 || -d "$TARGET" ]]; then
note "icon-grid (ADR-009) + border discipline (ADR-008): $TARGET"
run bash "${SCRIPT_DIR}/lint_design_principles.sh" "$TARGET"
fi
note "design tokens (ADR-001/002/003/006): $TARGET"
run bash "${SCRIPT_DIR}/lint_tokens.sh" "$TARGET"
echo
if [[ "$fail" -eq 0 ]]; then
echo "✅ All checks passed."
else
echo "❌ One or more checks failed — see output above."
fi
exit "$fail"