@windyroad/style-guide 0.3.1-preview.300 → 0.4.0-preview.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,6 +45,18 @@ case "$FILE_PATH" in
|
|
|
45
45
|
;;
|
|
46
46
|
esac
|
|
47
47
|
|
|
48
|
+
# Governance-managed surface exemptions — ADR-060 § Phase 2 amendment
|
|
49
|
+
# 2026-05-12 lines 481-496 (P170 Phase 2 Slice 2.5). Mirrors the
|
|
50
|
+
# docs/problems / docs/jtbd peer-plugin policy exemptions in
|
|
51
|
+
# architect-enforce-edit.sh + jtbd-enforce-edit.sh. Short-circuits before
|
|
52
|
+
# the *.html extension check below would otherwise fire on story-map HTML.
|
|
53
|
+
case "$FILE_PATH" in
|
|
54
|
+
*/docs/story-maps/*|docs/story-maps/*)
|
|
55
|
+
exit 0 ;;
|
|
56
|
+
*/docs/stories/*|docs/stories/*)
|
|
57
|
+
exit 0 ;;
|
|
58
|
+
esac
|
|
59
|
+
|
|
48
60
|
# Gate all UI source files (CSS and component files)
|
|
49
61
|
case "$FILE_PATH" in
|
|
50
62
|
*.css|*.html|*.jsx|*.tsx|*.vue|*.svelte|*.ejs|*.hbs) ;;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bats
|
|
2
|
+
|
|
3
|
+
# Tests for style-guide-enforce-edit.sh — verifies the path-based exemption
|
|
4
|
+
# for governance-managed surfaces (docs/story-maps/, docs/stories/) per
|
|
5
|
+
# ADR-060 § Phase 2 amendment 2026-05-12 lines 481-496 (P170 Phase 2 Slice 2.5).
|
|
6
|
+
#
|
|
7
|
+
# The style-guide hook is opt-in (gates only *.css|*.html|*.jsx|*.tsx|*.vue|
|
|
8
|
+
# *.svelte|*.ejs|*.hbs). Story-map HTML files would otherwise be blocked at
|
|
9
|
+
# `*.html` matching when docs/STYLE-GUIDE.md is absent OR review-gate is open.
|
|
10
|
+
# The exemption short-circuits before the extension check.
|
|
11
|
+
|
|
12
|
+
setup() {
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
|
|
14
|
+
HOOK="$SCRIPT_DIR/style-guide-enforce-edit.sh"
|
|
15
|
+
ORIG_DIR="$PWD"
|
|
16
|
+
TEST_DIR=$(mktemp -d)
|
|
17
|
+
cd "$TEST_DIR"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
teardown() {
|
|
21
|
+
cd "$ORIG_DIR"
|
|
22
|
+
rm -rf "$TEST_DIR"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
run_hook_with_file() {
|
|
26
|
+
local file_path="$1"
|
|
27
|
+
local json="{\"tool_input\":{\"file_path\":\"${file_path}\"},\"session_id\":\"test-session-$$\"}"
|
|
28
|
+
echo "$json" | bash "$HOOK"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
assert_path_allowed() {
|
|
32
|
+
local file_path="$1"
|
|
33
|
+
run run_hook_with_file "$file_path"
|
|
34
|
+
[ "$status" -eq 0 ]
|
|
35
|
+
[[ "$output" != *"BLOCKED"* ]]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
assert_path_blocked() {
|
|
39
|
+
local file_path="$1"
|
|
40
|
+
run run_hook_with_file "$file_path"
|
|
41
|
+
[ "$status" -eq 0 ]
|
|
42
|
+
[[ "$output" == *"BLOCKED"* ]]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# --- Story maps + stories exemptions (P170 Phase 2 Slice 2.5 / ADR-060) ---
|
|
46
|
+
|
|
47
|
+
@test "style-guide: exempts docs/story-maps/ HTML in per-state subdir" {
|
|
48
|
+
assert_path_allowed "$PWD/docs/story-maps/draft/STORY-MAP-001-foo.html"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@test "style-guide: exempts docs/story-maps/ HTML in completed subdir" {
|
|
52
|
+
assert_path_allowed "$PWD/docs/story-maps/completed/STORY-MAP-002-bar.html"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@test "style-guide: exempts docs/stories/ files even though .md isn't normally gated" {
|
|
56
|
+
# Markdown isn't in the opt-in extension list anyway, so this passes by
|
|
57
|
+
# virtue of the extension filter — but the explicit exemption documents
|
|
58
|
+
# intent and survives a hypothetical future scope-widening.
|
|
59
|
+
assert_path_allowed "$PWD/docs/stories/draft/STORY-001-foo.md"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# --- Regression: non-exempt UI files still gate ---
|
|
63
|
+
|
|
64
|
+
@test "style-guide: still blocks an unrelated .html file when no policy exists" {
|
|
65
|
+
# No docs/STYLE-GUIDE.md created — hook should still block this HTML.
|
|
66
|
+
assert_path_blocked "$PWD/public/index.html"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@test "style-guide: still blocks a .tsx component file when no policy exists" {
|
|
70
|
+
assert_path_blocked "$PWD/src/Component.tsx"
|
|
71
|
+
}
|