360 Secure SkillHub
360 安全技能中心

Vitest Config Validator

核心功能:校验vitest.config.ts/js文件的语法错误、废弃选项、插件冲突及最佳实践,无需执行JS。典型场景:验证Vitest测试runner配置、审计测试设置、lint配置文件。通过命令行操作,支持全量验证、语法检查等命令,输出含文本、JSON、单行摘要三种格式,可开启严格模式,按问题 severity 区分并返回对应退出码。

charlie-morrison
charlie-morrison
热度 54.87
最近更新 2026-05-11 17:44:47
分类:开发依赖:代码执行 / 读写文件应用场景:代码审查 / 调试排错 / 自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add vitest-config-validator
Metadata
name
vitest-config-validator
description
Validate vitest.config.ts/js and vitest workspace configurations for syntax, deprecated options, plugin conflicts, and best practices. Use when validating Vitest test runner configs, auditing test setups, or linting vitest.config files.

Vitest Config Validator

Validate vitest.config.ts and vitest.config.js files for syntax errors, deprecated options, plugin conflicts, and best practices. Parses config files as text using regex patterns — no JS execution required.

Commands

# Full validation (all rules)
python3 scripts/vitest_config_validator.py validate vitest.config.ts

# Quick syntax-only check (structure rules only)
python3 scripts/vitest_config_validator.py check vitest.config.ts

# Explain config in human-readable form
python3 scripts/vitest_config_validator.py explain vitest.config.ts

# Suggest improvements
python3 scripts/vitest_config_validator.py suggest vitest.config.ts

# JSON output
python3 scripts/vitest_config_validator.py validate vitest.config.ts --format json

# One-line PASS/WARN/FAIL summary
python3 scripts/vitest_config_validator.py validate vitest.config.ts --format summary

# Strict mode (warnings become errors)
python3 scripts/vitest_config_validator.py validate vitest.config.ts --strict

Rules (22)

# Category Severity Rule
S1 Structure E File not found or unreadable
S2 Structure E Empty config or no defineConfig call
S3 Structure W No default export found
S4 Structure W Both vitest.config and vite.config with test section detected
S5 Structure W Unknown top-level config keys
T1 Test Settings E Invalid test environment (must be jsdom/happy-dom/node/edge-runtime)
T2 Test Settings W Empty include or exclude patterns
T3 Test Settings E Invalid glob pattern in include/exclude
T4 Test Settings I Coverage provider not set (recommend c8/v8/istanbul)
T5 Test Settings W testTimeout set unreasonably high (>60000ms) or low (<100ms)
P1 Performance W singleThread: true used with forks pool (disables parallelism)
P2 Performance W isolate: false without comment (risky for test isolation)
P3 Performance I No pool configuration (defaults may not be optimal)
P4 Performance W globals: true without type declaration reference
C1 Compatibility W Deprecated option used
C2 Compatibility W css.modules without css.include (potential miss)
C3 Compatibility W deps.inline and deps.external conflict
B1 Best Practices I No reporter configured
B2 Best Practices I Missing coverage configuration
B3 Best Practices W setupFiles references potentially non-existent pattern
B4 Best Practices I snapshotFormat not explicitly configured
B5 Best Practices I passWithNoTests not set (CI may fail on empty test suite)

Output Formats

  • text (default): Human-readable with [E]/[W]/[I] severity prefix
  • json: Machine-readable structured output
  • summary: Single-line PASS / WARN / FAIL

Exit Codes

  • 0 — No errors
  • 1 — Errors found (or warnings in --strict mode)
  • 2 — File not found or parse error