# Stylelint wrapper for the design skill. Run only when .css files changed.
# Resolves stylelint in order:
# 1. repo-local ./node_modules/.bin/stylelint (project's own config)
# 2. skill-level ~/.copilot/skills/design/references/assets/stylelint/
# node_modules/.bin/stylelint (config from that dir)
# 4. none found → warn and exit 0 (graceful skip, never a failure)
# Usage: lint_css.sh FILE.css [FILE.css ...]
echo "Usage: lint_css.sh FILE.css [FILE.css ...]" >&2
SKILL_STYLELINT_DIR="${HOME}/.copilot/skills/design/references/assets/stylelint"
if [ -x "./node_modules/.bin/stylelint" ]; then
exec "./node_modules/.bin/stylelint" --fix "$@"
elif [ -x "${SKILL_STYLELINT_DIR}/node_modules/.bin/stylelint" ]; then
exec "${SKILL_STYLELINT_DIR}/node_modules/.bin/stylelint" \
--config "${SKILL_STYLELINT_DIR}/stylelint.config.mjs" --fix "$@"
elif command -v stylelint >/dev/null 2>&1; then
exec stylelint --fix "$@"
echo "WARNING (stylelint): not installed — skipping." >&2
echo "Install once at the skill level: cd ${SKILL_STYLELINT_DIR} && npm install" >&2