Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@ jobs:
- run: npm test
- name: Build (exports map consumers)
run: npm run build
- name: Lint CLI gate (F1 golden, exit 2)
run: |
set +e
npx tsx src/cli.ts lint --dspack fixtures/shadcn.v0_3.dspack.json \
--surface fixtures/golden/violating/F1-dialog-for-delete.dsurface.json \
> /tmp/f1.json 2>/dev/null
code=$?
set -e
test "$code" -eq 2
diff /tmp/f1.json fixtures/golden/violating/F1-dialog-for-delete.expected.json
- name: CLI smoke
run: npm run context -- --dspack fixtures/shadcn.v0_3.dspack.json --intent destructive-action > /dev/null
53 changes: 53 additions & 0 deletions fixtures/golden/clean/delete-account.dsurface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"dspackSurface": "0.1",
"system": "shadcn/ui",
"intent": "destructive-action",
"root": {
"component": "card",
"children": [
{
"component": "alert-dialog",
"children": [
{
"component": "alert-dialog-trigger",
"children": [
{
"component": "button",
"props": {
"variant": "destructive"
},
"text": "Delete account"
}
]
},
{
"component": "alert-dialog-content",
"children": [
{
"component": "alert-dialog-title",
"text": "Delete your account?"
},
{
"component": "alert-dialog-description",
"text": "This will permanently delete your account and all associated data. This action cannot be undone."
},
{
"component": "alert-dialog-footer",
"children": [
{
"component": "alert-dialog-cancel",
"text": "Cancel"
},
{
"component": "alert-dialog-action",
"text": "Delete account"
}
]
}
]
}
]
}
]
}
}
52 changes: 52 additions & 0 deletions fixtures/golden/violating/F1-dialog-for-delete.dsurface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"dspackSurface": "0.1",
"system": "shadcn/ui",
"intent": "destructive-action",
"root": {
"component": "card",
"children": [
{
"component": "dialog",
"children": [
{
"component": "dialog-trigger",
"children": [
{
"component": "button",
"props": {
"variant": "destructive"
},
"text": "Delete account"
}
]
},
{
"component": "dialog-content",
"children": [
{
"component": "dialog-title",
"text": "Delete your account?"
},
{
"component": "dialog-description",
"text": "This will permanently delete your account."
},
{
"component": "dialog-footer",
"children": [
{
"component": "button",
"props": {
"variant": "destructive"
},
"text": "Delete"
}
]
}
]
}
]
}
]
}
}
54 changes: 54 additions & 0 deletions fixtures/golden/violating/F1-dialog-for-delete.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"gates": [
{
"gate": "S1",
"name": "surface-schema",
"status": "PASS"
},
{
"gate": "S2",
"name": "contract-vocabulary",
"status": "PASS"
},
{
"gate": "S3",
"name": "governance",
"status": "FAIL"
}
],
"findings": [
{
"ruleId": "rule.destructive-requires-alertdialog",
"type": "component-choice",
"requirement": "must",
"level": "error",
"message": "Component 'dialog' is forbidden for intent 'destructive-action'.",
"rationale": "Dialog can be dismissed by clicking the overlay or pressing Escape, so a user can bypass a destructive confirmation without making a conscious choice. AlertDialog forces an explicit confirm/cancel decision and is announced with greater urgency by screen readers.",
"location": {
"path": "$.root.children[0]",
"component": "dialog"
},
"exampleIds": [
"ex.delete-account-confirmation"
]
},
{
"ruleId": "rule.destructive-requires-alertdialog",
"type": "component-choice",
"requirement": "must",
"level": "error",
"message": "Required component 'alert-dialog' does not appear in the surface.",
"rationale": "Dialog can be dismissed by clicking the overlay or pressing Escape, so a user can bypass a destructive confirmation without making a conscious choice. AlertDialog forces an explicit confirm/cancel decision and is announced with greater urgency by screen readers.",
"location": {
"path": "$.root",
"component": "surface"
},
"exampleIds": [
"ex.delete-account-confirmation"
]
}
],
"errorCount": 2,
"warnCount": 0,
"pass": false
}
18 changes: 18 additions & 0 deletions fixtures/golden/violating/F2-no-confirmation.dsurface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"dspackSurface": "0.1",
"system": "shadcn/ui",
"intent": "destructive-action",
"root": {
"component": "card",
"children": [
{
"component": "button",
"id": "delete_btn",
"props": {
"variant": "destructive"
},
"text": "Delete account"
}
]
}
}
39 changes: 39 additions & 0 deletions fixtures/golden/violating/F2-no-confirmation.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"gates": [
{
"gate": "S1",
"name": "surface-schema",
"status": "PASS"
},
{
"gate": "S2",
"name": "contract-vocabulary",
"status": "PASS"
},
{
"gate": "S3",
"name": "governance",
"status": "FAIL"
}
],
"findings": [
{
"ruleId": "rule.destructive-requires-alertdialog",
"type": "component-choice",
"requirement": "must",
"level": "error",
"message": "Required component 'alert-dialog' does not appear in the surface.",
"rationale": "Dialog can be dismissed by clicking the overlay or pressing Escape, so a user can bypass a destructive confirmation without making a conscious choice. AlertDialog forces an explicit confirm/cancel decision and is announced with greater urgency by screen readers.",
"location": {
"path": "$.root",
"component": "surface"
},
"exampleIds": [
"ex.delete-account-confirmation"
]
}
],
"errorCount": 1,
"warnCount": 0,
"pass": false
}
49 changes: 49 additions & 0 deletions fixtures/golden/violating/F3-missing-cancel.dsurface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"dspackSurface": "0.1",
"system": "shadcn/ui",
"intent": "destructive-action",
"root": {
"component": "card",
"children": [
{
"component": "alert-dialog",
"children": [
{
"component": "alert-dialog-trigger",
"children": [
{
"component": "button",
"props": {
"variant": "destructive"
},
"text": "Delete account"
}
]
},
{
"component": "alert-dialog-content",
"children": [
{
"component": "alert-dialog-title",
"text": "Delete your account?"
},
{
"component": "alert-dialog-description",
"text": "This cannot be undone."
},
{
"component": "alert-dialog-footer",
"children": [
{
"component": "alert-dialog-action",
"text": "Delete account"
}
]
}
]
}
]
}
]
}
}
39 changes: 39 additions & 0 deletions fixtures/golden/violating/F3-missing-cancel.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"gates": [
{
"gate": "S1",
"name": "surface-schema",
"status": "PASS"
},
{
"gate": "S2",
"name": "contract-vocabulary",
"status": "PASS"
},
{
"gate": "S3",
"name": "governance",
"status": "FAIL"
}
],
"findings": [
{
"ruleId": "rule.alertdialog-requires-cancel",
"type": "required-composition",
"requirement": "must",
"level": "error",
"message": "Required sub-component 'alert-dialog-cancel' (min 1) not found among descendants (found 0).",
"rationale": "A confirmation without an explicit cancel action and a title naming the consequence funnels the user toward the destructive action; the title is also required for aria-labelledby.",
"location": {
"path": "$.root.children[0]",
"component": "alert-dialog"
},
"exampleIds": [
"ex.delete-account-confirmation"
]
}
],
"errorCount": 1,
"warnCount": 0,
"pass": false
}
49 changes: 49 additions & 0 deletions fixtures/golden/violating/F4-missing-title.dsurface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"dspackSurface": "0.1",
"system": "shadcn/ui",
"intent": "destructive-action",
"root": {
"component": "card",
"children": [
{
"component": "alert-dialog",
"children": [
{
"component": "alert-dialog-trigger",
"children": [
{
"component": "button",
"props": {
"variant": "destructive"
},
"text": "Delete account"
}
]
},
{
"component": "alert-dialog-content",
"children": [
{
"component": "alert-dialog-description",
"text": "This cannot be undone."
},
{
"component": "alert-dialog-footer",
"children": [
{
"component": "alert-dialog-cancel",
"text": "Cancel"
},
{
"component": "alert-dialog-action",
"text": "Delete account"
}
]
}
]
}
]
}
]
}
}
Loading
Loading