The page held six teaching sections and a 142-line `styles:` block, at 471 effective lines against a limit of 250. It is now 36 lines of composition. Angular scopes a component's CSS to markup that component rendered, so the split had to move each rule to its owner. `concept-card` owns the card vocabulary and renders it. `.app-code`, `.app-lead`, `.app-cols` and `.app-note` become globals, because their targets are projected or arrive through `[innerHTML]`. That constraint exposed a live bug. The syntax-highlighting rules compiled to `pre[_ngcontent-%COMP%] .k[_ngcontent-%COMP%]`, but `highlight-ts` injects the `.k`/`.s`/`.c` spans through `[innerHTML]`, so they carry no scope attribute and the rule never matched. Keywords, strings and comments have always rendered in the plain foreground colour. The rules are global now, on five new `--app-code-*` tokens. Widen the colour guard while here: it scanned only `*.component.ts`, so every `*.page.ts`, `*.section.ts` and `*.step.ts` was invisible to it. That is how this page collected 21 hardcoded colours. One other file needed a fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
38 lines
1.9 KiB
Bash
Executable File
38 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# WP-02 token guard: fail if any *.ts file hardcodes a colour (hex/rgb/hsl) instead of
|
|
# a --rhc-*/--app-* design token. Specs and stories are exempt — they legitimately show
|
|
# colour swatches. Palette values live ONLY in the styles.scss token bridge (the one
|
|
# exempt file — it IS the bridge). Widened from *.component.ts to *.ts in RD-24: a
|
|
# *.page.ts, *.section.ts or *.step.ts hardcoding a colour was invisible before that.
|
|
#
|
|
# px/rem are deliberately NOT grepped: too many false positives (font sizes,
|
|
# transforms, media queries). Raw border widths are fixed by hand and mapped to
|
|
# --rhc-border-width-*; see docs/backlog/WP-02-check-tokens.md.
|
|
#
|
|
# Escape hatch: put a `token-ok` marker + reason on a line to suppress a justified
|
|
# false positive (a colour word inside a comment or a data-URI). Keep the bar high.
|
|
set -uo pipefail
|
|
|
|
hits=$(grep -rnE '#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(' apps libs --include='*.ts' \
|
|
| grep -vE '\.(spec|stories)\.ts:' | grep -v 'token-ok' || true)
|
|
if [ -n "$hits" ]; then
|
|
echo "$hits"
|
|
echo 'FAIL: hardcoded colours in components (use --rhc-*/--app-* tokens, or add a `token-ok` marker + reason)'
|
|
exit 1
|
|
fi
|
|
echo 'OK: no hardcoded colours in components'
|
|
|
|
# ADR-C-008 guard: every `// CIBG-GAP EXTENSION:` marker (ADR-0003 §Consequences)
|
|
# must have a row in the register, so the table cannot drift from the code
|
|
# again without CI catching it.
|
|
gap_register='libs/shared/docs/cibg-gaps.mdx'
|
|
markers=$(grep -rl 'CIBG-GAP EXTENSION' apps libs --include='*.component.ts' | xargs -n1 dirname | xargs -n1 basename | sort -u)
|
|
rows=$(grep -oP '^\| `\K[^`]+' "$gap_register" | sort -u)
|
|
missing=$(comm -23 <(echo "$markers") <(echo "$rows"))
|
|
if [ -n "$missing" ]; then
|
|
echo "$missing"
|
|
echo "FAIL: CIBG-GAP EXTENSION marker(s) with no row in $gap_register"
|
|
exit 1
|
|
fi
|
|
echo 'OK: every CIBG-GAP EXTENSION marker has a cibg-gaps.mdx row'
|