← 返回
未分类 中文

Prettierrc Validator

Validate and lint Prettier configuration files (.prettierrc, .prettierrc.json, .prettierrc.yaml, .prettierrc.toml, package.json#prettier) for structure, inva...
校验并检查 Prettier 配置文件(.prettierrc、.prettierrc.json、.prettierrc.yaml、.prettierrc.toml、package.json#prettier)的结构和无效项
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 404
下载
💾 1
安装
1
版本
#latest

概述

Prettier Config Validator

Validate .prettierrc config files for correctness, deprecated options, conflicting overrides, and best practices. Supports JSON, YAML, TOML, and package.json#prettier field. JS configs are detected but not statically validated.

Commands

# Full lint (all rules)
python3 scripts/prettierrc_validator.py lint .prettierrc.json

# Check enum values, ranges, type conflicts only
python3 scripts/prettierrc_validator.py options .prettierrc.json

# Check deprecated/removed options only
python3 scripts/prettierrc_validator.py deprecated .prettierrc.json

# Validate 'overrides' array only
python3 scripts/prettierrc_validator.py overrides .prettierrc.json

# Validate structure/syntax only
python3 scripts/prettierrc_validator.py validate .prettierrc.json

# JSON output (for CI / tooling)
python3 scripts/prettierrc_validator.py lint .prettierrc.json --format json

# Summary line only
python3 scripts/prettierrc_validator.py lint .prettierrc.json --format summary

Supported files

  • .prettierrc (JSON or YAML auto-detected)
  • .prettierrc.json / .prettierrc.json5
  • .prettierrc.yaml / .prettierrc.yml
  • .prettierrc.toml
  • package.json — validates the "prettier" field
  • .prettierrc.js / prettier.config.js — detected but not validated statically

Rules (22)

Structure (5)

  • Invalid JSON / YAML / TOML syntax
  • Unknown top-level options
  • Wrong type for option (boolean, int, string, array expected)
  • Empty config file
  • package.json with missing or invalid prettier field

Options (7)

  • Invalid enum value (quoteProps, trailingComma, arrowParens, proseWrap, htmlWhitespaceSensitivity, endOfLine, embeddedLanguageFormatting)
  • printWidth out of reasonable range (< 20 or > 320)
  • tabWidth invalid (0 or negative, > 16 warning)
  • parser name not a known built-in parser
  • requirePragma + insertPragma both true (conflict)
  • rangeStart > rangeEnd (inverted range)
  • Unknown parser name (plugin-assumed)

Deprecated (2)

  • jsxBracketSameLine → use bracketSameLine (Prettier 2.4+)
  • Removed options (useFlowParser, tabs) with replacement guidance

Overrides (5)

  • Override missing files field
  • files empty array or wrong type
  • Override missing options (no effect)
  • Unknown option inside override
  • Duplicate glob pattern across overrides (precedence bug)

Best Practices (3)

  • Missing endOfLine setting (cross-platform advice)
  • Missing trailingComma (default changed in Prettier v3)
  • printWidth very short (< 40) — may cause awkward line breaks
  • useTabs: true without explicit tabWidth
  • Invalid / empty plugin entries

Output Formats

  • text (default): human-readable with severity icons
  • json: machine-readable list of issues (file, path, rule, severity, message, category)
  • summary: single line of counts

Exit Codes

  • 0: No errors (warnings/info allowed)
  • 1: Errors found
  • 2: Invalid input (file not found, unparseable, unsupported format)

Requirements

  • Python 3.8+
  • Optional: PyYAML (better YAML parsing — falls back to a minimal parser for simple configs)
  • Optional: tomli (only for Python 3.10 and below; Python 3.11+ has tomllib built in)

Examples

Broken config

{ "printWidth": "100", "trailingComma": "some", "jsxBracketSameLine": true }
✗ ERROR   wrong-type          [printWidth] must be an integer
✗ ERROR   invalid-enum-value  [trailingComma] invalid value 'some' (valid: all, es5, none)
⚠ WARNING deprecated-option   [jsxBracketSameLine] use 'bracketSameLine'

Good CI gate

python3 scripts/prettierrc_validator.py lint .prettierrc.json --format summary
# exit 1 on any error — fails the CI step

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 09:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Slack Messaging

charlie-morrison
Slack 消息—通过 CLI 和 API 发送消息、管理频道、上传文件、添加反应并自动化团队通知。
★ 0 📥 546
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 197 📥 68,108
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 683 📥 330,491