#!/bin/bash

echo "🔍 开始代码质量检查..."
echo ""

# 1. TypeScript 类型检查
echo "1️⃣  TypeScript 类型检查"
npx vue-tsc --noEmit 2>&1 | tee type-errors.log | grep -E "error TS" | wc -l
echo ""

# 2. ESLint 检查
echo "2️⃣  ESLint 静态分析"
npx eslint src --ext .vue,.ts,.js 2>&1 | tee eslint-errors.log | wc -l
echo ""

# 3. 统计错误类型
echo "📊 错误统计："
echo "TypeScript 错误："
grep "error TS" type-errors.log | awk '{print $2}' | sort | uniq -c | sort -rn | head -10
echo ""

echo "ESLint 错误："
cat eslint-errors.log | head -20
echo ""

echo "✅ 检查完成！"
echo "详细日志：type-errors.log, eslint-errors.log"
