Skip to content

Check_controls

FieldValue
TypeSkill Resource
Source~/.copilot/skills/frontend/scripts/check_controls.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
# Check that a *.stories.tsx file's argTypes cover the component's real props.
#
# Usage: check_controls.sh <Component.tsx> <Component.stories.tsx>
#
# Heuristic, not a full TS parser: pulls prop names out of the Props interface
# and flags any that never appear in an `argTypes` block in the story file.
set -uo pipefail
COMPONENT="${1:-}"
STORY="${2:-}"
fail=0
if [[ -z "$COMPONENT" || -z "$STORY" || ! -f "$COMPONENT" || ! -f "$STORY" ]]; then
echo "Usage: $0 <Component.tsx> <Component.stories.tsx>" >&2
exit 2
fi
if ! grep -q 'argTypes' "$STORY"; then
echo "❌ no argTypes block found in $STORY"
fail=1
else
echo "✅ argTypes block present"
fi
props=$(awk '/interface .*Props/{flag=1; next} /^}/{flag=0} flag' "$COMPONENT" \
| grep -oE '^\s*[a-zA-Z][a-zA-Z0-9_]*\??:' | sed -E 's/[?:[:space:]]//g')
missing=()
for p in $props; do
grep -q "\b${p}\s*:" "$STORY" || missing+=("$p")
done
if [[ ${#missing[@]} -gt 0 ]]; then
echo "❌ props with no matching argTypes entry: ${missing[*]}"
fail=1
else
echo "✅ every declared prop has an argTypes entry (or file has no exported Props interface to check)"
fi
exit "$fail"