chore(web): library-admin inline script moves to admin.ts; rendering guardrail
The library admin page carried an inline <script> block of global functions (toggleLibraryPanel, openEditModal, openDeleteModal, openFolderBrowser plus the delete-modal close listener). They move into the admin Alpine component as typed methods; the page body gains x-data="admin" and the call sites switch onclick= -> @click. Behavior unchanged. Guardrail: make lint-rendering (wired into make test) fails when a web/src file builds more HTML template literals than its recorded baseline (web/src/rendering-allowlist.txt, seeded at 18 sites across 9 files post-twin-deletion) or when a .templ file gains an inline script block. theme_flash_guard.templ is the only sanctioned inline script; web/src/reader is a sanctioned island. theme.ts: Array.from(classList) — DOMTokenList spread needs lib.dom.iterable, which the tsconfig does not include.
This commit is contained in:
1 parent
f1844591b4
commit
506a04b55d
6 files changed
+164
-94
No files matched your search
@@ -47,9 +47,34 @@ help:
|
||||
@echo " ./release v0.3.0 - Tag, push, and release (notes auto-generated from commits)"
|
||||
|
||||
# Run unit tests locally (fast, no containers)
|
||||
test:
|
||||
test: lint-rendering
|
||||
go test ./internal/... -v -short
|
||||
|
||||
# Rendering-ownership guard (AGENTS.md → Rendering ownership): templ renders
|
||||
# UI markup, JS orchestrates. Fails when a web/src file builds more HTML
|
||||
# template literals than its recorded baseline (web/src/rendering-allowlist.txt),
|
||||
# or when a .templ file gains an inline <script> block (theme_flash_guard.templ
|
||||
# is the only sanctioned one). Shrink baselines as fragments move to templ
|
||||
# partials; grow one only with a written reason.
|
||||
lint-rendering:
|
||||
@violations=""; \
|
||||
for f in $$(grep -rlE 'innerHTML[[:space:]]*=[[:space:]]*\`' web/src --include='*.ts' | grep -v 'web/src/reader/'); do \
|
||||
count=$$(grep -cE 'innerHTML[[:space:]]*=[[:space:]]*\`' $$f); \
|
||||
allowed=$$(grep -F "$$f:" web/src/rendering-allowlist.txt | cut -d: -f2); \
|
||||
allowed=$${allowed:-0}; \
|
||||
if [ $$count -gt $$allowed ]; then \
|
||||
violations="$$violations $$f ($$count > $$allowed)"; \
|
||||
fi; \
|
||||
done; \
|
||||
for f in $$(grep -rln '<script>' templates --include='*.templ'); do \
|
||||
case $$f in *theme_flash_guard*) continue;; esac; \
|
||||
violations="$$violations $$f (inline script)"; \
|
||||
done; \
|
||||
if [ -n "$$violations" ]; then \
|
||||
echo "rendering-ownership violations:$$violations"; exit 1; \
|
||||
fi; \
|
||||
echo "rendering ownership OK"
|
||||
|
||||
# Run integration tests in containers (matches production environment)
|
||||
test-integration:
|
||||
@echo "Building test containers..."
|
||||
|
||||
Reference in new issue
Block a user