Lightweight Frontend Code Health Intelligence Diagnostic Engine
轻量级前端代码健康度智能诊断引擎
WebVitalScan 是一款轻量级前端代码健康度智能诊断引擎,灵感来源于对现代前端项目质量管理的深度思考。它能一键扫描你的前端项目,从 安全、性能、架构、可访问性、正确性、包体积 六大维度进行全面诊断,输出 0-100 的健康评分和可操作的诊断建议。
🎯 解决的核心痛点:
✨ 自研差异化亮点:
pip install 即可使用| 特性 | 描述 |
|---|---|
| 🔒 安全检测 | XSS 风险、硬编码密钥、eval 注入、不安全的 HTTP、CORS 配置 |
| ⚡ 性能分析 | 内联样式、大包引入、图片尺寸缺失、console.log、昂贵渲染、列表优化 |
| 🏗️ 架构诊断 | 巨型组件、Props 穿透、直接 DOM 操作、关注点混合、Index 作为 Key |
| ♿ 可访问性 | 图片 Alt 文本缺失、表单 Label 缺失、低对比度、可点击元素角色缺失 |
| ✅ 正确性检查 | TypeScript any 类型、空 Catch 块、未使用导入、Error Boundary |
| 📦 包体积优化 | 重量级依赖检测、重复依赖引入 |
环境要求: Python 3.8+(无需其他依赖)
# 克隆仓库
git clone https://github.com/gitstq/WebVitalScan.git
cd WebVitalScan
# 直接运行(无需安装依赖)
python3 webvitalscan.py /path/to/your/project
# 或安装后使用
pip install -e .
webvitalscan /path/to/your/project
常用命令:
# 基础扫描
webvitalscan ./my-react-app
# 详细输出(含代码片段)
webvitalscan ./my-project --verbose
# 输出 HTML 报告
webvitalscan ./src -o html -f report.html
# 输出 JSON(适合 CI/CD)
webvitalscan . -o json -f result.json
# 输出 SARIF(GitHub Code Scanning)
webvitalscan . -o sarif -f results.sarif
# 排除测试文件
webvitalscan . --exclude "test_|spec_|mock_"
# 仅显示严重问题
webvitalscan . --min-severity error
| 格式 | 参数 | 用途 |
|---|---|---|
| 🖥️ Terminal | -o terminal(默认) |
开发时快速查看,彩色输出 |
| 📄 JSON | -o json |
CI/CD 流水线集成、自动化处理 |
| 🌐 HTML | -o html |
团队分享、存档记录、可视化分析 |
| 📋 SARIF | -o sarif |
GitHub Code Scanning、VS Code 集成 |
| 分数 | 等级 | 含义 |
|---|---|---|
| 90-100 | A+ | 🟢 优秀,代码质量很高 |
| 80-89 | A | 🟢 良好,仅有少量建议 |
| 70-79 | B | 🟡 一般,存在需要关注的问题 |
| 60-69 | C | 🟡 较差,建议尽快修复 |
| 50-59 | D | 🔴 差,存在严重问题 |
| 0-49 | F | 🔴 极差,需要立即重构 |
# GitHub Actions 示例
name: WebVitalScan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -e .
- run: webvitalscan . -o sarif -f results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
设计理念:
后续迭代计划:
欢迎提交 Issue 和 PR!请遵循以下规范:
git checkout -b feature/amazing-rulegit commit -m 'feat: add amazing security rule'git push origin feature/amazing-rule本项目基于 MIT License 开源。
WebVitalScan 是一款輕量級前端程式碼健康度智慧診斷引擎。它能一鍵掃描你的前端專案,從 安全、效能、架構、無障礙、正確性、套件體積 六大維度進行全面診斷,輸出 0-100 的健康評分和可操作的診斷建議。
🎯 解決的核心痛點:
✨ 自研差異化亮點:
pip install 即可使用| 特性 | 描述 |
|---|---|
| 🔒 安全檢測 | XSS 風險、硬編碼密鑰、eval 注入、不安全的 HTTP、CORS 配置 |
| ⚡ 效能分析 | 內聯樣式、大包引入、圖片尺寸缺失、console.log、昂貴渲染、列表優化 |
| 🏗️ 架構診斷 | 巨型元件、Props 穿透、直接 DOM 操作、關注點混合、Index 作為 Key |
| ♿ 無障礙 | 圖片 Alt 文字缺失、表單 Label 缺失、低對比度、可點擊元素角色缺失 |
| ✅ 正確性檢查 | TypeScript any 類型、空 Catch 區塊、未使用導入、Error Boundary |
| 📦 套件體積優化 | 重量級依賴檢測、重複依賴引入 |
環境要求: Python 3.8+(無需其他依賴)
# 克隆倉庫
git clone https://github.com/gitstq/WebVitalScan.git
cd WebVitalScan
# 直接運行(無需安裝依賴)
python3 webvitalscan.py /path/to/your/project
# 或安裝後使用
pip install -e .
webvitalscan /path/to/your/project
常用命令:
# 基礎掃描
webvitalscan ./my-react-app
# 詳細輸出(含程式碼片段)
webvitalscan ./my-project --verbose
# 輸出 HTML 報告
webvitalscan ./src -o html -f report.html
# 輸出 JSON(適合 CI/CD)
webvitalscan . -o json -f result.json
# 輸出 SARIF(GitHub Code Scanning)
webvitalscan . -o sarif -f results.sarif
# 排除測試檔案
webvitalscan . --exclude "test_|spec_|mock_"
# 僅顯示嚴重問題
webvitalscan . --min-severity error
| 格式 | 參數 | 用途 |
|---|---|---|
| 🖥️ Terminal | -o terminal(預設) |
開發時快速查看,彩色輸出 |
| 📄 JSON | -o json |
CI/CD 流水線整合、自動化處理 |
| 🌐 HTML | -o html |
團隊分享、存檔記錄、可視化分析 |
| 📋 SARIF | -o sarif |
GitHub Code Scanning、VS Code 整合 |
| 分數 | 等級 | 含義 |
|---|---|---|
| 90-100 | A+ | 🟢 優秀,程式碼品質很高 |
| 80-89 | A | 🟢 良好,僅有少量建議 |
| 70-79 | B | 🟡 一般,存在需要關注的問題 |
| 60-69 | C | 🟡 較差,建議盡快修復 |
| 50-59 | D | 🔴 差,存在嚴重問題 |
| 0-49 | F | 🔴 極差,需要立即重構 |
設計理念:
後續迭代計劃:
歡迎提交 Issue 和 PR!請遵循以下規範:
git checkout -b feature/amazing-rulegit commit -m 'feat: add amazing security rule'git push origin feature/amazing-rule本專案基於 MIT License 開源。
WebVitalScan is a lightweight frontend code health intelligence diagnostic engine. It scans your frontend project with a single command, performing comprehensive diagnostics across 6 dimensions: Security, Performance, Architecture, Accessibility, Correctness, and Bundle Size — outputting a 0-100 health score with actionable recommendations.
🎯 Core Problems Solved:
✨ Key Differentiators:
| Feature | Description |
|---|---|
| 🔒 Security Detection | XSS risks, hardcoded secrets, eval injection, insecure HTTP, CORS misconfiguration |
| ⚡ Performance Analysis | Inline styles, heavy imports, missing image dimensions, console.log, expensive renders, list optimization |
| 🏗️ Architecture Diagnostics | God components, prop drilling, direct DOM manipulation, mixed concerns, index-as-key |
| ♿ Accessibility | Missing alt text, missing form labels, low contrast, missing ARIA roles |
| ✅ Correctness Checks | TypeScript any types, empty catch blocks, unused imports, Error Boundaries |
| 📦 Bundle Size Optimization | Heavy dependency detection, duplicate dependency imports |
Requirements: Python 3.8+ (no other dependencies needed)
# Clone the repository
git clone https://github.com/gitstq/WebVitalScan.git
cd WebVitalScan
# Run directly (no installation needed)
python3 webvitalscan.py /path/to/your/project
# Or install and use
pip install -e .
webvitalscan /path/to/your/project
Common Commands:
# Basic scan
webvitalscan ./my-react-app
# Verbose output (with code snippets)
webvitalscan ./my-project --verbose
# HTML report
webvitalscan ./src -o html -f report.html
# JSON output (for CI/CD)
webvitalscan . -o json -f result.json
# SARIF output (GitHub Code Scanning)
webvitalscan . -o sarif -f results.sarif
# Exclude test files
webvitalscan . --exclude "test_|spec_|mock_"
# Only show critical issues
webvitalscan . --min-severity error
| Format | Flag | Use Case |
|---|---|---|
| 🖥️ Terminal | -o terminal (default) |
Quick dev-time checks, colorful output |
| 📄 JSON | -o json |
CI/CD pipeline integration, automation |
| 🌐 HTML | -o html |
Team sharing, archiving, visual analysis |
| 📋 SARIF | -o sarif |
GitHub Code Scanning, VS Code integration |
| Score | Grade | Meaning |
|---|---|---|
| 90-100 | A+ | 🟢 Excellent, very high code quality |
| 80-89 | A | 🟢 Good, only minor suggestions |
| 70-79 | B | 🟡 Fair, issues need attention |
| 60-69 | C | 🟡 Poor, fix recommended soon |
| 50-59 | D | 🔴 Bad, serious issues present |
| 0-49 | F | 🔴 Critical, immediate refactoring needed |
# GitHub Actions Example
name: WebVitalScan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -e .
- run: webvitalscan . -o sarif -f results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
Design Principles:
Roadmap:
Issues and PRs are welcome! Please follow these guidelines:
git checkout -b feature/amazing-rulegit commit -m 'feat: add amazing security rule'git push origin feature/amazing-ruleThis project is licensed under the MIT License.
Made with ❤️ by SoloBot