三层验证工具:语义分级器 · JSON 输入 · 快照模板。证明"加了规则后有效"。
粘贴一段错误文案或描述,系统自动提取关键字段并匹配模式。
提取结果
{
"component_type": "Alert",
"visual": {
"color": "yellow",
"background": "solid",
"icon": "warning"
},
"copy": {
"title": "Too Many Requests",
"description": "请求过于频繁,请稍后再试",
"tone": "urgent"
},
"interaction": {
"dismissible": true,
"actions": ["wait", "upgrade"]
},
"context": "system_error"
}
粘贴组件语义快照 JSON,系统自动匹配已知模式。
{
"component_type": "Alert",
"visual": { "color": "yellow", "background": "solid", "icon": "warning" },
"copy": { "title": "Too Many Requests", "description": "请求过于频繁,请稍后再试", "tone": "urgent" },
"interaction": { "dismissible": true, "actions": ["wait", "upgrade"] },
"context": "system_error"
}
匹配到模式:ERR-001
错误状态后果差异未分级
查看详情 →编译管线 v1 · 实现层的越界能被拦住吗?
契约声明
# ERR-001 v1.1.0
error_severity:
retryable:
description: "请求频率已达上限"
visual_mapping:
color_token: "status.warning"
motion_token: "none"
icon_token: "clock"
user_action:
- label: "等待倒计时"
action: "wait_countdown"
- label: "升级套餐"
action: "upgrade"
immutable_boundaries:
- boundary_type: "safety"
rule: "禁止所有错误状态共用同一种红色视觉表达"
violation_action: "block"
违规代码(JSX)
<Alert color="#cf1322" ← 硬编码致命红 severity="error" ← 语义级别:error icon="warning" > 请求过于频繁,请稍后再试 </Alert>
ESLint 自定义规则执行结果
组件 color 与契约声明语义级别不一致
JSX 中语义属性硬编码、未引用字典绑定
action.destructive 绑定缺二次确认交互
引用 deprecated 字典条目
修正后的合规代码
<Alert color_token="status.warning" severity="retryable" icon="clock" > 请求频率已达上限 <Action icon="timer">42分钟后重试</Action> <Action icon="upgrade">升级 Plus</Action> </Alert>
CI 规则定义(编译管线 v1 产出)
# .eslintrc.js — 语义绑定校验规则
module.exports = {
plugins: ['semantic-pipeline'],
rules: {
'semantic-pipeline/severity-color-match': 'error',
'semantic-pipeline/overlay-reference-only': 'error',
'semantic-pipeline/no-missing-destructive-confirm': 'error',
'semantic-pipeline/deprecated-reference': 'warn'
}
};
# Stylelint 规则(配套)
rules:
error-severity-color:
selector: "[data-severity]"
mapping:
retryable: { color: "#f5a623", bg: "rgba(245,158,11,0.15)" }
forbidden: { color: "#cf1322" }
message: "retryable 不得使用红色"
overlay-reference-only:
selector: "[data-semantic]"
forbidden: { attr: "color", hardcoded: true }
required: { attr: "color_token" }
message: "语义属性必须引用字典绑定"
验证口径
契约层合法 ≠ 代码层守法。前端 JSX 硬编码红色、组件 color 与契约语义级别不一致,机器能否在提交时拦住?
✗ 2 个 error 未通过,阻断合入。修正后重新提交。