@raintree-technology/hig-doctor-core 0.1.2 → 0.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@raintree-technology/hig-doctor-core",
3
- "version": "0.1.2",
4
- "description": "Rule engine powering HIG Doctor: framework detection, Apple HIG pattern rules, and the audit pipeline.",
3
+ "version": "0.2.0",
4
+ "description": "HIG Doctor rule engine: framework detection, Apple HIG and accessibility rules, and the audit pipeline.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/index.js",
@@ -16,11 +16,11 @@
16
16
  "files": [
17
17
  "dist",
18
18
  "src",
19
- "README.md",
20
- "CHANGELOG.md"
19
+ "!src/**/*.test.ts",
20
+ "README.md"
21
21
  ],
22
22
  "engines": {
23
- "node": "24.x"
23
+ "node": ">=22"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
@@ -43,7 +43,7 @@
43
43
  "typescript": "^5.9.3"
44
44
  },
45
45
  "scripts": {
46
- "build": "esbuild src/index.ts --bundle --platform=node --target=node20 --format=esm --external:typescript --outfile=dist/index.js && tsc -p tsconfig.build.json",
46
+ "build": "esbuild src/index.ts --bundle --platform=node --target=node22 --format=esm --external:typescript --outfile=dist/index.js && tsc -p tsconfig.build.json",
47
47
  "test": "bun test",
48
48
  "typecheck": "tsc --noEmit",
49
49
  "prepublishOnly": "bun run build"
@@ -53,6 +53,5 @@
53
53
  "@types/node": "^20",
54
54
  "esbuild": "^0.25.0",
55
55
  "typescript": "^5.9.3"
56
- },
57
- "packageManager": "bun@1.3.11"
56
+ }
58
57
  }
package/src/analyze.ts CHANGED
@@ -1,4 +1,4 @@
1
- // analyze.ts — the tiered analysis entry point.
1
+ // Tiered analysis entry point.
2
2
  //
3
3
  // Base tier: detectPatterns (regex, always available, dependency-free).
4
4
  // Refinement tiers run on top and are strictly precision-improving:
@@ -1,4 +1,4 @@
1
- // audit-generator.ts
1
+ // Renders the Markdown audit report.
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import type { ScanResult } from "./scanner";
@@ -96,7 +96,7 @@ export async function loadSkillContent(skillsDir: string, skillName: string): Pr
96
96
  const skillPath = join(skillsDir, skillName, "SKILL.md");
97
97
  const content = await readFile(skillPath, "utf-8");
98
98
  const stripped = content.replace(/^---\s*\r?\n[\s\S]*?\r?\n---\s*(?:\r?\n|$)/, "");
99
- const principlesMatch = stripped.match(/## Key Principles\n([\s\S]*?)(?=\n## |$)/);
99
+ const principlesMatch = stripped.match(/## Key Principles\r?\n([\s\S]*?)(?=\r?\n## |$)/);
100
100
  return principlesMatch ? principlesMatch[1].trim() : stripped.slice(0, 2000);
101
101
  } catch {
102
102
  return null;
@@ -133,32 +133,16 @@ export function generateAuditMarkdown(
133
133
  lines.push(`**Quick stats**: ${totalConcerns} potential concerns, ${totalPositives} positive patterns, ${totalPatterns} component usages detected across ${categories.length} HIG categories`);
134
134
  lines.push("");
135
135
 
136
- // Instructions
137
- lines.push("## Instructions for AI Evaluator");
136
+ lines.push("## How to use this report");
138
137
  lines.push("");
139
- lines.push("You are reviewing a project for Apple Human Interface Guidelines compliance.");
140
- lines.push("The HIG principles (accessibility, color systems, typography, responsive layout, motion) apply to all surfaces — native, web, and cross-platform.");
141
- lines.push("For each category below, evaluate the code excerpts against the HIG reference material.");
142
- lines.push("");
143
- lines.push("**Scoring**: Rate each category 1-10:");
144
- lines.push("- **9-10**: Excellent HIG compliance, follows best practices");
145
- lines.push("- **7-8**: Good compliance with minor improvements possible");
146
- lines.push("- **5-6**: Partial compliance, several areas need attention");
147
- lines.push("- **3-4**: Significant HIG violations");
148
- lines.push("- **1-2**: Major violations or missing fundamental practices");
149
- lines.push("");
150
- lines.push("**Output**: For each category, provide:");
151
- lines.push("1. Score (1-10)");
152
- lines.push("2. What's done well (cite specific code)");
153
- lines.push("3. What needs improvement (cite specific file:line)");
154
- lines.push("4. Specific fix recommendations");
138
+ lines.push("Concerns are probable problems found by static rules; positives and patterns only record what the code uses. Check each concern against the HIG reference under its category, then fix it or document why it does not apply. Automated findings do not establish HIG or accessibility conformance.");
155
139
  lines.push("");
156
140
 
157
141
  // Categories
158
142
  for (const category of categories) {
159
143
  lines.push(`## Category: ${category.label}`);
160
144
  lines.push("");
161
- lines.push(`*${category.matches.length} detections across ${category.fileCount} file(s) — ${category.concerns} concern(s), ${category.positives} positive(s)*`);
145
+ lines.push(`*${category.matches.length} detections across ${category.fileCount} file(s): ${category.concerns} concern(s), ${category.positives} positive(s)*`);
162
146
  lines.push("");
163
147
 
164
148
  lines.push("### Code Excerpts");
@@ -179,116 +163,7 @@ export function generateAuditMarkdown(
179
163
  lines.push(`*Load reference from skill: ${category.skillName}*`);
180
164
  }
181
165
  lines.push("");
182
-
183
- lines.push("### Evaluate");
184
- lines.push("");
185
- const checks = getEvaluationChecklist(category.skillName);
186
- for (const check of checks) {
187
- lines.push(`- ${check}`);
188
- }
189
- lines.push("");
190
166
  }
191
167
 
192
- // Scoring table
193
- lines.push("## Scoring Summary");
194
- lines.push("");
195
- lines.push("| Category | Score (1-10) | Key Findings |");
196
- lines.push("|----------|-------------|-------------|");
197
- for (const category of categories) {
198
- lines.push(`| ${category.label} | | |`);
199
- }
200
- lines.push("| **Overall** | **/10** | |");
201
- lines.push("");
202
-
203
168
  return lines.join("\n");
204
169
  }
205
-
206
- function getEvaluationChecklist(skillName: string): string[] {
207
- const checklists: Record<string, string[]> = {
208
- "hig-foundations": [
209
- "Color usage: system semantic colors vs hardcoded values",
210
- "Typography: Dynamic Type text styles vs fixed font sizes",
211
- "Accessibility: labels, hints, traits on interactive elements",
212
- "Dark mode: proper color adaptation, no hardcoded light/dark values",
213
- "Motion: Reduce Motion support for animations",
214
- ],
215
- "hig-components-layout": [
216
- "Navigation pattern matches app structure (tabs for flat, sidebar for deep)",
217
- "Adaptive layout: responds to size classes, multitasking",
218
- "Standard navigation components (NavigationSplitView, not deprecated NavigationView)",
219
- "Consistent back navigation and spatial hierarchy",
220
- ],
221
- "hig-components-controls": [
222
- "Standard control usage (Button, Toggle, Picker, etc.)",
223
- "Proper button styles and roles",
224
- "Clear action labels and consistent interaction patterns",
225
- ],
226
- "hig-components-selection": [
227
- "Appropriate picker and selection controls",
228
- "Clear selection state feedback",
229
- ],
230
- "hig-components-actions": [
231
- "Button hierarchy and prominence",
232
- "Destructive actions clearly marked",
233
- "Swipe actions follow HIG conventions",
234
- ],
235
- "hig-components-presentation": [
236
- "Sheets for focused tasks, popovers for contextual info",
237
- "Alerts used sparingly for important decisions",
238
- "Confirmation dialogs for destructive actions",
239
- ],
240
- "hig-components-textinput": [
241
- "Text fields use appropriate keyboard types",
242
- "Search functionality uses .searchable where appropriate",
243
- ],
244
- "hig-components-media": [
245
- "Image handling with proper async loading",
246
- "Media playback uses system controls",
247
- ],
248
- "hig-components-menus": [
249
- "Context menus provide relevant actions",
250
- "Menu organization follows HIG grouping conventions",
251
- ],
252
- "hig-components-dialogs": [
253
- "Alerts used sparingly for important decisions",
254
- "Sheets for focused tasks, popovers for contextual info",
255
- "Confirmation dialogs for destructive actions",
256
- ],
257
- "hig-components-search": [
258
- "Searchable modifier used for filterable content",
259
- "Search suggestions and scopes where appropriate",
260
- ],
261
- "hig-components-status": [
262
- "Progress indicators for long operations",
263
- "Appropriate use of determinate vs indeterminate progress",
264
- ],
265
- "hig-components-content": [
266
- "Content display uses appropriate containers",
267
- "Image handling with proper async loading",
268
- ],
269
- "hig-components-system": [
270
- "System integration uses standard APIs (ShareLink, PhotosPicker)",
271
- "Deep link handling, widget support where relevant",
272
- ],
273
- "hig-patterns": [
274
- "Drag and drop support where appropriate",
275
- "Pull-to-refresh for refreshable content",
276
- "Swipe actions follow HIG conventions",
277
- "Undo support for destructive actions",
278
- ],
279
- "hig-inputs": [
280
- "Text input uses appropriate field types",
281
- "Keyboard shortcuts for power users (macOS/iPad)",
282
- "Gesture usage follows platform conventions",
283
- ],
284
- "hig-technologies": [
285
- "Apple framework integration follows HIG for that technology",
286
- "Proper permission handling and progressive disclosure",
287
- ],
288
- "hig-platforms": [
289
- "UI adapts appropriately across target platforms",
290
- "Platform idioms respected (iPhone vs iPad vs Mac)",
291
- ],
292
- };
293
- return checklists[skillName] ?? ["Evaluate against Apple HIG best practices for this category"];
294
- }
package/src/audit.ts CHANGED
@@ -1,4 +1,4 @@
1
- // audit.ts — Full pipeline: scan → detect → categorize → generate markdown
1
+ // Full pipeline: scan, detect, apply config and baseline, categorize, render Markdown.
2
2
  import { scanProject, type ScanResult } from "./scanner";
3
3
  import { type PatternMatch } from "./patterns";
4
4
  import { analyzeFile } from "./analyze";
@@ -43,7 +43,7 @@ export interface AuditResult {
43
43
  baselinePath: string | null;
44
44
  /** Concerns absorbed by the baseline (hidden from results and gating). */
45
45
  baselined: number;
46
- /** Baseline occurrences that no longer match anything — time to re-snapshot. */
46
+ /** Baseline occurrences that no longer match anything (time to re-snapshot). */
47
47
  baselineStale: number;
48
48
  /** Cache hit/miss counts when the cache is enabled, else null. */
49
49
  cacheStats: { hits: number; misses: number } | null;
@@ -68,17 +68,15 @@ export async function audit(directory: string, skillsDir?: string, options: Audi
68
68
  const allFiles = [...scanResult.codeFiles, ...scanResult.styleFiles, ...scanResult.markupFiles];
69
69
  const cachePath = join(resolvedDir, CACHE_FILENAME);
70
70
  const cache = options.cache ? await ScanCache.load(cachePath) : null;
71
- const touched = new Set<string>();
72
71
  for (const file of allFiles) {
73
72
  let matches = cache?.get(file.relativePath, file.content) ?? null;
74
73
  if (matches === null) {
75
74
  matches = analyzeFile(file.content, file.relativePath);
76
75
  cache?.set(file.relativePath, file.content, matches);
77
76
  }
78
- if (cache) touched.add(cache.keyOf(file.relativePath, file.content));
79
77
  detected.push(...matches);
80
78
  }
81
- if (cache) await cache.save(cachePath, touched);
79
+ if (cache) await cache.save(cachePath);
82
80
  const configured = applyConfig(detected, loaded.config);
83
81
 
84
82
  // 4. Apply baseline: previously-snapshotted concerns are absorbed so only
@@ -108,14 +106,10 @@ export async function audit(directory: string, skillsDir?: string, options: Audi
108
106
  if (skillsDir) {
109
107
  resolvedSkillsDir = resolve(skillsDir);
110
108
  } else {
111
- // Try to find skills directory relative to common locations
112
- const candidates = [
113
- join(resolvedDir, "skills"),
114
- join(resolvedDir, "..", "skills"),
115
- join(resolvedDir, "..", "..", "skills"),
116
- // Relative to this package (for development: packages/core/src → repo root)
117
- join(moduleDir, "..", "..", "..", "skills"),
118
- ];
109
+ // The audited project's own skills/, then this repo's (running from source).
110
+ // Parent directories are not searched: an unrelated ../skills folder would
111
+ // otherwise leak into the report.
112
+ const candidates = [join(resolvedDir, "skills"), join(moduleDir, "..", "..", "..", "skills")];
119
113
  for (const candidate of candidates) {
120
114
  try {
121
115
  await access(candidate);
package/src/baseline.ts CHANGED
Binary file
package/src/benchmark.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // should produce. "bad" fixtures assert true positives (a missing one is a
5
5
  // false negative); "good" fixtures assert the absence of concerns (any concern
6
6
  // is a false positive). The harness scores per-rule and overall so regressions
7
- // in either direction are visible. docs/benchmark.md is generated from this.
7
+ // in either direction are visible.
8
8
  import { analyzeFile } from "./analyze";
9
9
 
10
10
  export interface BenchmarkCase {
package/src/cache.ts CHANGED
@@ -1,4 +1,4 @@
1
- // cache.ts — content-hash cache for local scans.
1
+ // Content-hash cache for local scans.
2
2
  //
3
3
  // Analysis is a pure function of (path, content, ruleset), so re-scanning a
4
4
  // project only needs to re-analyze files whose content changed. The cache keys
@@ -33,6 +33,7 @@ function keyFor(path: string, content: string): string {
33
33
 
34
34
  export class ScanCache {
35
35
  private entries: Map<string, PatternMatch[]>;
36
+ private touched = new Set<string>();
36
37
  private hits = 0;
37
38
  private misses = 0;
38
39
 
@@ -44,7 +45,7 @@ export class ScanCache {
44
45
  try {
45
46
  const raw = await readFile(path, "utf-8");
46
47
  const parsed = JSON.parse(raw) as CacheFile;
47
- // A namespace mismatch means the ruleset or cache format changed — drop it.
48
+ // A namespace mismatch means the ruleset or cache format changed: drop it.
48
49
  if (parsed.namespace === namespace() && parsed.entries) {
49
50
  return new ScanCache(new Map(Object.entries(parsed.entries)));
50
51
  }
@@ -56,7 +57,9 @@ export class ScanCache {
56
57
 
57
58
  /** Return cached findings for this file, or null on a miss. */
58
59
  get(path: string, content: string): PatternMatch[] | null {
59
- const hit = this.entries.get(keyFor(path, content));
60
+ const key = keyFor(path, content);
61
+ this.touched.add(key);
62
+ const hit = this.entries.get(key);
60
63
  if (hit) {
61
64
  this.hits++;
62
65
  return hit;
@@ -66,24 +69,22 @@ export class ScanCache {
66
69
  }
67
70
 
68
71
  set(path: string, content: string, matches: PatternMatch[]): void {
69
- this.entries.set(keyFor(path, content), matches);
72
+ const key = keyFor(path, content);
73
+ this.touched.add(key);
74
+ this.entries.set(key, matches);
70
75
  }
71
76
 
72
77
  get stats(): { hits: number; misses: number } {
73
78
  return { hits: this.hits, misses: this.misses };
74
79
  }
75
80
 
76
- /** Persist only the keys touched this run, so deleted files don't accumulate. */
77
- async save(path: string, touched: Set<string>): Promise<void> {
81
+ /** Persist only entries read or written this run, so deleted files drop out. */
82
+ async save(path: string): Promise<void> {
78
83
  const entries: Record<string, PatternMatch[]> = {};
79
84
  for (const [k, v] of this.entries) {
80
- if (touched.has(k)) entries[k] = v;
85
+ if (this.touched.has(k)) entries[k] = v;
81
86
  }
82
87
  const file: CacheFile = { namespace: namespace(), entries };
83
88
  await writeFile(path, JSON.stringify(file));
84
89
  }
85
-
86
- keyOf(path: string, content: string): string {
87
- return keyFor(path, content);
88
- }
89
90
  }
@@ -1,4 +1,4 @@
1
- // categorizer.ts
1
+ // Groups matches by HIG skill: rule category N maps to skill hig-N.
2
2
  import type { PatternMatch } from "./patterns";
3
3
 
4
4
  export interface CategorySummary {
@@ -16,35 +16,9 @@ export interface CategorySummary {
16
16
  files: string[];
17
17
  }
18
18
 
19
- const CATEGORY_TO_SKILL: Record<string, string> = {
20
- "foundations": "hig-foundations",
21
- "components-layout": "hig-components-layout",
22
- "components-selection": "hig-components-selection",
23
- "components-actions": "hig-components-actions",
24
- "components-presentation": "hig-components-presentation",
25
- "components-textinput": "hig-components-textinput",
26
- "components-media": "hig-components-media",
27
- "components-controls": "hig-components-controls",
28
- "components-menus": "hig-components-menus",
29
- "components-dialogs": "hig-components-dialogs",
30
- "components-search": "hig-components-search",
31
- "components-status": "hig-components-status",
32
- "components-content": "hig-components-content",
33
- "components-system": "hig-components-system",
34
- "patterns": "hig-patterns",
35
- "platforms": "hig-platforms",
36
- "technologies": "hig-technologies",
37
- "inputs": "hig-inputs",
38
- };
39
-
40
19
  const CATEGORY_LABELS: Record<string, string> = {
41
20
  "hig-foundations": "Foundations",
42
21
  "hig-components-layout": "Layout & Navigation",
43
- "hig-components-selection": "Selection Controls",
44
- "hig-components-actions": "Actions",
45
- "hig-components-presentation": "Presentation",
46
- "hig-components-textinput": "Text Input",
47
- "hig-components-media": "Media",
48
22
  "hig-components-controls": "Controls",
49
23
  "hig-components-menus": "Menus & Actions",
50
24
  "hig-components-dialogs": "Dialogs & Presentations",
@@ -64,7 +38,7 @@ export function categorizeMatches(matches: PatternMatch[]): CategorySummary[] {
64
38
  const grouped = new Map<string, PatternMatch[]>();
65
39
 
66
40
  for (const match of matches) {
67
- const skillName = CATEGORY_TO_SKILL[match.category] || `hig-${match.category}`;
41
+ const skillName = `hig-${match.category}`;
68
42
  if (!grouped.has(skillName)) {
69
43
  grouped.set(skillName, []);
70
44
  }
package/src/config.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  // { "files": ["marketing/**"], "rules": { "css/outline-none": "off" } }
9
9
  // ]
10
10
  // }
11
- // Rule keys are stable rule IDs (see docs/rules.md) or prefix globs ending in
11
+ // Rule keys are stable rule IDs (see the README rule table) or prefix globs ending in
12
12
  // "*". Values: "off" drops the rule, a severity remaps concern severity, "on"
13
13
  // keeps the default. Overrides apply per file glob; the last matching override
14
14
  // wins over the global rules map.
@@ -56,11 +56,11 @@ function validateRules(
56
56
  for (const [id, setting] of Object.entries(rules)) {
57
57
  if (typeof setting !== "string" || !VALID_SETTINGS.has(setting)) {
58
58
  throw new Error(
59
- `${where}: invalid setting ${JSON.stringify(setting)} for rule "${id}" — expected "off", "on", "critical", "serious", or "moderate"`,
59
+ `${where}: invalid setting ${JSON.stringify(setting)} for rule "${id}": expected "off", "on", "critical", "serious", or "moderate"`,
60
60
  );
61
61
  }
62
62
  if (!id.includes("*") && !getRuleById(id)) {
63
- warnings.push(`${where}: unknown rule ID "${id}" (see docs/rules.md)`);
63
+ warnings.push(`${where}: unknown rule ID "${id}"`);
64
64
  }
65
65
  out[id] = setting as RuleSetting;
66
66
  }
package/src/index.ts CHANGED
@@ -1,6 +1,4 @@
1
- // @raintree-technology/hig-doctor-core — public API surface.
2
- // The CLI, MCP server, and website audit demo all consume the engine through
3
- // this module; keep additions here deliberate since they become npm API.
1
+ // Public API of @raintree-technology/hig-doctor-core. Everything exported here is npm API.
4
2
  export {
5
3
  audit,
6
4
  type AuditOptions,
@@ -72,10 +70,3 @@ export {
72
70
  type SuggestedFix,
73
71
  type FixApplication,
74
72
  } from "./fixes";
75
- export {
76
- runBenchmark,
77
- BENCHMARK_CASES,
78
- type BenchmarkCase,
79
- type BenchmarkReport,
80
- type RuleScore,
81
- } from "./benchmark";
package/src/patterns.ts CHANGED
@@ -1,7 +1,5 @@
1
- // patterns.ts — Universal HIG pattern detection across all frameworks
2
- // Rules cover Swift, React, Vue, Svelte, Angular, Flutter, Kotlin, Android XML, CSS, HTML.
3
- // The authoritative rule count is the exported RULE_COUNT (end of file); never
4
- // hardcode a count in prose — import RULE_COUNT instead.
1
+ // Rule catalog and the regex detection tier for every supported framework.
2
+ // Use the exported RULE_COUNT rather than hardcoding a count.
5
3
  export type Severity = "critical" | "serious" | "moderate";
6
4
 
7
5
  // The Apple HIG snapshot this ruleset and the skills corpus were authored
@@ -630,7 +628,7 @@ const flutterRules: PatternRule[] = [
630
628
  // Color
631
629
  { category: "foundations", subcategory: "color", type: "positive", pattern: "Theme color", regex: /Theme\.of\(context\)\.colorScheme/, fileFilter: DART },
632
630
  { category: "foundations", subcategory: "color", type: "concern", pattern: "hardcoded Color", regex: /Color\(0x[0-9a-fA-F]+\)/, fileFilter: DART },
633
- { category: "foundations", subcategory: "color", type: "concern", pattern: "Colors.red/blue", regex: /Colors\.(red|blue|green|yellow|orange|purple|pink|white|black|grey)\b/, fileFilter: DART },
631
+ { category: "foundations", subcategory: "color", type: "concern", pattern: "Colors.red/blue", regex: /\bColors\.(red|blue|green|yellow|orange|purple|pink|white|black|grey)\b/, fileFilter: DART },
634
632
  // Typography
635
633
  { category: "foundations", subcategory: "typography", type: "positive", pattern: "Theme text style", regex: /Theme\.of\(context\)\.textTheme/, fileFilter: DART },
636
634
  { category: "foundations", subcategory: "typography", type: "concern", pattern: "hardcoded fontSize", regex: /fontSize:\s*\d+/, fileFilter: DART },
@@ -1044,8 +1042,10 @@ export function ruleCatalog(): RuleMeta[] {
1044
1042
  return allRules.map(toMeta);
1045
1043
  }
1046
1044
 
1045
+ const rulesById = new Map(allRules.map(r => [r.id, r]));
1046
+
1047
1047
  export function getRuleById(id: string): RuleMeta | undefined {
1048
- const rule = allRules.find(r => r.id === id);
1048
+ const rule = rulesById.get(id);
1049
1049
  return rule ? toMeta(rule) : undefined;
1050
1050
  }
1051
1051
 
@@ -1131,7 +1131,7 @@ function suppressionCovers(ids: string[] | "all", ruleId: string): boolean {
1131
1131
  * `hig-disable-*` comments the regex tier does.
1132
1132
  */
1133
1133
  export function buildSuppressionFilter(code: string): (ruleId: string, line: number) => boolean {
1134
- const rawLines = code.split("\n");
1134
+ const rawLines = code.split(/\r?\n/);
1135
1135
 
1136
1136
  // Collect suppressions before any stripping. next-line targets are 1-based.
1137
1137
  let fileSuppression: string[] | "all" | null = null;
@@ -1165,7 +1165,7 @@ export function buildSuppressionFilter(code: string): (ruleId: string, line: num
1165
1165
  // tiers on top. Callers wanting the strongest available analysis use analyzeFile.
1166
1166
  export function detectPatterns(code: string, file: string): PatternMatch[] {
1167
1167
  const matches: PatternMatch[] = [];
1168
- const rawLines = code.split("\n");
1168
+ const rawLines = code.split(/\r?\n/);
1169
1169
 
1170
1170
  const isSuppressed = buildSuppressionFilter(code);
1171
1171
  const isStyleFile = /\.(css|scss|sass|less)$/.test(file);
@@ -1303,5 +1303,4 @@ export function detectPatterns(code: string, file: string): PatternMatch[] {
1303
1303
  return matches;
1304
1304
  }
1305
1305
 
1306
- // Export rule count for documentation
1307
1306
  export const RULE_COUNT = allRules.length;
package/src/scanner.ts CHANGED
@@ -127,10 +127,7 @@ async function loadIgnorePatterns(directory: string): Promise<string[]> {
127
127
  function buildIgnoreMatcher(patterns: string[]): (relPath: string) => boolean {
128
128
  const regexps = patterns.map(globToRegExp);
129
129
  if (regexps.length === 0) return () => false;
130
- return (relPath: string) => {
131
- const posix = relPath.split(sep).join("/");
132
- return regexps.some(re => re.test(posix));
133
- };
130
+ return (relPath: string) => regexps.some(re => re.test(relPath));
134
131
  }
135
132
 
136
133
  // Read a UTF-8 file, skipping anything too large to be worth scanning. Returns
@@ -173,7 +170,8 @@ async function walkDir(dir: string, rootDir: string, result: ScanResult, isIgnor
173
170
  }
174
171
  for (const entry of entries) {
175
172
  const fullPath = join(dir, entry.name);
176
- const relPath = relative(rootDir, fullPath);
173
+ // POSIX separators everywhere downstream: globs, baselines, SARIF, reports.
174
+ const relPath = relative(rootDir, fullPath).split(sep).join("/");
177
175
  // Never follow symlinks: avoids escaping the scanned tree (e.g. a link to /)
178
176
  // and breaks any directory cycles.
179
177
  if (entry.isSymbolicLink()) continue;
package/CHANGELOG.md DELETED
@@ -1,51 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to `@raintree-technology/hig-doctor-core` are documented here.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.1.2] - 2026-09-02
9
-
10
- ### Fixed
11
-
12
- - Match `onMouseOver` and `onMouseOut` accessibility concerns within one JSX
13
- element so handlers on separate elements cannot satisfy each other.
14
- - Preserve valid `onFocus` and `onBlur` counterparts regardless of their
15
- attribute order or line position inside the element.
16
-
17
- ## [0.1.1] - 2026-07-26
18
-
19
- ### Fixed
20
-
21
- - Report the opening element's line for JSX findings and honor inline
22
- suppressions in the AST tier.
23
- - Fall back to regex analysis when Bun resolves a missing TypeScript compiler
24
- to an unusable stub module.
25
- - Include analysis-tier availability in cache identity so caches cannot replay
26
- AST findings in environments without the AST tier.
27
- - Scan native platform directories unless the project is Flutter or React
28
- Native, and normalize Windows paths before applying config overrides.
29
- - Keep safe CSS fixes out of comments and strings, including multi-line forms.
30
-
31
- ### Added
32
-
33
- - `suggestFixInContent`, which uses surrounding file context when producing
34
- machine-readable edits.
35
-
36
- ## [0.1.0] - 2026-07-21
37
-
38
- Initial release of the extracted rule engine.
39
-
40
- ### Added
41
-
42
- - `audit` pipeline (scan → detect → categorize → report) with config, baseline,
43
- inline suppression, and content-hash cache support.
44
- - Tiered analysis: `detectPatterns` (regex base tier), `analyzeFile` (regex +
45
- Swift structural + TypeScript-compiler JSX refinement, each finding tagged
46
- with its engine).
47
- - Rule catalog with stable IDs, severities, engines, HIG citations, and fix
48
- guidance (`ruleCatalog`, `getRuleById`); 431 rules across 14 frameworks.
49
- - SARIF 2.1.0 output (`toSarif`) with suggested fixes.
50
- - Baseline (`createBaseline` / `applyBaseline`), config (`loadConfig` /
51
- `applyConfig`), fixes (`suggestFix` / `applyFixes`), and cache (`ScanCache`) APIs.