@design-parity/checks

中文文档
1.18.0发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 4182

Deterministic a11y + i18n spec checks over a DesignReference / CandidateRender pair. No model at run time — only committed rules and thresholds.

原始使用文档
文档目录5 节
  1. Checks
  2. Configuration
  3. Validate CLI
  4. Finding kinds
  5. Develop

@design-parity/checks

Deterministic accessibility + internationalization spec checks over a (DesignReference, CandidateRender) pair. These are the high-value, spec-backed findings the verdict leads with (see docs/PRINCIPLES.md Principle 2): the objective details developers routinely miss and design tools don't enforce.

Every check is a pure function that reads committed thresholds and the captured semantics — no network call and no model at run time (Principle 1). The same PR always scores the same.

Checks

FunctionKindWhat it asserts
checkContrastcontrastWCAG 1.4.3/1.4.6 text contrast per theme; fails AA → error, meets AA but not AAA → info.
checkTouchTargetsa11yInteractive targets ≥ 48dp (Material 3); below the WCAG 2.5.8 floor of 24dp → error.
checkSemanticsa11yInteractive/image nodes expose an accessible label / content description.
checkTextExpansioni18nPseudolocale text growth vs available width → truncation risk (warn).
checkLocaleFormattingi18nHardcoded locale-specific currency/date/number literals in labels.
checkRtlMirroringi18nDirectional icons that must mirror under RTL; right-to-left text.
checkHardcodedStringsi18nUn-keyed user-facing literals (opt-in — a render can't prove a string came from a resource).

runChecks(reference, candidate, config?) runs the whole suite and returns findings a11y first, then i18n, severity-ordered within each group. runA11yChecks / runI18nChecks run one group.

A contrast failure stays an error unless the reference semantic tree contains the same foreground/background pair failing the same threshold. That exact design-led match is reported as a warning with sharedWithReference: true: the accessibility debt remains visible, while parity does not ask code to diverge from its source. An absent or unassessable reference never suppresses a candidate failure.

Configuration

All policy is committed and overridable via ChecksConfig (contrast level, touch-target minimum, glyph-advance estimate, themes, hardcoded-string opt-in). Defaults live in src/thresholds.ts and encode WCAG 2.2

  • Material 3 + standard pseudolocale guidance.

A repo commits these knobs to design-parity.checks.json — the file @design-parity/baseline writes during bootstrap. It is read deterministically at run time so its tuned thresholds actually reach the engine (Principle 1):

  • loadChecksConfig(path) — read, parse, and schema-validate a config file; throws a readable error if it is missing, not JSON, or schema-invalid.
  • loadChecksConfigOrDefault(path) — same, but a missing file resolves to the committed defaults, so a repo in steady state with no setup still works. A present-but-invalid file still throws.
  • validateChecksConfig(value) — validate an already-parsed object against the draft-07 schema.

The config shape mirrors ChecksConfig exactly, so bootstrap output validates and loads without translation. See examples/design-parity.checks.json.

Validate CLI

design-parity-validate-checks [path ...] validates one or more config files against the schema and exits non-zero on the first invalid one, so it can gate CI. Defaults to design-parity.checks.json in the cwd.

node packages/checks/dist/cli/validate-checks.js design-parity.checks.json

Finding kinds

This package introduced the dedicated a11y and i18n FindingKinds in @design-parity/core so the verdict can cleanly lead with them. contrast keeps its own kind (it carries a numeric ratio and is the headline a11y finding). Focus order and state-announcement gaps are not asserted yet: SemanticNode does not model them, so adding those checks is a contract change in core — tracked rather than faked.

Develop

npm run build --workspace @design-parity/checks
npm test

版本与发布记录

@design-parity/checks 共发布 102 个版本,首次发布于 2026/06/14;过去 12 个月发布了 102 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.18.0latest2026/11/074 天前
1.17.02026/10/2617 天前
1.16.12026/10/1824 天前
1.16.02026/10/1726 天前
1.15.02026/10/1528 天前
1.14.12026/10/1230 天前

关于 @design-parity/checks 的常见问题

@design-parity/checks 是什么?

Deterministic a11y + i18n spec checks over a DesignReference / CandidateRender pair. No model at run time — only committed rules and thresholds.

如何安装 @design-parity/checks?

在项目目录运行 npm install @design-parity/checks,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 design-parity-validate-checks,可以用 npx design-parity-validate-checks 直接运行。

@design-parity/checks 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@design-parity/checks 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@design-parity/checks 可以商用吗?

@design-parity/checks 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@design-parity/checks 的下载量有多少?

根据 npm 官方下载统计,@design-parity/checks 在 2026/10/12 – 2026/11/10 这 30 天内被下载 4,182 次,日均约 139 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@design-parity/checks 还在维护吗?

最新版本 1.18.0 发布于 2026/11/07(4 天前);至今共发布 102 个版本,其中过去 12 个月发布了 102 个;首次发布于 2026/06/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。