@monoes/monomindcli 2.16.1 → 2.16.2

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 (214) hide show
  1. package/.claude/helpers/handlers/edit-handler.cjs +14 -12
  2. package/.claude/helpers/handlers/route-handler.cjs +6 -0
  3. package/.claude/helpers/monograph-freshen.cjs +31 -113
  4. package/.claude/helpers/utils/monograph-resolve.cjs +497 -0
  5. package/.claude/helpers/utils/monograph.cjs +8 -51
  6. package/README.md +1 -1
  7. package/dist/src/commands/doctor-hook-monograph-checks.d.ts +8 -0
  8. package/dist/src/commands/doctor-hook-monograph-checks.d.ts.map +1 -0
  9. package/dist/src/commands/doctor-hook-monograph-checks.js +79 -0
  10. package/dist/src/commands/doctor-hook-monograph-checks.js.map +1 -0
  11. package/dist/src/commands/doctor.d.ts.map +1 -1
  12. package/dist/src/commands/doctor.js +4 -1
  13. package/dist/src/commands/doctor.js.map +1 -1
  14. package/dist/src/commands/monograph.d.ts.map +1 -1
  15. package/dist/src/commands/monograph.js +16 -1
  16. package/dist/src/commands/monograph.js.map +1 -1
  17. package/dist/src/orgrt/bash-timeout.d.ts +14 -0
  18. package/dist/src/orgrt/bash-timeout.d.ts.map +1 -0
  19. package/dist/src/orgrt/bash-timeout.js +18 -0
  20. package/dist/src/orgrt/bash-timeout.js.map +1 -0
  21. package/dist/src/orgrt/block-recheck.d.ts +30 -0
  22. package/dist/src/orgrt/block-recheck.d.ts.map +1 -0
  23. package/dist/src/orgrt/block-recheck.js +81 -0
  24. package/dist/src/orgrt/block-recheck.js.map +1 -0
  25. package/dist/src/orgrt/completion-gate.d.ts +4 -0
  26. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  27. package/dist/src/orgrt/completion-gate.js +22 -2
  28. package/dist/src/orgrt/completion-gate.js.map +1 -1
  29. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  30. package/dist/src/orgrt/daemon.js +6 -4
  31. package/dist/src/orgrt/daemon.js.map +1 -1
  32. package/dist/src/orgrt/decisions.d.ts +1 -1
  33. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  34. package/dist/src/orgrt/decisions.js +14 -6
  35. package/dist/src/orgrt/decisions.js.map +1 -1
  36. package/dist/src/orgrt/mailbox.d.ts +14 -0
  37. package/dist/src/orgrt/mailbox.d.ts.map +1 -1
  38. package/dist/src/orgrt/mailbox.js +31 -1
  39. package/dist/src/orgrt/mailbox.js.map +1 -1
  40. package/dist/src/orgrt/sandbox-fault.d.ts +16 -6
  41. package/dist/src/orgrt/sandbox-fault.d.ts.map +1 -1
  42. package/dist/src/orgrt/sandbox-fault.js +78 -33
  43. package/dist/src/orgrt/sandbox-fault.js.map +1 -1
  44. package/dist/src/orgrt/session.d.ts +4 -3
  45. package/dist/src/orgrt/session.d.ts.map +1 -1
  46. package/dist/src/orgrt/session.js +24 -13
  47. package/dist/src/orgrt/session.js.map +1 -1
  48. package/dist/src/orgrt/task-dag.d.ts +8 -2
  49. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  50. package/dist/src/orgrt/task-dag.js +10 -4
  51. package/dist/src/orgrt/task-dag.js.map +1 -1
  52. package/dist/src/orgrt/types.d.ts +11 -0
  53. package/dist/src/orgrt/types.d.ts.map +1 -1
  54. package/dist/src/orgrt/types.js +18 -0
  55. package/dist/src/orgrt/types.js.map +1 -1
  56. package/dist/src/utils/resource-governor.d.ts.map +1 -1
  57. package/dist/src/utils/resource-governor.js +35 -2
  58. package/dist/src/utils/resource-governor.js.map +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +6 -6
  61. package/.claude/skills/monodesign/SKILL.md +0 -257
  62. package/.claude/skills/monodesign/adapt.md +0 -53
  63. package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +0 -100
  64. package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +0 -103
  65. package/.claude/skills/monodesign/animate.md +0 -65
  66. package/.claude/skills/monodesign/audit.md +0 -89
  67. package/.claude/skills/monodesign/bolder.md +0 -50
  68. package/.claude/skills/monodesign/clarify.md +0 -64
  69. package/.claude/skills/monodesign/colorize.md +0 -68
  70. package/.claude/skills/monodesign/craft.md +0 -51
  71. package/.claude/skills/monodesign/critique.md +0 -66
  72. package/.claude/skills/monodesign/delight.md +0 -47
  73. package/.claude/skills/monodesign/distill.md +0 -56
  74. package/.claude/skills/monodesign/document.md +0 -83
  75. package/.claude/skills/monodesign/extract.md +0 -74
  76. package/.claude/skills/monodesign/harden.md +0 -65
  77. package/.claude/skills/monodesign/init.md +0 -30
  78. package/.claude/skills/monodesign/layout.md +0 -36
  79. package/.claude/skills/monodesign/live.md +0 -34
  80. package/.claude/skills/monodesign/onboard.md +0 -50
  81. package/.claude/skills/monodesign/optimize.md +0 -64
  82. package/.claude/skills/monodesign/overdrive.md +0 -56
  83. package/.claude/skills/monodesign/polish.md +0 -68
  84. package/.claude/skills/monodesign/quieter.md +0 -57
  85. package/.claude/skills/monodesign/reference/adapt.md +0 -312
  86. package/.claude/skills/monodesign/reference/adapt.native.md +0 -58
  87. package/.claude/skills/monodesign/reference/android.md +0 -40
  88. package/.claude/skills/monodesign/reference/animate.md +0 -203
  89. package/.claude/skills/monodesign/reference/antipatterns-catalog.md +0 -410
  90. package/.claude/skills/monodesign/reference/audit.md +0 -135
  91. package/.claude/skills/monodesign/reference/audit.native.md +0 -139
  92. package/.claude/skills/monodesign/reference/bolder.md +0 -120
  93. package/.claude/skills/monodesign/reference/brand-workflow.md +0 -180
  94. package/.claude/skills/monodesign/reference/brand.md +0 -108
  95. package/.claude/skills/monodesign/reference/clarify.md +0 -288
  96. package/.claude/skills/monodesign/reference/codex.md +0 -105
  97. package/.claude/skills/monodesign/reference/cognitive-load.md +0 -106
  98. package/.claude/skills/monodesign/reference/color-and-contrast.md +0 -105
  99. package/.claude/skills/monodesign/reference/colorize.md +0 -257
  100. package/.claude/skills/monodesign/reference/component-specs.md +0 -260
  101. package/.claude/skills/monodesign/reference/component-states.md +0 -274
  102. package/.claude/skills/monodesign/reference/component-system.md +0 -358
  103. package/.claude/skills/monodesign/reference/copy-formulas.md +0 -160
  104. package/.claude/skills/monodesign/reference/craft.md +0 -123
  105. package/.claude/skills/monodesign/reference/critique.md +0 -780
  106. package/.claude/skills/monodesign/reference/delight.md +0 -302
  107. package/.claude/skills/monodesign/reference/design-principles.md +0 -246
  108. package/.claude/skills/monodesign/reference/distill.md +0 -111
  109. package/.claude/skills/monodesign/reference/document.md +0 -429
  110. package/.claude/skills/monodesign/reference/extract.md +0 -69
  111. package/.claude/skills/monodesign/reference/harden.md +0 -347
  112. package/.claude/skills/monodesign/reference/heuristics-scoring.md +0 -234
  113. package/.claude/skills/monodesign/reference/hooks.md +0 -92
  114. package/.claude/skills/monodesign/reference/image-prompts.md +0 -130
  115. package/.claude/skills/monodesign/reference/init.md +0 -221
  116. package/.claude/skills/monodesign/reference/interaction-design.md +0 -189
  117. package/.claude/skills/monodesign/reference/ios.md +0 -45
  118. package/.claude/skills/monodesign/reference/layout.md +0 -185
  119. package/.claude/skills/monodesign/reference/live.md +0 -710
  120. package/.claude/skills/monodesign/reference/motion-design.md +0 -109
  121. package/.claude/skills/monodesign/reference/onboard.md +0 -234
  122. package/.claude/skills/monodesign/reference/optimize.md +0 -258
  123. package/.claude/skills/monodesign/reference/overdrive.md +0 -130
  124. package/.claude/skills/monodesign/reference/personas.md +0 -179
  125. package/.claude/skills/monodesign/reference/polish.md +0 -241
  126. package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +0 -108
  127. package/.claude/skills/monodesign/reference/product.md +0 -60
  128. package/.claude/skills/monodesign/reference/quieter.md +0 -99
  129. package/.claude/skills/monodesign/reference/responsive-design.md +0 -114
  130. package/.claude/skills/monodesign/reference/shape.md +0 -165
  131. package/.claude/skills/monodesign/reference/spatial-design.md +0 -100
  132. package/.claude/skills/monodesign/reference/teach.md +0 -10
  133. package/.claude/skills/monodesign/reference/token-architecture.md +0 -222
  134. package/.claude/skills/monodesign/reference/typeset.md +0 -301
  135. package/.claude/skills/monodesign/reference/typography.md +0 -159
  136. package/.claude/skills/monodesign/reference/ux-research.md +0 -143
  137. package/.claude/skills/monodesign/reference/ux-rules.md +0 -211
  138. package/.claude/skills/monodesign/reference/ux-writing.md +0 -107
  139. package/.claude/skills/monodesign/scripts/command-metadata.json +0 -94
  140. package/.claude/skills/monodesign/scripts/context-signals.mjs +0 -260
  141. package/.claude/skills/monodesign/scripts/context.mjs +0 -1065
  142. package/.claude/skills/monodesign/scripts/critique-storage.mjs +0 -416
  143. package/.claude/skills/monodesign/scripts/detect-csp.mjs +0 -193
  144. package/.claude/skills/monodesign/scripts/detect.mjs +0 -33
  145. package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +0 -1960
  146. package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +0 -321
  147. package/.claude/skills/monodesign/scripts/detector/design-system.mjs +0 -814
  148. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +0 -5628
  149. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +0 -50
  150. package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +0 -259
  151. package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +0 -339
  152. package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +0 -636
  153. package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +0 -1016
  154. package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +0 -253
  155. package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -198
  156. package/.claude/skills/monodesign/scripts/detector/findings.mjs +0 -12
  157. package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +0 -181
  158. package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +0 -373
  159. package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +0 -426
  160. package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +0 -198
  161. package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +0 -166
  162. package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +0 -563
  163. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +0 -3024
  164. package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +0 -124
  165. package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +0 -101
  166. package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +0 -30
  167. package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +0 -148
  168. package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +0 -7
  169. package/.claude/skills/monodesign/scripts/hook-admin.mjs +0 -694
  170. package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +0 -516
  171. package/.claude/skills/monodesign/scripts/hook-lib.mjs +0 -1785
  172. package/.claude/skills/monodesign/scripts/hook.mjs +0 -61
  173. package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +0 -809
  174. package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +0 -69
  175. package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +0 -640
  176. package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +0 -129
  177. package/.claude/skills/monodesign/scripts/lib/provider.mjs +0 -4
  178. package/.claude/skills/monodesign/scripts/lib/target-args.mjs +0 -42
  179. package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +0 -50
  180. package/.claude/skills/monodesign/scripts/live/completion.mjs +0 -19
  181. package/.claude/skills/monodesign/scripts/live/event-validation.mjs +0 -137
  182. package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +0 -458
  183. package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +0 -939
  184. package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +0 -357
  185. package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +0 -152
  186. package/.claude/skills/monodesign/scripts/live/session-store.mjs +0 -293
  187. package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +0 -826
  188. package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +0 -279
  189. package/.claude/skills/monodesign/scripts/live/ui-core.mjs +0 -180
  190. package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +0 -36
  191. package/.claude/skills/monodesign/scripts/live-accept.mjs +0 -812
  192. package/.claude/skills/monodesign/scripts/live-browser-dom.js +0 -147
  193. package/.claude/skills/monodesign/scripts/live-browser-session.js +0 -124
  194. package/.claude/skills/monodesign/scripts/live-browser.js +0 -11213
  195. package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +0 -1241
  196. package/.claude/skills/monodesign/scripts/live-complete.mjs +0 -75
  197. package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +0 -683
  198. package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +0 -51
  199. package/.claude/skills/monodesign/scripts/live-inject.mjs +0 -596
  200. package/.claude/skills/monodesign/scripts/live-insert.mjs +0 -272
  201. package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +0 -363
  202. package/.claude/skills/monodesign/scripts/live-poll.mjs +0 -384
  203. package/.claude/skills/monodesign/scripts/live-resume.mjs +0 -94
  204. package/.claude/skills/monodesign/scripts/live-server.mjs +0 -1210
  205. package/.claude/skills/monodesign/scripts/live-status.mjs +0 -61
  206. package/.claude/skills/monodesign/scripts/live-target.mjs +0 -30
  207. package/.claude/skills/monodesign/scripts/live-wrap.mjs +0 -884
  208. package/.claude/skills/monodesign/scripts/live.mjs +0 -297
  209. package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +0 -14
  210. package/.claude/skills/monodesign/scripts/palette.mjs +0 -635
  211. package/.claude/skills/monodesign/scripts/pin.mjs +0 -221
  212. package/.claude/skills/monodesign/shape.md +0 -71
  213. package/.claude/skills/monodesign/teach.md +0 -18
  214. package/.claude/skills/monodesign/typeset.md +0 -59
@@ -1,636 +0,0 @@
1
- import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
2
- import { isNeutralColor } from '../../shared/color.mjs';
3
- import { extractGoogleFontFamilies } from '../../shared/fonts.mjs';
4
- import { checkSourceDesignSystem } from '../../design-system.mjs';
5
- import { isFullPage } from '../../shared/page.mjs';
6
- import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
7
- import { finding } from '../../findings.mjs';
8
- import { filterByProviders } from '../../registry/antipatterns.mjs';
9
- import { profileFindings, profileStep } from '../../profile/profiler.mjs';
10
- import {
11
- checkFocusVisible,
12
- checkHoverOnlyAffordance,
13
- checkDarkSchemeContrast,
14
- } from '../../rules/checks.mjs';
15
-
16
- // ---------------------------------------------------------------------------
17
- // Regex fallback (non-HTML files: CSS, JSX, TSX, etc.)
18
- // ---------------------------------------------------------------------------
19
-
20
- const hasRounded = (line) => /\brounded(?:-\w+)?\b/.test(line);
21
- const hasBorderRadius = (line) => /border-radius/i.test(line);
22
- const isSafeElement = (line) => /<(?:blockquote|nav[\s>]|pre[\s>]|code[\s>]|a\s|input[\s>]|span[\s>])/i.test(line);
23
-
24
- /** Strip HTML to plain text — drops script/style/comments/tags so
25
- * content-text analyzers don't false-positive on code or CSS. */
26
- function stripHtmlToText(html) {
27
- return html
28
- .replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, ' ')
29
- .replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, ' ')
30
- .replace(/<!--[\s\S]*?-->/g, ' ')
31
- .replace(/<[^>]+>/g, ' ')
32
- .replace(/\s+/g, ' ');
33
- }
34
-
35
- const PAGE_ANALYZER_EXTS = new Set(['.html', '.htm', '.astro', '.vue', '.svelte']);
36
-
37
- function extFromFilePath(filePath) {
38
- return filePath ? (filePath.match(/\.\w+$/)?.[0] || '').toLowerCase() : '';
39
- }
40
-
41
- function shouldRunPageAnalyzers(content, filePath) {
42
- if (!isFullPage(content)) return false;
43
- const ext = extFromFilePath(filePath);
44
- return !ext || PAGE_ANALYZER_EXTS.has(ext);
45
- }
46
-
47
- function firstOverusedGoogleFont(text) {
48
- return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
49
- }
50
-
51
- function isNeutralBorderColor(str) {
52
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
53
- if (!m) return false;
54
- const c = m[1].toLowerCase();
55
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
56
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
57
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
58
- if (hex) {
59
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
60
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
61
- }
62
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
63
- if (shex) {
64
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
65
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
66
- }
67
- return false;
68
- }
69
-
70
- const REGEX_MATCHERS = [
71
- // --- Side-tab ---
72
- { id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
73
- test: (m, line) => { const n = +m[1]; return hasRounded(line) ? n >= 2 : n >= 4; },
74
- fmt: (m) => m[0] },
75
- { id: 'side-tab', regex: /border-(?:left|right)\s*:\s*(\d+)px\s+solid[^;]*/gi,
76
- test: (m, line) => { if (isSafeElement(line)) return false; if (isNeutralBorderColor(m[0])) return false; const n = +m[1]; return hasBorderRadius(line) ? n >= 2 : n >= 3; },
77
- fmt: (m) => m[0].replace(/\s*;?\s*$/, '') },
78
- { id: 'side-tab', regex: /border-(?:left|right)-width\s*:\s*(\d+)px/gi,
79
- test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
80
- fmt: (m) => m[0] },
81
- { id: 'side-tab', regex: /border-inline-(?:start|end)\s*:\s*(\d+)px\s+solid/gi,
82
- test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
83
- fmt: (m) => m[0] },
84
- { id: 'side-tab', regex: /border-inline-(?:start|end)-width\s*:\s*(\d+)px/gi,
85
- test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
86
- fmt: (m) => m[0] },
87
- { id: 'side-tab', regex: /border(?:Left|Right)\s*[:=]\s*["'`](\d+)px\s+solid/g,
88
- test: (m) => +m[1] >= 3,
89
- fmt: (m) => m[0] },
90
- // --- Border accent on rounded ---
91
- { id: 'border-accent-on-rounded', regex: /\bborder-[tb]-(\d+)\b/g,
92
- test: (m, line) => hasRounded(line) && +m[1] >= 1,
93
- fmt: (m) => m[0] },
94
- { id: 'border-accent-on-rounded', regex: /border-(?:top|bottom)\s*:\s*(\d+)px\s+solid/gi,
95
- test: (m, line) => +m[1] >= 3 && hasBorderRadius(line),
96
- fmt: (m) => m[0] },
97
- // --- Overused font ---
98
- { id: 'overused-font', regex: /font-family\s*:\s*['"]?(Inter|Roboto|Open Sans|Lato|Montserrat|Arial|Helvetica|Fraunces|Geist Sans|Geist Mono|Geist|Mona Sans|Plus Jakarta Sans|Space Grotesk|Recoleta|Instrument Sans|Instrument Serif)\b/gi,
99
- test: () => true,
100
- fmt: (m) => m[0] },
101
- { id: 'overused-font', regex: /fonts\.googleapis\.com\/css2?\?[^"'\s)<>]*/gi,
102
- test: (m) => {
103
- m.overusedGoogleFont = firstOverusedGoogleFont(m[0]);
104
- return Boolean(m.overusedGoogleFont);
105
- },
106
- fmt: (m) => `Google Fonts: ${m.overusedGoogleFont || firstOverusedGoogleFont(m[0])}` },
107
- // --- Gradient text ---
108
- { id: 'gradient-text', regex: /background-clip\s*:\s*text|-webkit-background-clip\s*:\s*text/gi,
109
- test: (_m, line) => /gradient/i.test(line),
110
- fmt: () => 'background-clip: text + gradient' },
111
- // --- Gradient text (Tailwind) ---
112
- { id: 'gradient-text', regex: /\bbg-clip-text\b/g,
113
- test: (_m, line) => /\bbg-gradient-to-/i.test(line),
114
- fmt: () => 'bg-clip-text + bg-gradient' },
115
- // --- Tailwind gray on colored bg ---
116
- { id: 'gray-on-color', regex: /\btext-(?:gray|slate|zinc|neutral|stone)-(\d+)\b/g,
117
- test: (_m, line) => /\bbg-(?:red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d+\b/.test(line),
118
- fmt: (m, line) => { const bg = line.match(/\bbg-(?:red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d+\b/); return `${m[0]} on ${bg?.[0] || '?'}`; } },
119
- // --- Tailwind AI palette ---
120
- { id: 'ai-color-palette', regex: /\btext-(?:purple|violet|indigo)-(\d+)\b/g,
121
- test: (_m, line) => /\btext-(?:[2-9]xl|[3-9]xl)\b|<h[1-3]/i.test(line),
122
- fmt: (m) => `${m[0]} on heading` },
123
- { id: 'ai-color-palette', regex: /\bfrom-(?:purple|violet|indigo)-(\d+)\b/g,
124
- test: (_m, line) => /\bto-(?:purple|violet|indigo|blue|cyan|pink|fuchsia)-\d+\b/.test(line),
125
- fmt: (m) => `${m[0]} gradient` },
126
- // --- Bounce/elastic easing ---
127
- { id: 'bounce-easing', regex: /\banimate-bounce\b/g,
128
- test: () => true,
129
- fmt: () => 'animate-bounce (Tailwind)' },
130
- { id: 'bounce-easing', regex: /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi,
131
- test: () => true,
132
- fmt: (m) => {
133
- const token = m[1]
134
- .split(/[,\s]+/)
135
- .find((part) => /bounce|elastic|wobble|jiggle|spring/i.test(part));
136
- return `animation: ${token || m[1].trim()}`;
137
- } },
138
- { id: 'bounce-easing', regex: /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g,
139
- test: (m) => {
140
- const y1 = parseFloat(m[2]), y2 = parseFloat(m[4]);
141
- return y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1;
142
- },
143
- fmt: (m) => `cubic-bezier(${m[1]}, ${m[2]}, ${m[3]}, ${m[4]})` },
144
- // --- Layout property transition ---
145
- { id: 'layout-transition', regex: /transition\s*:\s*([^;{}]+)/gi,
146
- test: (m) => {
147
- const val = m[1].toLowerCase();
148
- if (/\ball\b/.test(val)) return false;
149
- return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
150
- },
151
- fmt: (m) => {
152
- const found = m[1].match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
153
- return `transition: ${found ? found.join(', ') : m[1].trim()}`;
154
- } },
155
- { id: 'layout-transition', regex: /transition-property\s*:\s*([^;{}]+)/gi,
156
- test: (m) => {
157
- const val = m[1].toLowerCase();
158
- if (/\ball\b/.test(val)) return false;
159
- return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
160
- },
161
- fmt: (m) => {
162
- const found = m[1].match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
163
- return `transition-property: ${found ? found.join(', ') : m[1].trim()}`;
164
- } },
165
- // --- Broken image: src="" or src="#" or src=" " ---
166
- { id: 'broken-image', regex: /<img\b[^>]*?\bsrc\s*=\s*(?:""|''|"\s+"|'\s+'|"#"|'#')/gi,
167
- test: () => true,
168
- fmt: (m) => m[0].slice(0, 100) },
169
- // --- Broken image: <img> with no src attribute at all ---
170
- { id: 'broken-image', regex: /<img\b(?:(?!\bsrc\s*=)[^>])*>/gi,
171
- test: (m) => !/\bsrc\s*=/i.test(m[0]),
172
- fmt: (m) => m[0].slice(0, 100) },
173
- // --- Image missing dimensions (CLS): <img> without width+height and
174
- // without a CSS aspect-ratio or explicit height. Covers HTML (width="…")
175
- // and JSX (width={…}) attribute forms. ---
176
- { id: 'image-missing-dimensions', regex: /<img\b[^>]*>/gi,
177
- test: (m) => {
178
- const tag = m[0];
179
- const hasHeight = /(?:^|[\s{;"'])height\s*[=:]/i.test(tag);
180
- const hasAspect = /aspect-?ratio/i.test(tag);
181
- return !hasHeight && !hasAspect;
182
- },
183
- fmt: (m) => m[0].slice(0, 100) },
184
- ];
185
-
186
- const REGEX_ANALYZERS = [
187
- // Single font
188
- (content, filePath) => {
189
- const fontFamilyRe = /font-family\s*:\s*([^;}]+)/gi;
190
- const fonts = new Set();
191
- let m;
192
- while ((m = fontFamilyRe.exec(content)) !== null) {
193
- for (const f of m[1].split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())) {
194
- if (f && !GENERIC_FONTS.has(f)) fonts.add(f);
195
- }
196
- }
197
- for (const f of extractGoogleFontFamilies(content)) fonts.add(f);
198
- if (fonts.size !== 1 || content.split('\n').length < 20) return [];
199
- const name = [...fonts][0];
200
- const lines = content.split('\n');
201
- let line = 1;
202
- for (let i = 0; i < lines.length; i++) { if (lines[i].toLowerCase().includes(name)) { line = i + 1; break; } }
203
- return [finding('single-font', filePath, `only font used is ${name}`, line)];
204
- },
205
- // Flat type hierarchy
206
- (content, filePath) => {
207
- const sizes = new Set();
208
- const REM = 16;
209
- let m;
210
- const sizeRe = /font-size\s*:\s*([\d.]+)(px|rem|em)\b/gi;
211
- while ((m = sizeRe.exec(content)) !== null) {
212
- const px = m[2] === 'px' ? +m[1] : +m[1] * REM;
213
- if (px > 0 && px < 200) sizes.add(Math.round(px * 10) / 10);
214
- }
215
- const clampRe = /font-size\s*:\s*clamp\(\s*([\d.]+)(px|rem|em)\s*,\s*[^,]+,\s*([\d.]+)(px|rem|em)\s*\)/gi;
216
- while ((m = clampRe.exec(content)) !== null) {
217
- sizes.add(Math.round((m[2] === 'px' ? +m[1] : +m[1] * REM) * 10) / 10);
218
- sizes.add(Math.round((m[4] === 'px' ? +m[3] : +m[3] * REM) * 10) / 10);
219
- }
220
- const TW = { 'text-xs': 12, 'text-sm': 14, 'text-base': 16, 'text-lg': 18, 'text-xl': 20, 'text-2xl': 24, 'text-3xl': 30, 'text-4xl': 36, 'text-5xl': 48, 'text-6xl': 60, 'text-7xl': 72, 'text-8xl': 96, 'text-9xl': 128 };
221
- for (const [cls, px] of Object.entries(TW)) { if (new RegExp(`\\b${cls}\\b`).test(content)) sizes.add(px); }
222
- if (sizes.size < 3) return [];
223
- const sorted = [...sizes].sort((a, b) => a - b);
224
- const ratio = sorted[sorted.length - 1] / sorted[0];
225
- if (ratio >= 2.0) return [];
226
- const lines = content.split('\n');
227
- let line = 1;
228
- for (let i = 0; i < lines.length; i++) { if (/font-size/i.test(lines[i]) || /\btext-(?:xs|sm|base|lg|xl|\d)/i.test(lines[i])) { line = i + 1; break; } }
229
- return [finding('flat-type-hierarchy', filePath, `Sizes: ${sorted.map(s => `${s}px`).join(', ')} (ratio ${ratio.toFixed(1)}:1)`, line)];
230
- },
231
- // Monotonous spacing (regex)
232
- (content, filePath) => {
233
- const vals = [];
234
- let m;
235
- const pxRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
236
- while ((m = pxRe.exec(content)) !== null) { const v = +m[1]; if (v > 0 && v < 200) vals.push(v); }
237
- const remRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
238
- while ((m = remRe.exec(content)) !== null) { const v = Math.round(parseFloat(m[1]) * 16); if (v > 0 && v < 200) vals.push(v); }
239
- const gapRe = /gap\s*:\s*(\d+)px/gi;
240
- while ((m = gapRe.exec(content)) !== null) vals.push(+m[1]);
241
- const twRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
242
- while ((m = twRe.exec(content)) !== null) vals.push(+m[1] * 4);
243
- const rounded = vals.map(v => Math.round(v / 4) * 4);
244
- if (rounded.length < 10) return [];
245
- const counts = {};
246
- for (const v of rounded) counts[v] = (counts[v] || 0) + 1;
247
- const maxCount = Math.max(...Object.values(counts));
248
- const pct = maxCount / rounded.length;
249
- const unique = [...new Set(rounded)].filter(v => v > 0);
250
- if (pct <= 0.6 || unique.length > 3) return [];
251
- const dominant = Object.entries(counts).sort((a, b) => b[1] - a[1])[0][0];
252
- return [finding('monotonous-spacing', filePath, `~${dominant}px used ${maxCount}/${rounded.length} times (${Math.round(pct * 100)}%)`)];
253
- },
254
- // Em-dash overuse: 5+ em-dashes or "--" in body text content
255
- // (occasional em-dash use in prose is fine; the pattern fires only
256
- // when count crosses into AI-cadence territory).
257
- (content, filePath) => {
258
- const text = stripHtmlToText(content);
259
- let count = 0;
260
- const re = /[—]|--(?=\S)/g;
261
- while (re.exec(text) !== null) count++;
262
- if (count < 5) return [];
263
- return [finding('em-dash-overuse', filePath, `${count} em-dashes in body text`)];
264
- },
265
- // Marketing buzzwords: SaaS phrase list
266
- (content, filePath) => {
267
- const text = stripHtmlToText(content);
268
- const lower = text.toLowerCase();
269
- const BUZZWORDS = [
270
- 'streamline your', 'empower your', 'supercharge your',
271
- 'unleash your', 'unleash the power', 'leverage the power',
272
- 'built for the modern', 'trusted by leading', 'trusted by the world',
273
- 'best-in-class', 'industry-leading', 'world-class', 'enterprise-grade',
274
- 'next-generation', 'cutting-edge', 'transform your business',
275
- 'revolutionize', 'game-changer', 'game changing',
276
- 'mission-critical', 'best of breed', 'future-proof', 'future proof',
277
- 'seamless experience', 'seamlessly integrate',
278
- 'drive engagement', 'drive growth', 'drive results',
279
- 'harness the power',
280
- ];
281
- let count = 0;
282
- let firstSample = '';
283
- for (const phrase of BUZZWORDS) {
284
- let from = 0;
285
- while (true) {
286
- const idx = lower.indexOf(phrase, from);
287
- if (idx === -1) break;
288
- count++;
289
- if (!firstSample) {
290
- firstSample = text.slice(Math.max(0, idx - 12), Math.min(text.length, idx + phrase.length + 12)).trim();
291
- }
292
- from = idx + phrase.length;
293
- }
294
- }
295
- if (count === 0) return [];
296
- return [finding('marketing-buzzword', filePath, `${count} buzzword phrase${count === 1 ? '' : 's'}: "${firstSample}"`)];
297
- },
298
- // Numbered section markers (01 / 02 / 03 ...)
299
- (content, filePath) => {
300
- const text = stripHtmlToText(content);
301
- const re = /\b(0[1-9]|1[0-2])\b/g;
302
- const seen = new Set();
303
- let m;
304
- while ((m = re.exec(text)) !== null) seen.add(m[1]);
305
- if (seen.size < 3) return [];
306
- const sorted = [...seen].sort();
307
- let sequential = 0;
308
- for (let i = 1; i < sorted.length; i++) {
309
- if (parseInt(sorted[i], 10) === parseInt(sorted[i - 1], 10) + 1) sequential++;
310
- }
311
- if (sequential < 2) return [];
312
- return [finding('numbered-section-markers', filePath, `Sequence: ${sorted.slice(0, 6).join(', ')}`)];
313
- },
314
- // Aphoristic cadence: manufactured-contrast + short-rebuttal
315
- (content, filePath) => {
316
- const text = stripHtmlToText(content);
317
- const NOT_A_RE = /\bNot an? [a-z][^.!?]{1,40}[.!]\s+[A-Z][^.!?]{1,60}[.!]/g;
318
- const SHORT_REBUTTAL_RE = /\b[A-Z][^.!?]{4,80}[.!]\s+(No|Just)\s+[a-z][^.!?]{2,60}[.!]/g;
319
- let count = 0;
320
- let firstSample = '';
321
- let m;
322
- NOT_A_RE.lastIndex = 0;
323
- while ((m = NOT_A_RE.exec(text)) !== null) {
324
- count++;
325
- if (!firstSample) firstSample = m[0].trim().slice(0, 80);
326
- }
327
- SHORT_REBUTTAL_RE.lastIndex = 0;
328
- while ((m = SHORT_REBUTTAL_RE.exec(text)) !== null) {
329
- count++;
330
- if (!firstSample) firstSample = m[0].trim().slice(0, 80);
331
- }
332
- if (count < 3) return [];
333
- return [finding('aphoristic-cadence', filePath, `${count} aphoristic constructions: "${firstSample}"`)];
334
- },
335
- // Dark glow (page-level: dark bg + colored box-shadow with blur)
336
- (content, filePath) => {
337
- // Check if page has a dark background
338
- const darkBgRe = /background(?:-color)?\s*:\s*(?:#(?:0[0-9a-f]|1[0-9a-f]|2[0-3])[0-9a-f]{4}\b|#(?:0|1)[0-9a-f]{2}\b|rgb\(\s*(\d{1,2})\s*,\s*(\d{1,2})\s*,\s*(\d{1,2})\s*\))/gi;
339
- const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
340
- const hasDarkBg = darkBgRe.test(content) || twDarkBg.test(content);
341
- if (!hasDarkBg) return [];
342
-
343
- // Check for colored box-shadow with blur > 4px
344
- const shadowRe = /box-shadow\s*:\s*([^;{}]+)/gi;
345
- let m;
346
- while ((m = shadowRe.exec(content)) !== null) {
347
- const val = m[1];
348
- const colorMatch = val.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
349
- if (!colorMatch) continue;
350
- const [r, g, b] = [+colorMatch[1], +colorMatch[2], +colorMatch[3]];
351
- if ((Math.max(r, g, b) - Math.min(r, g, b)) < 30) continue; // skip gray
352
- // Check blur: look for pattern like "0 0 20px" (third number > 4)
353
- const pxVals = [...val.matchAll(/(\d+)px|(?<![.\d])\b(0)\b(?![.\d])/g)].map(p => +(p[1] || p[2]));
354
- if (pxVals.length >= 3 && pxVals[2] > 4) {
355
- const lines = content.substring(0, m.index).split('\n');
356
- return [finding('dark-glow', filePath, `Colored glow (rgb(${r},${g},${b})) on dark page`, lines.length)];
357
- }
358
- }
359
- return [];
360
- },
361
- ];
362
-
363
- // ---------------------------------------------------------------------------
364
- // Style block extraction (Vue/Svelte <style> blocks)
365
- // ---------------------------------------------------------------------------
366
-
367
- function extractStyleBlocks(content, ext) {
368
- ext = ext.toLowerCase();
369
- if (ext !== '.vue' && ext !== '.svelte') return [];
370
- const blocks = [];
371
- const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
372
- let m;
373
- while ((m = re.exec(content)) !== null) {
374
- const before = content.substring(0, m.index);
375
- const startLine = before.split('\n').length + 1;
376
- blocks.push({ content: m[1], startLine });
377
- }
378
- return blocks;
379
- }
380
-
381
- // ---------------------------------------------------------------------------
382
- // CSS-in-JS extraction (styled-components, emotion)
383
- // ---------------------------------------------------------------------------
384
-
385
- const CSS_IN_JS_EXTENSIONS = new Set(['.js', '.ts', '.jsx', '.tsx']);
386
-
387
- function extractCSSinJS(content, ext) {
388
- ext = ext.toLowerCase();
389
- if (!CSS_IN_JS_EXTENSIONS.has(ext)) return [];
390
- const blocks = [];
391
- const re = /(?:styled(?:\.\w+|\([^)]+\))|css)\s*`([\s\S]*?)`/g;
392
- let m;
393
- while ((m = re.exec(content)) !== null) {
394
- const before = content.substring(0, m.index);
395
- const startLine = before.split('\n').length;
396
- blocks.push({ content: m[1], startLine });
397
- }
398
- return blocks;
399
- }
400
-
401
- function runRegexMatchers(lines, filePath, lineOffset = 0, blockContext = null, options = {}) {
402
- const { profile, phase = 'regex-matchers' } = options || {};
403
- const findings = [];
404
- if (!profile) {
405
- for (const matcher of REGEX_MATCHERS) {
406
- for (let i = 0; i < lines.length; i++) {
407
- const line = lines[i];
408
- matcher.regex.lastIndex = 0;
409
- let m;
410
- while ((m = matcher.regex.exec(line)) !== null) {
411
- // For extracted blocks, use nearby lines as context for multi-line CSS patterns
412
- const context = blockContext
413
- ? lines.slice(Math.max(0, i - 3), Math.min(lines.length, i + 4)).join(' ')
414
- : line;
415
- if (matcher.test(m, context)) {
416
- findings.push(finding(matcher.id, filePath, matcher.fmt(m, context), i + 1 + lineOffset));
417
- }
418
- }
419
- }
420
- }
421
- return findings;
422
- }
423
-
424
- for (const matcher of REGEX_MATCHERS) {
425
- const matcherFindings = profileFindings(profile, {
426
- engine: 'regex',
427
- phase,
428
- ruleId: matcher.id,
429
- target: filePath,
430
- }, () => {
431
- const matches = [];
432
- for (let i = 0; i < lines.length; i++) {
433
- const line = lines[i];
434
- matcher.regex.lastIndex = 0;
435
- let m;
436
- while ((m = matcher.regex.exec(line)) !== null) {
437
- // For extracted blocks, use nearby lines as context for multi-line CSS patterns
438
- const context = blockContext
439
- ? lines.slice(Math.max(0, i - 3), Math.min(lines.length, i + 4)).join(' ')
440
- : line;
441
- if (matcher.test(m, context)) {
442
- matches.push(finding(matcher.id, filePath, matcher.fmt(m, context), i + 1 + lineOffset));
443
- }
444
- }
445
- }
446
- return matches;
447
- });
448
- findings.push(...matcherFindings);
449
- }
450
- return findings;
451
- }
452
-
453
- /** Page-level analyzers that scan rendered text content (em-dash use,
454
- * buzzword phrases, numbered section markers, aphoristic cadence).
455
- * These are detector-agnostic — they work on any HTML/text source
456
- * and don't need a parsed DOM. Exported so detectHtml can call them
457
- * for `.html` files (which otherwise skip the regex engine). */
458
- const TEXT_CONTENT_ANALYZER_IDS = [
459
- 'em-dash-overuse',
460
- 'marketing-buzzword',
461
- 'numbered-section-markers',
462
- 'aphoristic-cadence',
463
- ];
464
-
465
- function runTextContentAnalyzers(content, filePath, options = {}) {
466
- const profile = options?.profile;
467
- if (!shouldRunPageAnalyzers(content, filePath)) return [];
468
- // The 4 text-content analyzers are at indices 3-6 in REGEX_ANALYZERS.
469
- const findings = [];
470
- for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
471
- const analyzer = REGEX_ANALYZERS[3 + i];
472
- const ruleId = TEXT_CONTENT_ANALYZER_IDS[i];
473
- findings.push(...profileFindings(profile, {
474
- engine: 'regex',
475
- phase: 'text-content',
476
- ruleId,
477
- target: filePath,
478
- }, () => analyzer(content, filePath)));
479
- }
480
- return findings;
481
- }
482
-
483
- // Extract raw CSS text from a source file for the stylesheet-level analyzers
484
- // (focus-visible, hover-only, dark-scheme). CSS-like files are CSS wholesale;
485
- // everything else contributes only its <style> block contents so tag markup
486
- // and inline styles don't confuse the flat CSS parser.
487
- const CSS_LIKE_EXTS = new Set(['.css', '.scss', '.sass', '.less']);
488
- function extractStylesheetText(content, ext) {
489
- if (CSS_LIKE_EXTS.has(ext)) return content;
490
- const blocks = [];
491
- const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
492
- let m;
493
- while ((m = re.exec(content)) !== null) blocks.push(m[1]);
494
- return blocks.join('\n');
495
- }
496
-
497
- const STYLESHEET_ANALYZERS = [
498
- { id: 'missing-focus-visible', run: checkFocusVisible },
499
- { id: 'hover-only-affordance', run: checkHoverOnlyAffordance },
500
- { id: 'dark-scheme-contrast-blindspot', run: checkDarkSchemeContrast },
501
- ];
502
-
503
- // Run the stylesheet-level analyzers over a source file's CSS. Applies to
504
- // CSS-like sources and to full HTML pages (which carry <style> blocks).
505
- function runStylesheetAnalyzers(content, filePath, options = {}) {
506
- const profile = options?.profile;
507
- const ext = extFromFilePath(filePath);
508
- const isCssLike = CSS_LIKE_EXTS.has(ext);
509
- if (!isCssLike && !isFullPage(content)) return [];
510
- const cssText = extractStylesheetText(content, ext);
511
- if (!cssText.trim()) return [];
512
- const findings = [];
513
- for (const analyzer of STYLESHEET_ANALYZERS) {
514
- const hits = profileFindings(profile, {
515
- engine: 'regex',
516
- phase: 'stylesheet',
517
- ruleId: analyzer.id,
518
- target: filePath,
519
- }, () => analyzer.run(cssText));
520
- for (const h of hits) findings.push(finding(h.id, filePath, h.snippet));
521
- }
522
- return findings;
523
- }
524
-
525
- function detectText(content, filePath, options = {}) {
526
- const profile = options?.profile;
527
- const findings = [];
528
- const lines = content.split('\n');
529
- const ext = extFromFilePath(filePath);
530
-
531
- // Run regex matchers on the full file content (catches Tailwind classes, inline styles)
532
- // Enable block context for CSS files where related properties span multiple lines
533
- const cssLike = new Set(['.css', '.scss', '.sass', '.less']);
534
- findings.push(...runRegexMatchers(lines, filePath, 0, cssLike.has(ext) || null, {
535
- profile,
536
- phase: 'source',
537
- }));
538
-
539
- // Extract and scan <style> blocks from Vue/Svelte SFCs
540
- const styleBlocks = profile
541
- ? profileStep(profile, {
542
- engine: 'regex',
543
- phase: 'extract',
544
- ruleId: 'style-blocks',
545
- target: filePath,
546
- }, () => extractStyleBlocks(content, ext))
547
- : extractStyleBlocks(content, ext);
548
- for (const block of styleBlocks) {
549
- const blockLines = block.content.split('\n');
550
- findings.push(...runRegexMatchers(blockLines, filePath, block.startLine - 1, true, {
551
- profile,
552
- phase: 'style-block',
553
- }));
554
- }
555
-
556
- // Extract and scan CSS-in-JS template literals
557
- const cssJsBlocks = profile
558
- ? profileStep(profile, {
559
- engine: 'regex',
560
- phase: 'extract',
561
- ruleId: 'css-in-js',
562
- target: filePath,
563
- }, () => extractCSSinJS(content, ext))
564
- : extractCSSinJS(content, ext);
565
- for (const block of cssJsBlocks) {
566
- const blockLines = block.content.split('\n');
567
- findings.push(...runRegexMatchers(blockLines, filePath, block.startLine - 1, true, {
568
- profile,
569
- phase: 'css-in-js',
570
- }));
571
- }
572
-
573
- if (options?.designSystem) {
574
- findings.push(...profileFindings(profile, {
575
- engine: 'regex',
576
- phase: 'source',
577
- ruleId: 'design-system',
578
- target: filePath,
579
- }, () => checkSourceDesignSystem(content, filePath, { designSystem: options.designSystem })));
580
- }
581
-
582
- // Deduplicate findings (same antipattern + similar snippet, within 2 lines)
583
- const deduped = [];
584
- for (const f of findings) {
585
- const isDupe = deduped.some(d =>
586
- d.antipattern === f.antipattern &&
587
- d.snippet === f.snippet &&
588
- Math.abs(d.line - f.line) <= 2
589
- );
590
- if (!isDupe) deduped.push(f);
591
- }
592
-
593
- // Page-level analyzers only run on full pages
594
- if (shouldRunPageAnalyzers(content, filePath)) {
595
- const analyzerIds = [
596
- 'single-font',
597
- 'flat-type-hierarchy',
598
- 'monotonous-spacing',
599
- 'em-dash-overuse',
600
- 'marketing-buzzword',
601
- 'numbered-section-markers',
602
- 'aphoristic-cadence',
603
- 'dark-glow',
604
- ];
605
- for (let i = 0; i < REGEX_ANALYZERS.length; i++) {
606
- const analyzer = REGEX_ANALYZERS[i];
607
- deduped.push(...profileFindings(profile, {
608
- engine: 'regex',
609
- phase: 'page-analyzer',
610
- ruleId: analyzerIds[i] || `analyzer-${i + 1}`,
611
- target: filePath,
612
- }, () => analyzer(content, filePath)));
613
- }
614
- }
615
-
616
- // Stylesheet-level accessibility analyzers (focus-visible, hover-only,
617
- // dark-scheme). Run on CSS-like sources and full HTML pages.
618
- deduped.push(...runStylesheetAnalyzers(content, filePath, options));
619
-
620
- const byProvider = filterByProviders(deduped, options?.providers);
621
- // Inline `monodesign-disable*` waivers travel with the file; honor them unless
622
- // explicitly bypassed (`--no-config` / `--no-inline-ignores`).
623
- return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, content);
624
- }
625
-
626
- export {
627
- REGEX_MATCHERS,
628
- REGEX_ANALYZERS,
629
- TEXT_CONTENT_ANALYZER_IDS,
630
- extractStyleBlocks,
631
- extractCSSinJS,
632
- runRegexMatchers,
633
- runTextContentAnalyzers,
634
- runStylesheetAnalyzers,
635
- detectText,
636
- };