basalt-ui 1.1.0 → 1.2.0

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.
Files changed (191) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +37 -0
  3. package/README.md +47 -5
  4. package/agent/rules/basalt-app.md +126 -0
  5. package/agent/rules/basalt-content.md +3 -1
  6. package/agent/skills/basalt-app/SKILL.md +32 -10
  7. package/configs/check.yml +3 -1
  8. package/configs/oxlint.json +1 -1
  9. package/dist/agent/part-list.d.ts.map +1 -1
  10. package/dist/agent/part-list.js +17 -7
  11. package/dist/agent/stick-to-bottom.js +2 -2
  12. package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
  13. package/dist/agent-chat/thread-detail-panel.js +37 -33
  14. package/dist/agent-chat/thread-message.d.ts.map +1 -1
  15. package/dist/agent-chat/thread-message.js +8 -5
  16. package/dist/agent-chat/thread-outcome-card.js +3 -3
  17. package/dist/agent-chat/thread-workspace.js +1 -1
  18. package/dist/charts/primitives/ChartLegend.js +2 -0
  19. package/dist/charts/primitives/ChartTooltip.js +2 -1
  20. package/dist/cli/index.d.ts +21 -1
  21. package/dist/cli/index.d.ts.map +1 -1
  22. package/dist/cli/index.js +50 -12
  23. package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
  24. package/dist/connectivity/connectivity-indicator.js +3 -3
  25. package/dist/content/article-card.module.css +7 -5
  26. package/dist/content/article-layout.module.css +16 -12
  27. package/dist/content/callout.module.css +4 -4
  28. package/dist/content/code-block.module.css +8 -7
  29. package/dist/content/guide.module.css +3 -3
  30. package/dist/content/mermaid.module.css +2 -2
  31. package/dist/content/prose.module.css +59 -29
  32. package/dist/content/reading-progress.module.css +2 -0
  33. package/dist/content/toc.module.css +6 -3
  34. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  35. package/dist/dashboard/delta-badge.js +10 -2
  36. package/dist/dashboard/empty-state.d.ts.map +1 -1
  37. package/dist/dashboard/empty-state.js +3 -16
  38. package/dist/dashboard/settings-section.js +2 -2
  39. package/dist/dashboard/settings-section.module.css +2 -2
  40. package/dist/dashboard/stat-card.js +2 -1
  41. package/dist/data/virtual-list.d.ts.map +1 -1
  42. package/dist/data/virtual-list.js +12 -2
  43. package/dist/forms/FormErrorSummary.js +2 -2
  44. package/dist/guard/index.d.ts +20 -4
  45. package/dist/guard/index.d.ts.map +1 -1
  46. package/dist/guard/index.js +250 -37
  47. package/dist/guard/types.d.ts +24 -3
  48. package/dist/guard/types.d.ts.map +1 -1
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/provider/index.d.ts +30 -1
  52. package/dist/provider/index.d.ts.map +1 -1
  53. package/dist/provider/index.js +32 -7
  54. package/dist/provider/lab-theme.d.ts +39 -0
  55. package/dist/provider/lab-theme.d.ts.map +1 -0
  56. package/dist/provider/lab-theme.js +52 -0
  57. package/dist/shell/app-header.module.css +2 -2
  58. package/dist/shell/app-mobile-nav.module.css +1 -1
  59. package/dist/shell/app-sidebar-account.d.ts.map +1 -1
  60. package/dist/shell/app-sidebar-account.js +4 -2
  61. package/dist/shell/app-sidebar.d.ts.map +1 -1
  62. package/dist/shell/app-sidebar.js +4 -2
  63. package/dist/shell/app-sidebar.module.css +36 -26
  64. package/dist/shell/index.d.ts.map +1 -1
  65. package/dist/shell/index.js +11 -4
  66. package/dist/shell/sidebar-search.module.css +16 -4
  67. package/dist/styles.css +1 -1
  68. package/dist/surfaces.d.ts +16 -12
  69. package/dist/surfaces.d.ts.map +1 -1
  70. package/dist/surfaces.js +12 -4
  71. package/dist/theme/controls.module.css +1 -1
  72. package/dist/theme/floating.module.css +1 -1
  73. package/dist/theme/index.d.ts +116 -11
  74. package/dist/theme/index.d.ts.map +1 -1
  75. package/dist/theme/index.js +703 -566
  76. package/dist/theme/nav-link.module.css +1 -1
  77. package/dist/theme/use-basalt-spacing.d.ts +3 -0
  78. package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
  79. package/dist/theme/use-basalt-spacing.js +8 -0
  80. package/dist/theme-lab/derive-controls.d.ts +13 -0
  81. package/dist/theme-lab/derive-controls.d.ts.map +1 -0
  82. package/dist/theme-lab/derive-controls.js +137 -0
  83. package/dist/theme-lab/derive-state.d.ts +55 -0
  84. package/dist/theme-lab/derive-state.d.ts.map +1 -0
  85. package/dist/theme-lab/derive-state.js +81 -0
  86. package/dist/theme-lab/index.d.ts +12 -2
  87. package/dist/theme-lab/index.d.ts.map +1 -1
  88. package/dist/theme-lab/index.js +13 -62
  89. package/dist/theme-toggle/index.d.ts.map +1 -1
  90. package/dist/theme-toggle/index.js +3 -2
  91. package/dist/tokens/derive.d.ts +89 -0
  92. package/dist/tokens/derive.d.ts.map +1 -0
  93. package/dist/tokens/derive.js +250 -0
  94. package/dist/tokens/hct.d.ts +34 -0
  95. package/dist/tokens/hct.d.ts.map +1 -0
  96. package/dist/tokens/hct.js +159 -0
  97. package/dist/tokens/index.d.ts +71 -7
  98. package/dist/tokens/index.d.ts.map +1 -1
  99. package/dist/tokens/index.js +284 -46
  100. package/dist/tokens/palette.d.ts +984 -167
  101. package/dist/tokens/palette.d.ts.map +1 -1
  102. package/dist/tokens/palette.js +617 -119
  103. package/dist/vite-color-mix.d.ts +30 -0
  104. package/dist/vite-color-mix.d.ts.map +1 -0
  105. package/dist/vite-color-mix.js +80 -0
  106. package/dist/vite.d.ts +82 -1
  107. package/dist/vite.d.ts.map +1 -1
  108. package/dist/vite.js +312 -0
  109. package/llms.txt +5 -4
  110. package/package.json +24 -9
  111. package/src/agent/part-list.tsx +13 -7
  112. package/src/agent/stick-to-bottom.tsx +2 -2
  113. package/src/agent-chat/thread-detail-panel.tsx +13 -10
  114. package/src/agent-chat/thread-message.tsx +8 -5
  115. package/src/agent-chat/thread-outcome-card.tsx +2 -2
  116. package/src/agent-chat/thread-workspace.tsx +2 -2
  117. package/src/charts/primitives/ChartLegend.tsx +2 -2
  118. package/src/charts/primitives/ChartTooltip.tsx +2 -2
  119. package/src/cli/check-theme.test.ts +18 -0
  120. package/src/cli/index.ts +112 -20
  121. package/src/cli/init-sync.test.ts +68 -0
  122. package/src/connectivity/connectivity-indicator.tsx +8 -2
  123. package/src/content/article-card.module.css +7 -5
  124. package/src/content/article-layout.module.css +16 -12
  125. package/src/content/callout.module.css +4 -4
  126. package/src/content/code-block.module.css +8 -7
  127. package/src/content/guide.module.css +3 -3
  128. package/src/content/mermaid.module.css +2 -2
  129. package/src/content/prose.module.css +59 -29
  130. package/src/content/prose.module.css.test.ts +55 -0
  131. package/src/content/reading-progress.module.css +2 -0
  132. package/src/content/toc.module.css +6 -3
  133. package/src/dashboard/delta-badge.tsx +10 -4
  134. package/src/dashboard/empty-state.tsx +3 -16
  135. package/src/dashboard/settings-section.module.css +2 -2
  136. package/src/dashboard/settings-section.tsx +2 -2
  137. package/src/dashboard/stat-card.tsx +2 -2
  138. package/src/data/virtual-list.tsx +12 -2
  139. package/src/forms/FormErrorSummary.tsx +1 -1
  140. package/src/guard/check-source.test.ts +416 -5
  141. package/src/guard/index.ts +367 -45
  142. package/src/guard/types.ts +24 -2
  143. package/src/index.ts +1 -0
  144. package/src/provider/index.test.tsx +100 -0
  145. package/src/provider/index.tsx +79 -7
  146. package/src/provider/lab-theme.test.ts +147 -0
  147. package/src/provider/lab-theme.ts +166 -0
  148. package/src/shell/app-header.module.css +2 -2
  149. package/src/shell/app-mobile-nav.module.css +1 -1
  150. package/src/shell/app-sidebar-account.tsx +9 -2
  151. package/src/shell/app-sidebar.module.css +36 -26
  152. package/src/shell/app-sidebar.tsx +12 -2
  153. package/src/shell/index.tsx +14 -3
  154. package/src/shell/sidebar-search.module.css +16 -4
  155. package/src/styles.css +1 -1
  156. package/src/surfaces.ts +25 -11
  157. package/src/theme/contrast.test.ts +19 -3
  158. package/src/theme/controls.module.css +1 -1
  159. package/src/theme/density-option.test.ts +96 -0
  160. package/src/theme/density-relations.test.ts +428 -0
  161. package/src/theme/derive-theme.test.ts +101 -0
  162. package/src/theme/floating.module.css +1 -1
  163. package/src/theme/fonts-option.test.ts +69 -0
  164. package/src/theme/index.ts +930 -563
  165. package/src/theme/nav-link.module.css +1 -1
  166. package/src/theme/radius-option.test.ts +86 -0
  167. package/src/theme/radius.test.ts +132 -0
  168. package/src/theme/spacing.test.ts +432 -0
  169. package/src/theme/use-basalt-spacing.test.tsx +51 -0
  170. package/src/theme/use-basalt-spacing.ts +38 -0
  171. package/src/theme-lab/derive-controls.test.ts +94 -0
  172. package/src/theme-lab/derive-controls.tsx +227 -0
  173. package/src/theme-lab/derive-state.test.ts +71 -0
  174. package/src/theme-lab/derive-state.ts +163 -0
  175. package/src/theme-lab/index.tsx +29 -68
  176. package/src/theme-lab/theme-lab.test.ts +4 -18
  177. package/src/theme-toggle/index.tsx +9 -4
  178. package/src/tokens/build-fonts-css.test.ts +51 -0
  179. package/src/tokens/build-radius-css.test.ts +25 -0
  180. package/src/tokens/density.test.ts +274 -0
  181. package/src/tokens/derive-radius.test.ts +62 -0
  182. package/src/tokens/derive.test.ts +30 -0
  183. package/src/tokens/derive.ts +481 -0
  184. package/src/tokens/hct.ts +231 -0
  185. package/src/tokens/index.ts +395 -45
  186. package/src/tokens/palette.test.ts +114 -0
  187. package/src/tokens/palette.ts +1118 -180
  188. package/src/vite-color-mix.test.ts +46 -0
  189. package/src/vite-color-mix.ts +137 -0
  190. package/src/vite.test.ts +192 -0
  191. package/src/vite.ts +502 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ./guard — headless policy core. Mantine-free, dependency-free.
3
3
  *
4
- * GUARD_RULES: the closed registry of all 18 violation kinds.
4
+ * GUARD_RULES: the closed registry of all 19 violation kinds.
5
5
  * checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
6
6
  */
7
7
  import type { Finding, GuardConfig, GuardKind } from './types'
@@ -14,12 +14,32 @@ const HEX = /#[0-9a-fA-F]{3,8}\b/g
14
14
  const FUNC = /\b(?:rgba?|hsla?)\(/g
15
15
  const LOCALSTORAGE_THEME = /localStorage\s*\.\s*getItem\s*\(\s*['"]theme['"]\s*\)/g
16
16
 
17
+ // A hardcoded fontFamily/font-family literal — camelCase (JSX prop / object property, quoted
18
+ // value) or kebab-case (CSS text in a template literal, quoted OR bare value — kebab-case is never
19
+ // a valid unquoted JS identifier, so a bare `font-family: Inter` can only be literal CSS text).
20
+ // The escape is a `var(...)` reference restricted to the two entry-point prefixes
21
+ // (`--basalt-font-*` / `--mantine-font-family-*`) — any OTHER var() reference still flags, so the
22
+ // single-entry-point invariant holds. A CSS-wide keyword (inherit/initial/unset/revert) never
23
+ // flags either: it defers to the cascade rather than hardcoding a font.
24
+ const RAW_FONT_FAMILY_VAR_ESCAPE = /var\(\s*--(?:basalt-font-|mantine-font-family-)/.source
25
+ const RAW_FONT_FAMILY_KEYWORD = /(?:inherit|initial|unset|revert)\b/.source
26
+ const RAW_FONT_FAMILY = new RegExp(
27
+ `\\bfontFamily\\s*[:=]\\s*\\{?(?!['"\`]?\\s*${RAW_FONT_FAMILY_VAR_ESCAPE})(?!['"\`]?\\s*${RAW_FONT_FAMILY_KEYWORD})['"\`][^'"\`]+['"\`]` +
28
+ `|\\bfont-family\\s*:\\s*(?!['"\`]?\\s*${RAW_FONT_FAMILY_VAR_ESCAPE})(?!['"\`]?\\s*${RAW_FONT_FAMILY_KEYWORD})(?:['"\`][^'"\`]+['"\`]|[A-Za-z][\\w-]*)`,
29
+ 'g',
30
+ )
31
+
17
32
  // Ad-hoc inline surface styling — border* / borderRadius / boxShadow with literal values.
18
- // A var(--…) reference inside the quoted value passes (the system itself).
33
+ // Three escapes pass (the value is already system-routed, not a hardcoded surface literal):
34
+ // • a `var(--…)` reference — the CSS-var system itself;
35
+ // • a `${…}` template-literal interpolation — the value is JS-composed, typically from `VX.*`
36
+ // tokens; any raw color inside it is separately caught by raw-hex / raw-color-fn;
37
+ // • for `border*` only, a bare `none`/`transparent`/`inherit`/`unset`/`revert` keyword — a reset,
38
+ // not a surface definition.
19
39
  const SURFACE_BORDER =
20
- /\bborder(?:Top|Bottom|Left|Right)?\s*:\s*(?!['"`]?[^'"`]*var\()['"`][^'"`]+['"`]/g
40
+ /\bborder(?:Top|Bottom|Left|Right)?\s*:\s*(?!['"`]?[^'"`]*(?:var\(|\$\{))(?!['"`]?(?:none|transparent|inherit|unset|revert)\b)['"`][^'"`]+['"`]/g
21
41
  const SURFACE_RADIUS = /\bborderRadius\s*:\s*(?:[0-9]+|['"`](?!\s*var\()[^'"`]*[0-9])/g
22
- const SURFACE_SHADOW = /\bboxShadow\s*:\s*(?!['"`]?[^'"`]*var\()['"`][^'"`]+['"`]/g
42
+ const SURFACE_SHADOW = /\bboxShadow\s*:\s*(?!['"`]?[^'"`]*(?:var\(|\$\{))['"`][^'"`]+['"`]/g
23
43
 
24
44
  // A `Card` / `Paper` opening tag carrying `withBorder`. Card depth is `--vx-shadow-card`, whose 1px
25
45
  // ring lives INSIDE the shadow value; `withBorder` therefore adds a SECOND, real `border` property
@@ -132,6 +152,7 @@ export const DEFAULT_GUARD_CONFIG: GuardConfig = {
132
152
  rawFormControl: true,
133
153
  sub16InputFont: true,
134
154
  allowComment: 'theme-allow',
155
+ exemptRules: {},
135
156
  }
136
157
 
137
158
  // ── Path predicate ────────────────────────────────────────────────────────────────────────────────
@@ -141,14 +162,247 @@ function isChartFile(relPath: string): boolean {
141
162
  }
142
163
 
143
164
  /**
144
- * The skip policy the per-line loop applies inline, reused by the full-text tag-scoped scans
145
- * (which resolve their own report line and so must re-check it): a line carrying the allow-comment,
146
- * or a pure-comment line, is never a violation.
165
+ * Whether `kind` is exempted at `relPath` via `cfg.exemptRules` — the config-driven, per-rule
166
+ * counterpart to `isChartFile`'s hardcoded path scoping. A pattern matches when `relPath` split on
167
+ * `/` includes it as a WHOLE segment (a trailing `/` is stripped first, so `'agent'` and `'agent/'`
168
+ * are equivalent); a substring match against one longer segment (e.g. `'age'` against `agent`)
169
+ * never counts.
170
+ */
171
+ function isRuleExempt(
172
+ kind: GuardKind,
173
+ relPath: string,
174
+ exemptRules: GuardConfig['exemptRules'],
175
+ ): boolean {
176
+ const patterns = exemptRules?.[kind]
177
+ if (patterns === undefined || patterns.length === 0) return false
178
+ const segments = relPath.split('/')
179
+ return patterns.some((pattern) => segments.includes(pattern.replace(/\/$/, '')))
180
+ }
181
+
182
+ /**
183
+ * The allow-comment skip the full-text tag-scoped scans re-apply on their own resolved report
184
+ * line: a line carrying the allow-comment is never a violation. Pure-comment lines need no
185
+ * special case here anymore — they are handled upstream by `stripComments` (matches simply can't
186
+ * land on blanked-out comment text), so this only ever runs against the ORIGINAL (unstripped)
187
+ * line, since the allow-comment annotation itself lives inside a comment.
147
188
  */
148
189
  function isSkippedLine(line: string, cfg: GuardConfig): boolean {
149
- if (line.includes(cfg.allowComment)) return true
150
- const trimmed = line.trimStart()
151
- return trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')
190
+ return line.includes(cfg.allowComment)
191
+ }
192
+
193
+ /** The 2 comment/regex dialects the stripper understands, resolved from the file's own extension. */
194
+ type GuardSyntax = 'ts' | 'css'
195
+
196
+ /**
197
+ * CSS (including `.module.css`) has no `//` line-comment syntax at all — an unquoted `//`, e.g.
198
+ * inside `url(https://…)`, is real CSS text, never a comment opener. Match on the `.css` suffix
199
+ * (not a naive `split('.')`) so `foo.module.css` resolves the same as `foo.css`.
200
+ */
201
+ function guardSyntaxFor(relPath: string): GuardSyntax {
202
+ return relPath.endsWith('.css') ? 'css' : 'ts'
203
+ }
204
+
205
+ // A `/` opens a regex literal (not division) when the previous significant token is one of these
206
+ // punctuation marks, or one of the REGEX_PRECEDING_KEYWORDS below, or nothing has been scanned yet
207
+ // (start of input) — the standard JS lexer disambiguation. `ts`-syntax only; CSS has no regexes.
208
+ const REGEX_PRECEDING_PUNCT = new Set([
209
+ '=',
210
+ '(',
211
+ ',',
212
+ '[',
213
+ ':',
214
+ '!',
215
+ '&',
216
+ '|',
217
+ '?',
218
+ '{',
219
+ '}',
220
+ ';',
221
+ '+',
222
+ '-',
223
+ '*',
224
+ '%',
225
+ '~',
226
+ '^',
227
+ '<',
228
+ ])
229
+ const REGEX_PRECEDING_KEYWORDS = new Set([
230
+ 'return',
231
+ 'typeof',
232
+ 'case',
233
+ 'in',
234
+ 'of',
235
+ 'delete',
236
+ 'void',
237
+ 'throw',
238
+ 'do',
239
+ 'else',
240
+ ])
241
+ const WORD_CHAR = /[A-Za-z0-9_$]/
242
+
243
+ /**
244
+ * Strip comments out of source text, leaving real comment-awareness in place of the old per-line
245
+ * prefix heuristic (which only caught a comment when ITS OWN line happened to start with `//` /
246
+ * `*` / `/*` — a block-comment continuation line that didn't start with `*` slipped straight
247
+ * through as if it were code).
248
+ *
249
+ * Stripped characters are replaced 1:1 with a space (newlines are preserved verbatim), so the
250
+ * output is the SAME LENGTH as the input and every remaining token keeps its exact original line
251
+ * number and character offset — callers can keep using `text.slice(0, i).split('\n').length` for
252
+ * line numbers exactly as before.
253
+ *
254
+ * Deliberately does NOT touch string literals (`'`, `"`, backtick, backslash-escaped): a raw hex
255
+ * or a `//` inside a string is real source text, not a comment, and must still be scanned as-is
256
+ * (e.g. a URL like `'https://x.com/#abc'` must not have its `//` treated as a line comment).
257
+ *
258
+ * `syntax === 'css'` disables `//` line-comment handling entirely (CSS only has `/* *\/`) — an
259
+ * unquoted `url(https://…)` must never have its rest-of-line blanked (that was the BUG 2 false
260
+ * negative: a real violation on the same line silently disappearing behind a bogus "comment").
261
+ *
262
+ * `syntax === 'ts'` additionally recognizes regex literals (`/…/flags`) via
263
+ * `REGEX_PRECEDING_PUNCT` / `REGEX_PRECEDING_KEYWORDS` and consumes them VERBATIM — a `/*` or `//`
264
+ * shaped sequence inside a regex body (e.g. a character class `/[/*]/`) is real regex source, not
265
+ * a comment opener, and must not open a block comment that then runs away to EOF eating every
266
+ * subsequent line unrecoverably (that was the BUG 1 false negative — total loss of guard coverage
267
+ * for the rest of the file). The heuristic is inherently imperfect (full disambiguation needs a
268
+ * real parser), so it is DELIBERATELY biased toward treating an ambiguous `/` as division, i.e.
269
+ * NOT a regex, i.e. NOT specially protected: an under-strip here just leaves a `/` as an ordinary
270
+ * character (worst case a spurious finding a human can `theme-allow`), whereas an over-eager
271
+ * regex-open would swallow real code as "protected regex content" and could hide a genuine
272
+ * violation — the failure mode BUG 1 already showed is unacceptable.
273
+ */
274
+ function stripComments(text: string, syntax: GuardSyntax): string {
275
+ const out: string[] = Array.from<string>({ length: text.length })
276
+ let inLineComment = false
277
+ let inBlockComment = false
278
+ let stringQuote: string | null = null
279
+ let currentWord = ''
280
+ let lastUnitType: 'word' | 'punct' | 'none' = 'none'
281
+ let lastWord = ''
282
+ let lastPunct = ''
283
+ let i = 0
284
+
285
+ function flushWord(): void {
286
+ if (currentWord === '') return
287
+ lastUnitType = 'word'
288
+ lastWord = currentWord
289
+ currentWord = ''
290
+ }
291
+
292
+ function canPrecedeRegex(): boolean {
293
+ if (lastUnitType === 'none') return true
294
+ if (lastUnitType === 'word') return REGEX_PRECEDING_KEYWORDS.has(lastWord)
295
+ return REGEX_PRECEDING_PUNCT.has(lastPunct)
296
+ }
297
+
298
+ while (i < text.length) {
299
+ const ch = text[i] ?? ''
300
+
301
+ if (inLineComment) {
302
+ out[i] = ch === '\n' ? '\n' : ' '
303
+ if (ch === '\n') inLineComment = false
304
+ i++
305
+ continue
306
+ }
307
+
308
+ if (inBlockComment) {
309
+ if (ch === '*' && text[i + 1] === '/') {
310
+ out[i] = ' '
311
+ out[i + 1] = ' '
312
+ i += 2
313
+ inBlockComment = false
314
+ continue
315
+ }
316
+ out[i] = ch === '\n' ? '\n' : ' '
317
+ i++
318
+ continue
319
+ }
320
+
321
+ if (stringQuote !== null) {
322
+ out[i] = ch
323
+ if (ch === '\\' && i + 1 < text.length) {
324
+ out[i + 1] = text[i + 1] ?? ''
325
+ i += 2
326
+ continue
327
+ }
328
+ if (ch === stringQuote) stringQuote = null
329
+ i++
330
+ continue
331
+ }
332
+
333
+ if (WORD_CHAR.test(ch)) {
334
+ currentWord += ch
335
+ out[i] = ch
336
+ i++
337
+ continue
338
+ }
339
+ flushWord()
340
+
341
+ if (ch === "'" || ch === '"' || ch === '`') {
342
+ stringQuote = ch
343
+ out[i] = ch
344
+ lastUnitType = 'punct'
345
+ lastPunct = ch
346
+ i++
347
+ continue
348
+ }
349
+
350
+ if (ch === '/' && text[i + 1] === '*') {
351
+ inBlockComment = true
352
+ out[i] = ' '
353
+ i++
354
+ continue
355
+ }
356
+
357
+ if (syntax === 'ts' && ch === '/' && text[i + 1] === '/') {
358
+ inLineComment = true
359
+ out[i] = ' '
360
+ i++
361
+ continue
362
+ }
363
+
364
+ if (syntax === 'ts' && ch === '/' && canPrecedeRegex()) {
365
+ // Consume the regex literal VERBATIM: backslash escapes and `[...]` character classes never
366
+ // close it early. A raw newline before the closing `/` means this was never a valid regex
367
+ // (JS disallows a literal line terminator inside one) — bail out of regex mode right there;
368
+ // every character up to the newline was already copied through unchanged either way, so
369
+ // bailing loses nothing.
370
+ out[i] = ch
371
+ let j = i + 1
372
+ let inClass = false
373
+ while (j < text.length) {
374
+ const rc = text[j] ?? ''
375
+ if (rc === '\n') break
376
+ out[j] = rc
377
+ if (rc === '\\' && j + 1 < text.length) {
378
+ out[j + 1] = text[j + 1] ?? ''
379
+ j += 2
380
+ continue
381
+ }
382
+ if (rc === '[') inClass = true
383
+ else if (rc === ']') inClass = false
384
+ else if (rc === '/' && !inClass) {
385
+ j++
386
+ break
387
+ }
388
+ j++
389
+ }
390
+ i = j
391
+ lastUnitType = 'punct'
392
+ lastPunct = '/'
393
+ continue
394
+ }
395
+
396
+ // Plain `/` (division, or any bare `/` in CSS syntax) — or any other punctuation/whitespace.
397
+ out[i] = ch
398
+ if (!/\s/.test(ch)) {
399
+ lastUnitType = 'punct'
400
+ lastPunct = ch
401
+ }
402
+ i++
403
+ }
404
+
405
+ return out.join('')
152
406
  }
153
407
 
154
408
  // ── GUARD_RULES registry ─────────────────────────────────────────────────────────────────────────
@@ -166,7 +420,7 @@ type GuardRule = {
166
420
  }
167
421
 
168
422
  /**
169
- * The closed registry of all 18 guard kinds. The triad test asserts
423
+ * The closed registry of all 19 guard kinds. The triad test asserts
170
424
  * `surface.guardKinds ⊆ keyof GUARD_RULES` at runtime.
171
425
  *
172
426
  * raw-surface, raw-html-layout, and sub-16-input-font are handled inline in checkSource
@@ -194,8 +448,16 @@ export const GUARD_RULES = {
194
448
  'localstorage-theme': {
195
449
  kind: 'localstorage-theme',
196
450
  pattern: LOCALSTORAGE_THEME,
451
+ // JS-call-shaped (`localStorage.getItem('theme')`) — never appears in CSS text.
452
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
197
453
  message: 'Theme must resolve via the Mantine color scheme + --vx-* vars.',
198
454
  },
455
+ 'raw-font-family': {
456
+ kind: 'raw-font-family',
457
+ pattern: RAW_FONT_FAMILY,
458
+ message:
459
+ 'Route the font stack through createBasaltTheme(overrides, { fonts }) / the shipped --basalt-font-sans|head|mono vars instead of a hardcoded fontFamily literal.',
460
+ },
199
461
  'off-identity-accent': {
200
462
  kind: 'off-identity-accent',
201
463
  pattern: (cfg: GuardConfig) =>
@@ -203,6 +465,10 @@ export const GUARD_RULES = {
203
465
  `\\b(?:color|c|bg|backgroundColor)\\s*=\\s*\\{?\\s*['"](${cfg.forbiddenAccents.join('|')})['"]`,
204
466
  'g',
205
467
  ),
468
+ // JSX-prop-shaped (`color={"teal"}`) — CSS declares `color: teal;` with a bare keyword and
469
+ // `:`, which the pattern's `=` anchor can never match; gated off explicitly so a future regex
470
+ // tweak can't silently start false-positiving on consumer CSS.
471
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
206
472
  message: 'For an off-identity accent use blue/gray or a status hue (red/green/orange/yellow).',
207
473
  },
208
474
  'raw-spacing': {
@@ -212,12 +478,17 @@ export const GUARD_RULES = {
212
478
  `\\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)=\\{(?:${cfg.spacingSteps.join('|')})\\}`,
213
479
  'g',
214
480
  ),
481
+ // JSX-prop-shaped (`p={16}`) — CSS has no `=`/`{}` prop syntax; gated off explicitly (see
482
+ // off-identity-accent above for why "never matches today" still gets an explicit gate).
483
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
215
484
  message: 'Use the Mantine spacing prop/token (p/m/gap with xs..xl).',
216
485
  },
217
486
  'raw-radius': {
218
487
  kind: 'raw-radius',
219
488
  pattern: RADIUS_PROP_RE,
220
489
  enabled: (cfg: GuardConfig) => cfg.rawRadius,
490
+ // JSX-prop-shaped (`radius={6}`) — CSS declares `border-radius: 6px;`, never `radius=`.
491
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
221
492
  message: 'Use the radius token (radius="md") instead of a numeric literal.',
222
493
  },
223
494
  'raw-surface': {
@@ -231,6 +502,8 @@ export const GUARD_RULES = {
231
502
  kind: 'card-with-border',
232
503
  pattern: CARD_SURFACE_TAG, // handled inline (full-text tag-scoped scan); entry keeps registry complete
233
504
  enabled: (cfg: GuardConfig) => cfg.cardWithBorder,
505
+ // JSX-tag-shaped (`<Card withBorder>`) — never appears in CSS text.
506
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
234
507
  message:
235
508
  'withBorder on a Card/Paper double-draws the edge — card depth is --vx-shadow-card, which already bakes a 1px ring into the shadow. Drop the prop (docs/DESIGN-SPEC.md doctrine inversion #1).',
236
509
  },
@@ -245,6 +518,8 @@ export const GUARD_RULES = {
245
518
  kind: 'raw-html-layout',
246
519
  pattern: RAW_HTML_TAG, // handled inline (3-condition conjunction); entry keeps registry complete
247
520
  enabled: (cfg: GuardConfig) => cfg.rawHtmlLayout,
521
+ // JSX-tag-shaped (`<div style={{...}}>`) — never appears in CSS text.
522
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
248
523
  message:
249
524
  'Raw HTML element with inline layout/surface styling — use a Mantine layout primitive (Box/Flex/Grid/Stack/Group).',
250
525
  },
@@ -258,13 +533,18 @@ export const GUARD_RULES = {
258
533
  kind: 'inline-display',
259
534
  pattern: INLINE_DISPLAY,
260
535
  enabled: (cfg: GuardConfig) => cfg.inlineDisplay,
536
+ // JSX-object-shaped (`display: 'flex'`, quoted value) — CSS never quotes a keyword value
537
+ // (`display: flex;` is bare), so the pattern's quote anchor can never match real CSS.
538
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
261
539
  message: 'Use <Flex>/<Grid>/<Group> instead of an inline display:flex/grid.',
262
540
  },
263
541
  'raw-visx-axis': {
264
542
  kind: 'raw-visx-axis',
265
543
  pattern: RAW_VISX_AXIS,
266
544
  enabled: (cfg: GuardConfig) => cfg.rawVisxAxis,
267
- appliesTo: isChartFile,
545
+ // Compose the existing chart-file scope with the CSS gate — a chart-file CSS module (none
546
+ // exist today, but the boundary should hold regardless) still can't carry a JSX axis tag.
547
+ appliesTo: (relPath) => isChartFile(relPath) && !relPath.endsWith('.css'),
268
548
  message:
269
549
  'Raw <AxisLeft>/<AxisBottom>/<AxisRight> in a chart file — use AxisLeftNumeric / AxisBottomDate / AxisRightNumeric.',
270
550
  },
@@ -272,6 +552,9 @@ export const GUARD_RULES = {
272
552
  kind: 'raw-motion-value',
273
553
  pattern: MOTION_TRANSITION_NUMERIC, // handled inline (2-regex kind); entry keeps registry complete
274
554
  enabled: (cfg: GuardConfig) => cfg.rawMotionValue,
555
+ // JSX-prop-shaped (`transition={{ duration: … }}`) — CSS's `transition:` property has no `=`
556
+ // or `{{`.
557
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
275
558
  message:
276
559
  'Route animation timing through MOTION_DURATION / MOTION_SPRING / MOTION_EASE_STANDARD (basalt-ui motion tokens) instead of a hardcoded duration/spring/ease.',
277
560
  },
@@ -279,6 +562,8 @@ export const GUARD_RULES = {
279
562
  kind: 'unframed-chart',
280
563
  pattern: RAW_CHART_LEGEND_ARRAY, // handled inline (full-text tag-scoped scan); entry keeps registry complete
281
564
  enabled: (cfg: GuardConfig) => cfg.unframedChart,
565
+ // JSX-tag-shaped (`<ChartLegend items={[…]}>`) — never appears in CSS text.
566
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
282
567
  message:
283
568
  'Hand-rolled ChartLegend built from an inline array literal — pass a derived legend (deriveLegend(series)), or compose ChartFrame, which derives it for you.',
284
569
  },
@@ -286,6 +571,8 @@ export const GUARD_RULES = {
286
571
  kind: 'chart-missing-aria-label',
287
572
  pattern: CHART_ENTRY_POINT_TAG, // handled inline (full-text tag-scoped scan); entry keeps registry complete
288
573
  enabled: (cfg: GuardConfig) => cfg.chartMissingAriaLabel,
574
+ // JSX-tag-shaped (`<MultiLine …>`) — never appears in CSS text.
575
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
289
576
  message:
290
577
  'Chart has no accessible text alternative — pass ariaLabel="…" so screen readers get more than an unlabeled graphic.',
291
578
  },
@@ -293,6 +580,9 @@ export const GUARD_RULES = {
293
580
  kind: 'raw-form-control',
294
581
  pattern: RAW_FORM_CONTROL,
295
582
  enabled: (cfg: GuardConfig) => cfg.rawFormControl,
583
+ // JSX-tag-shaped (`<input …>`) — a CSS element selector (`input, select {…}`) has no leading
584
+ // `<`, so the pattern's anchor can never match real CSS.
585
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
296
586
  message:
297
587
  'Raw <input>/<select>/<textarea> bypasses the ENTIRE theme, not just the font-size floor — no field surface, no shadow-card depth, no focus ring, no --input-* vars. Use TextInput / NumberInput / Select / Textarea from @mantine/core, or variant="unstyled" for a genuinely borderless/bespoke look.',
298
588
  },
@@ -300,11 +590,20 @@ export const GUARD_RULES = {
300
590
  kind: 'sub-16-input-font',
301
591
  pattern: SUB_16_FONT_SIZE, // handled inline (full-text tag-scoped scan); entry keeps registry complete
302
592
  enabled: (cfg: GuardConfig) => cfg.sub16InputFont,
593
+ // Only ever fires nested inside a raw-form-control JSX tag or a `styles={{ input: {…} }}`
594
+ // object literal — both JSX-shaped, neither appears in CSS text.
595
+ appliesTo: (relPath) => !relPath.endsWith('.css'),
303
596
  message:
304
597
  'fontSize below 16 on a form control is dead code — the styles.css iOS floor is `!important` and always wins. Either drop the override, or be honest about 16px in the design.',
305
598
  },
306
599
  } as const satisfies Record<GuardKind, GuardRule>
307
600
 
601
+ /** Whether `kind`'s rule fires for `relPath` — `appliesTo` is opt-in; absent means always applies. */
602
+ function ruleApplies(kind: GuardKind, relPath: string): boolean {
603
+ const appliesTo = (GUARD_RULES[kind] as GuardRule).appliesTo
604
+ return appliesTo === undefined || appliesTo(relPath)
605
+ }
606
+
308
607
  // ── checkSource ───────────────────────────────────────────────────────────────────────────────────
309
608
 
310
609
  /**
@@ -331,14 +630,19 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
331
630
  (GUARD_RULES['raw-radius'].pattern as RegExp).flags,
332
631
  )
333
632
 
633
+ // Comment-stripped text drives every match below; `lines` (the ORIGINAL, unstripped split) is
634
+ // kept only to resolve the allow-comment escape, since that annotation lives inside a comment
635
+ // the stripped text has already blanked out. Same length / same newline positions as `text`, so
636
+ // line numbers computed off either one agree.
334
637
  const lines = text.split('\n')
638
+ const codeText = stripComments(text, guardSyntaxFor(relPath))
639
+ const codeLines = codeText.split('\n')
640
+
335
641
  for (let i = 0; i < lines.length; i++) {
336
- const line = lines[i] ?? ''
642
+ const line = codeLines[i] ?? ''
337
643
 
338
- // Skip lines with the allow-comment or pure-comment lines.
339
- if (line.includes(cfg.allowComment)) continue
340
- const trimmed = line.trimStart()
341
- if (trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')) continue
644
+ // Skip lines with the allow-comment (checked against the ORIGINAL line text).
645
+ if ((lines[i] ?? '').includes(cfg.allowComment)) continue
342
646
 
343
647
  // Always-on kinds (raw-hex, raw-color-fn, localstorage-theme) — patterns from GUARD_RULES.
344
648
  for (const m of line.matchAll(GUARD_RULES['raw-hex'].pattern as RegExp)) {
@@ -347,18 +651,27 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
347
651
  for (const m of line.matchAll(GUARD_RULES['raw-color-fn'].pattern as RegExp)) {
348
652
  findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-color-fn' })
349
653
  }
350
- for (const m of line.matchAll(GUARD_RULES['localstorage-theme'].pattern as RegExp)) {
351
- findings.push({ relPath, line: i + 1, token: m[0], kind: 'localstorage-theme' })
654
+ if (ruleApplies('localstorage-theme', relPath)) {
655
+ for (const m of line.matchAll(GUARD_RULES['localstorage-theme'].pattern as RegExp)) {
656
+ findings.push({ relPath, line: i + 1, token: m[0], kind: 'localstorage-theme' })
657
+ }
658
+ }
659
+ for (const m of line.matchAll(GUARD_RULES['raw-font-family'].pattern as RegExp)) {
660
+ findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-font-family' })
352
661
  }
353
662
 
354
663
  // Dynamic-regex kinds — patterns already resolved above.
355
- for (const m of line.matchAll(forbiddenAccentRe)) {
356
- findings.push({ relPath, line: i + 1, token: m[1] ?? '', kind: 'off-identity-accent' })
664
+ if (ruleApplies('off-identity-accent', relPath)) {
665
+ for (const m of line.matchAll(forbiddenAccentRe)) {
666
+ findings.push({ relPath, line: i + 1, token: m[1] ?? '', kind: 'off-identity-accent' })
667
+ }
357
668
  }
358
- for (const m of line.matchAll(spacingPropRe)) {
359
- findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-spacing' })
669
+ if (ruleApplies('raw-spacing', relPath)) {
670
+ for (const m of line.matchAll(spacingPropRe)) {
671
+ findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-spacing' })
672
+ }
360
673
  }
361
- if (GUARD_RULES['raw-radius'].enabled!(cfg)) {
674
+ if (GUARD_RULES['raw-radius'].enabled!(cfg) && ruleApplies('raw-radius', relPath)) {
362
675
  for (const m of line.matchAll(radiusPropRe)) {
363
676
  findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-radius' })
364
677
  }
@@ -387,6 +700,7 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
387
700
  // raw-html-layout: 3-condition conjunction on the same line — gated via GUARD_RULES entry.
388
701
  if (
389
702
  GUARD_RULES['raw-html-layout'].enabled!(cfg) &&
703
+ ruleApplies('raw-html-layout', relPath) &&
390
704
  RAW_HTML_TAG.test(line) &&
391
705
  INLINE_STYLE.test(line) &&
392
706
  LAYOUT_SURFACE_PROP.test(line)
@@ -402,13 +716,14 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
402
716
  }
403
717
 
404
718
  // inline-display — pattern + gating from GUARD_RULES.
405
- if (GUARD_RULES['inline-display'].enabled!(cfg)) {
719
+ if (GUARD_RULES['inline-display'].enabled!(cfg) && ruleApplies('inline-display', relPath)) {
406
720
  for (const m of line.matchAll(GUARD_RULES['inline-display'].pattern as RegExp)) {
407
721
  findings.push({ relPath, line: i + 1, token: m[0], kind: 'inline-display' })
408
722
  }
409
723
  }
410
724
 
411
- // raw-visx-axis — pattern + gating + path applicability from GUARD_RULES.
725
+ // raw-visx-axis — pattern + gating + path applicability (chart-file scope AND CSS gate,
726
+ // composed on the registry's own appliesTo) from GUARD_RULES.
412
727
  if (
413
728
  GUARD_RULES['raw-visx-axis'].enabled!(cfg) &&
414
729
  GUARD_RULES['raw-visx-axis'].appliesTo!(relPath)
@@ -419,7 +734,7 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
419
734
  }
420
735
 
421
736
  // raw-motion-value: 2 separate regex checks, one kind — gated via GUARD_RULES entry.
422
- if (GUARD_RULES['raw-motion-value'].enabled!(cfg)) {
737
+ if (GUARD_RULES['raw-motion-value'].enabled!(cfg) && ruleApplies('raw-motion-value', relPath)) {
423
738
  for (const m of line.matchAll(MOTION_TRANSITION_NUMERIC)) {
424
739
  findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-motion-value' })
425
740
  }
@@ -429,7 +744,7 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
429
744
  }
430
745
 
431
746
  // raw-form-control — pattern + gating from GUARD_RULES.
432
- if (GUARD_RULES['raw-form-control'].enabled!(cfg)) {
747
+ if (GUARD_RULES['raw-form-control'].enabled!(cfg) && ruleApplies('raw-form-control', relPath)) {
433
748
  for (const m of line.matchAll(GUARD_RULES['raw-form-control'].pattern as RegExp)) {
434
749
  findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-form-control' })
435
750
  }
@@ -437,11 +752,12 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
437
752
  }
438
753
 
439
754
  // unframed-chart — full-text tag-scoped scan (not per-line, see RAW_CHART_LEGEND_ARRAY comment).
440
- // Reports at the line of the `items={[` token itself; honors the same theme-allow / pure-comment
441
- // skip as every per-line kind by checking that reported line directly.
442
- if (GUARD_RULES['unframed-chart'].enabled!(cfg)) {
443
- for (const m of text.matchAll(RAW_CHART_LEGEND_ARRAY)) {
444
- const lineNo = text.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
755
+ // Scans `codeText` (comment-stripped) so a legend example inside a comment can't match; reports
756
+ // at the line of the `items={[` token itself, honoring the same allow-comment escape as every
757
+ // per-line kind by checking the ORIGINAL reported line directly.
758
+ if (GUARD_RULES['unframed-chart'].enabled!(cfg) && ruleApplies('unframed-chart', relPath)) {
759
+ for (const m of codeText.matchAll(RAW_CHART_LEGEND_ARRAY)) {
760
+ const lineNo = codeText.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
445
761
  if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
446
762
  findings.push({ relPath, line: lineNo, token: 'items={[', kind: 'unframed-chart' })
447
763
  }
@@ -449,11 +765,14 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
449
765
 
450
766
  // chart-missing-aria-label — full-text tag-scoped scan (same shape as unframed-chart above).
451
767
  // A tag is a violation only when its own (possibly multi-line) prop list has no `ariaLabel=`.
452
- if (GUARD_RULES['chart-missing-aria-label'].enabled!(cfg)) {
453
- for (const m of text.matchAll(CHART_ENTRY_POINT_TAG)) {
768
+ if (
769
+ GUARD_RULES['chart-missing-aria-label'].enabled!(cfg) &&
770
+ ruleApplies('chart-missing-aria-label', relPath)
771
+ ) {
772
+ for (const m of codeText.matchAll(CHART_ENTRY_POINT_TAG)) {
454
773
  const tagText = m[0]
455
774
  if (HAS_ARIA_LABEL_PROP.test(tagText)) continue
456
- const lineNo = text.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
775
+ const lineNo = codeText.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
457
776
  if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
458
777
  findings.push({
459
778
  relPath,
@@ -467,11 +786,11 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
467
786
  // card-with-border — full-text tag-scoped scan (same shape as the two above). Reports at the line
468
787
  // of the `withBorder` token itself (not the end of the tag) so a multi-line-formatted Card points
469
788
  // the fix at the prop to delete.
470
- if (GUARD_RULES['card-with-border'].enabled!(cfg)) {
471
- for (const m of text.matchAll(CARD_SURFACE_TAG)) {
789
+ if (GUARD_RULES['card-with-border'].enabled!(cfg) && ruleApplies('card-with-border', relPath)) {
790
+ for (const m of codeText.matchAll(CARD_SURFACE_TAG)) {
472
791
  const withBorder = WITH_BORDER_PROP.exec(m[0])
473
792
  if (withBorder === null) continue
474
- const lineNo = text.slice(0, (m.index ?? 0) + withBorder.index).split('\n').length
793
+ const lineNo = codeText.slice(0, (m.index ?? 0) + withBorder.index).split('\n').length
475
794
  if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
476
795
  findings.push({ relPath, line: lineNo, token: 'withBorder', kind: 'card-with-border' })
477
796
  }
@@ -481,30 +800,33 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
481
800
  // form-control's own inline `style={{ fontSize: N }}`, (b) a Mantine `styles={{ input: { fontSize:
482
801
  // N } }}` per-part style. Either shape is now DEAD CODE against the `!important` floor in
483
802
  // styles.css — see the guard's doc comment for exactly which shapes this covers.
484
- if (GUARD_RULES['sub-16-input-font'].enabled!(cfg)) {
485
- for (const m of text.matchAll(RAW_FORM_CONTROL_TAG)) {
803
+ if (GUARD_RULES['sub-16-input-font'].enabled!(cfg) && ruleApplies('sub-16-input-font', relPath)) {
804
+ for (const m of codeText.matchAll(RAW_FORM_CONTROL_TAG)) {
486
805
  const tagText = m[0]
487
806
  if (!INLINE_STYLE.test(tagText)) continue
488
807
  const fontSizeMatch = [...tagText.matchAll(SUB_16_FONT_SIZE)][0]
489
808
  if (fontSizeMatch === undefined) continue
490
809
  const value = Number.parseFloat(fontSizeMatch[1] ?? '')
491
810
  if (!Number.isFinite(value) || value >= 16) continue
492
- const lineNo = text.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
811
+ const lineNo = codeText.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
493
812
  if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
494
813
  findings.push({ relPath, line: lineNo, token: fontSizeMatch[0], kind: 'sub-16-input-font' })
495
814
  }
496
815
 
497
- for (const m of text.matchAll(STYLES_INPUT_PART)) {
816
+ for (const m of codeText.matchAll(STYLES_INPUT_PART)) {
498
817
  const inputBody = m[1] ?? ''
499
818
  const fontSizeMatch = [...inputBody.matchAll(SUB_16_FONT_SIZE)][0]
500
819
  if (fontSizeMatch === undefined) continue
501
820
  const value = Number.parseFloat(fontSizeMatch[1] ?? '')
502
821
  if (!Number.isFinite(value) || value >= 16) continue
503
- const lineNo = text.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
822
+ const lineNo = codeText.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
504
823
  if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
505
824
  findings.push({ relPath, line: lineNo, token: fontSizeMatch[0], kind: 'sub-16-input-font' })
506
825
  }
507
826
  }
508
827
 
509
- return findings
828
+ // Per-rule, per-path exemption post-filter (§exemptRules) — applied once here so it uniformly
829
+ // covers every kind regardless of whether it was emitted via the GUARD_RULES registry loop above
830
+ // or one of the inline-handled kinds (raw-surface, raw-html-layout, sub-16-input-font, …).
831
+ return findings.filter((f) => !isRuleExempt(f.kind, f.relPath, cfg.exemptRules))
510
832
  }