当前位置: 首页 > Skill >

Tailwind Config Validator

Tailwind Config Validator

Tailwind Config Validator

Validate JSON-exported Tailwind CSS configuration files for structural issues, content path problems, theme misconfiguration, and best practices. Use when au...

1.0.1 2026.11.16 405
获取Skill文件查看使用说明
作 者:陈辰 许可证: 更新时间:2026.11.16
本文目录展开

Tailwind Config Validator

Validate Tailwind CSS configuration files exported as JSON for structural correctness, content path issues, theme misconfiguration, dark mode problems, plugin hygiene, and best practices. Pure Python 3 stdlib — no external dependencies.

Note: Tailwind configs are JS/TS, not directly parseable. This validator works with JSON-exported configs. Export via:

node -e "console.log(JSON.stringify(require('./tailwind.config.js')))" > config.json
python3 scripts/tailwind_config_validator.py validate config.json

Commands

validate — Full validation with all rules

python3 scripts/tailwind_config_validator.py validate config.json
python3 scripts/tailwind_config_validator.py validate config.json --strict
python3 scripts/tailwind_config_validator.py validate config.json --format json

lint — Run all rules (alias for validate)

python3 scripts/tailwind_config_validator.py lint config.json
python3 scripts/tailwind_config_validator.py lint config.json --format summary
python3 scripts/tailwind_config_validator.py lint config.json --strict --format json

content — Check content configuration

python3 scripts/tailwind_config_validator.py content config.json
python3 scripts/tailwind_config_validator.py content config.json --format json
python3 scripts/tailwind_config_validator.py content config.json --format summary

theme — Check theme configuration

python3 scripts/tailwind_config_validator.py theme config.json
python3 scripts/tailwind_config_validator.py theme config.json --format json
python3 scripts/tailwind_config_validator.py theme config.json --format summary

Flags

Flag Description
--strict Treat warnings as errors — exit code 1 (CI-friendly)
--format text Human-readable output (default)
--format json Machine-readable JSON
--format summary Compact summary with counts

Validation Rules (26)

Structure (5)

Rule Severity Description
S1 error File not found or unreadable
S2 error Empty config file
S3 error Invalid JSON syntax
S4 warning/info Unknown top-level keys (valid: content, theme, plugins, presets, darkMode, prefix, important, separator, corePlugins, safelist, blocklist, future, experimental)
S5 info JS/TS config detected (hint to export as JSON)

Content (5)

Rule Severity Description
C1 error Missing content paths (required for tree-shaking)
C2 warning Empty content array
C3 warning Content paths include node_modules (performance)
C4 warning Content glob too broad (e.g. **/* without extension filter)
C5 info Suspicious content pattern (bare *.css or similar)

Theme (5)

Rule Severity Description
T1 warning Overriding entire theme key without extend (replaces defaults)
T2 info Empty theme.extend object
T3 warning Invalid color values (not strings)
T4 info Referencing default theme without callback (theme() needed)
T5 warning Custom screen breakpoints not in ascending order

Dark Mode (2)

Rule Severity Description
D1 error Invalid darkMode value
D2 info darkMode "class" deprecated in v3.4+ (use "selector")

Plugins (3)

Rule Severity Description
P1 info Empty plugins array
P2 error Plugins not an array
P3 info Deprecated official plugins (built-in in v4)

Best Practices (6)

Rule Severity Description
B1 error No content paths defined (tree-shaking broken)
B2 warning Using important: true globally (anti-pattern)
B3 warning Prefix with special characters
B4 warning corePlugins disabled entirely
B5 warning Large safelist (>50 patterns, bloats CSS)
B6 warning Missing theme.extend (all customizations override defaults)

Exit Codes

Code Meaning
0 No errors (warnings allowed unless --strict)
1 Errors found (or warnings in --strict mode)
2 File not found / parse error

CI Integration

# GitHub Actions example
- name: Validate Tailwind config
  run: |
    node -e "console.log(JSON.stringify(require('./tailwind.config.js')))" > /tmp/tw-config.json
    python3 scripts/tailwind_config_validator.py validate /tmp/tw-config.json --strict --format json

Example Output

tailwind.config validate — config.json
=======================================
[ERROR  ] C1: Missing 'content' paths — required for tree-shaking
         Without content paths, Tailwind cannot purge unused CSS. Add content: ['./src/**/*.{html,js,ts,jsx,tsx}'].
[WARNING] T1: theme.colors overrides all default colors — use theme.extend.colors instead
         Placing keys directly under 'theme' replaces the entire default set. Move to 'theme.extend' to merge with defaults.
[WARNING] B2: important: true applies !important to all utilities (anti-pattern)
         Prefer important: '#app' to scope specificity to a root selector instead of global !important.
[INFO   ] P3: Plugin '@tailwindcss/forms' is built-in since Tailwind v4
         In Tailwind v4, @tailwindcss/forms functionality is included by default. Remove the plugin if upgrading.
[INFO   ] D2: darkMode 'class' is deprecated since v3.4 — use 'selector' instead
         The 'class' strategy still works but 'selector' is the recommended replacement.

Result: INVALID
Summary: 1 error(s), 2 warning(s), 2 info

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
Skill 文件
  • SKILL.md
    • Tailwind Config Validator
    • Commands
      • validate — Full validation with all rules
      • lint — Run all rules (alias for validate)
      • content — Check content configuration
      • theme — Check theme configuration
    • Flags
    • Validation Rules (26)
      • Structure (5)
      • Content (5)
      • Theme (5)
      • Dark Mode (2)
      • Plugins (3)
      • Best Practices (6)
    • Exit Codes
    • CI Integration
    • Example Output
  • 项目或源文件

相关 Skill

更多
NextJS Frontend Development + Integration NextJS Frontend Development + Integration Generate production-ready Next.js projects with TypeScript, Tailwind CSS, shadcn/ui, and API integration. Use when the user asks to build, create, develop, or scaffold a Next.js application, web app, full-stack project, or frontend with backend integration. Prioritizes modern stack (Next.js 14+, TypeScript, shadcn/ui, axios, react-query) and best practices. Also triggers on requests to add features, integrate APIs, or extend existing Next.js projects.
ia-tailwind-css ia-tailwind-css Tailwind CSS v4 模式:CSS 优先配置、工具类、组件变体、v3 迁移。使用场景:在使用 Tailwind 进行样式化、配置 @theme token 等时
skill-creator-enhanced skill-creator-enhanced Enhanced skill creator with templates, validation, publishing workflow, and quality gates. Guides through skill creation process with best practices, common patterns, and ClawHub integration.
Tailwind Design System Tailwind Design System 使用 CVA 构建可扩展、可主题化的 Tailwind CSS 组件库,支持变体、复合组件、设计令牌、暗黑模式及响应式网格。
Tailwind CSS Tailwind CSS 编写具有正确响应式设计、暗色模式和配置的 Tailwind 工具类