| 26 |
26 |
|
|
| 27 |
27 |
|
# 1. no-raw-hex
|
| 28 |
28 |
|
# No raw hex literals in JS or source HTML. HTML entities (&#NNNN;) and the
|
| 29 |
|
- |
# themes.js theme engine are exempt — themes.js is the only place that
|
|
29 |
+ |
# themes.js theme engine are exempt. themes.js is the only place that
|
| 30 |
30 |
|
# builds CSS values via string concatenation, by charter.
|
| 31 |
31 |
|
hits=$(grep -rnE '#[0-9a-fA-F]{3,8}\b' "$SRC_JS" "$SRC_HTML" 2>/dev/null \
|
| 32 |
32 |
|
| grep -vE '&#[0-9]+;' \
|
| 33 |
33 |
|
| grep -v 'js/themes.js' \
|
| 34 |
34 |
|
| grep -v 'js/tests/' \
|
| 35 |
35 |
|
|| true)
|
| 36 |
|
- |
report "no-raw-hex" "Raw hex literal in JS/HTML — use a CSS class or themed token." "$hits"
|
|
36 |
+ |
report "no-raw-hex" "Raw hex literal in JS/HTML. Use a CSS class or themed token." "$hits"
|
| 37 |
37 |
|
|
| 38 |
38 |
|
# 2. no-csstext
|
| 39 |
|
- |
# style.cssText injection is forbidden — it usually means color/border/font
|
|
39 |
+ |
# style.cssText injection is forbidden. It usually means color/border/font
|
| 40 |
40 |
|
# values are being set from JS and the result is unthemeable.
|
| 41 |
41 |
|
hits=$(grep -rn 'cssText' "$SRC_JS" 2>/dev/null | grep -v 'js/tests/' || true)
|
| 42 |
|
- |
report "no-csstext" "style.cssText injection — move styles into a CSS class." "$hits"
|
|
42 |
+ |
report "no-csstext" "style.cssText injection. Move styles into a CSS class." "$hits"
|
| 43 |
43 |
|
|
| 44 |
44 |
|
# 3. no-var-fallback-hex
|
| 45 |
45 |
|
# No var(--token, #fallback). Fallback hex bypasses the theme contract.
|
| 46 |
46 |
|
hits=$(grep -rnE 'var\(--[a-z-]+,\s*#' "$FRONTEND" \
|
| 47 |
47 |
|
--include='*.js' --include='*.html' --include='styles.css' 2>/dev/null || true)
|
| 48 |
|
- |
report "no-var-fallback-hex" "var(--token, #fallback) — drop the fallback; it bypasses themes." "$hits"
|
|
48 |
+ |
report "no-var-fallback-hex" "var(--token, #fallback): drop the fallback; it bypasses themes." "$hits"
|
| 49 |
49 |
|
|
| 50 |
50 |
|
# 4. no-styled-attrs
|
| 51 |
51 |
|
# No inline style="..." that touches color / background / border / shadow /
|
| 53 |
53 |
|
# tolerated; the goal is zero on the color and typography axes.
|
| 54 |
54 |
|
hits=$(grep -rnE 'style="[^"]*(color|background|border|shadow|font-size|font-family|padding)' \
|
| 55 |
55 |
|
"$SRC_JS" "$SRC_HTML" 2>/dev/null || true)
|
| 56 |
|
- |
report "no-styled-attrs" "Inline style= with color/background/border/shadow/font/padding — use a class." "$hits"
|
|
56 |
+ |
report "no-styled-attrs" "Inline style= with color/background/border/shadow/font/padding. Use a class." "$hits"
|
| 57 |
57 |
|
|
| 58 |
58 |
|
# 5. no-style-color-from-js
|
| 59 |
59 |
|
# No .style.<color-axis-property> assignments. Dynamic positioning
|
| 61 |
61 |
|
# color, background, border, font, padding values must come from CSS.
|
| 62 |
62 |
|
hits=$(grep -rnE '\.style\.(color|background|backgroundColor|borderColor|font|fontFamily|fontSize|paddingTop|paddingBottom|paddingLeft|paddingRight|margin|marginTop|marginBottom|marginLeft|marginRight|gap|opacity)\b' \
|
| 63 |
63 |
|
"$SRC_JS" 2>/dev/null | grep -v 'js/tests/' || true)
|
| 64 |
|
- |
report "no-style-color-from-js" "JS-set color/background/border/font/margin/padding/gap/opacity — use a class." "$hits"
|
|
64 |
+ |
report "no-style-color-from-js" "JS-set color/background/border/font/margin/padding/gap/opacity. Use a class." "$hits"
|
| 65 |
65 |
|
|
| 66 |
66 |
|
# 6. no-native-dialogs
|
| 67 |
|
- |
# window.confirm / window.prompt / window.alert are banned — they're
|
|
67 |
+ |
# window.confirm / window.prompt / window.alert are banned. They're
|
| 68 |
68 |
|
# unstyled on every platform and disabled in iOS WKWebView. Use the
|
| 69 |
69 |
|
# BB.ui.show{Confirm,Prompt}Dialog / BB.ui.showToast helpers instead.
|
| 70 |
70 |
|
hits=$(grep -rnE '\b(window\.)?(confirm|prompt|alert)\s*\(' "$SRC_JS" 2>/dev/null \
|
| 71 |
71 |
|
| grep -vE 'showConfirmDialog|showPromptDialog|confirmAction|confirmDelete|confirmBtn|\.confirm-message|/\*|\*\s|// ' \
|
| 72 |
72 |
|
| grep -v 'js/tests/' || true)
|
| 73 |
|
- |
report "no-native-dialogs" "window.confirm/prompt/alert are banned — use BB.ui.show{Confirm,Prompt}Dialog or showToast." "$hits"
|
|
73 |
+ |
report "no-native-dialogs" "window.confirm/prompt/alert are banned. Use BB.ui.show{Confirm,Prompt}Dialog or showToast." "$hits"
|
| 74 |
74 |
|
|
| 75 |
75 |
|
# 7. theme-token-coverage
|
| 76 |
76 |
|
# Every :root token must self-declare its nature on its declaration line:
|