Skip to content

Check_csf3

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

Source Content

#!/usr/bin/env bash
# Check a *.stories.tsx file follows CSF3 shape: default meta with title +
# component, the tags: ['autodocs'] convention, and at least one named Story
# export using the object form (not the deprecated CSF2 function-template
# form).
#
# Usage: check_csf3.sh <Component.stories.tsx>
set -uo pipefail
STORY="${1:-}"
fail=0
if [[ -z "$STORY" || ! -f "$STORY" ]]; then
echo "Usage: $0 <Component.stories.tsx>" >&2
exit 2
fi
check() {
if grep -qE "$2" "$STORY"; then
echo "$1"
else
echo "$1"
fail=1
fi
}
check "has a default meta export" 'export default'
check "meta declares a title" 'title:'
check "meta declares a component" 'component:'
check "declares tags: ['autodocs']" "tags:\s*\[[^]]*['\"]autodocs['\"]"
check "has at least one named Story object export" 'export const [A-Za-z0-9_]+: Story'
if grep -qE '\.bind\(\{\}\)|Template\.bind' "$STORY"; then
echo "❌ found CSF2 Template.bind({}) pattern — migrate to CSF3 object stories"
fail=1
else
echo "✅ no deprecated CSF2 Template.bind pattern"
fi
exit "$fail"