@raintree-technology/hig-doctor-core 0.1.1 → 0.1.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.
- package/CHANGELOG.md +9 -0
- package/README.md +23 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/patterns.test.ts +29 -1
- package/src/patterns.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to `@raintree-technology/hig-doctor-core` are documented her
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
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
|
+
|
|
8
17
|
## [0.1.1] - 2026-07-26
|
|
9
18
|
|
|
10
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -4,8 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
# @raintree-technology/hig-doctor-core
|
|
6
6
|
|
|
7
|
+
**Active library for tool authors embedding HIG Doctor audits.** It provides
|
|
8
|
+
framework detection, rule metadata, tiered analysis, and report generation.
|
|
9
|
+
|
|
7
10
|
The rule engine behind [HIG Doctor](https://github.com/raintree-technology/hig-doctor): framework detection, the Apple HIG rule catalog, tiered analysis (regex → Swift structural → TypeScript-compiler JSX), and the audit pipeline. The [`hig-doctor`](../cli) CLI and [`hig-mcp`](../mcp) server are thin wrappers over this package; embed it directly to run audits from your own tooling.
|
|
8
11
|
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @raintree-technology/hig-doctor-core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Run an audit
|
|
19
|
+
|
|
9
20
|
```ts
|
|
10
21
|
import { audit, analyzeFile, ruleCatalog, toSarif } from "@raintree-technology/hig-doctor-core";
|
|
11
22
|
|
|
@@ -22,6 +33,9 @@ for (const rule of ruleCatalog()) {
|
|
|
22
33
|
}
|
|
23
34
|
```
|
|
24
35
|
|
|
36
|
+
Expected result: `audit` returns categorized, engine-tagged findings without
|
|
37
|
+
sending source code over the network.
|
|
38
|
+
|
|
25
39
|
## Exports
|
|
26
40
|
|
|
27
41
|
- `audit(dir, skillsDir?, options?)` — full scan → detect → categorize → report, with config, baseline, and cache support.
|
|
@@ -33,6 +47,14 @@ for (const rule of ruleCatalog()) {
|
|
|
33
47
|
|
|
34
48
|
The `ast-tsx` tier uses the TypeScript compiler when the optional `typescript` dependency is present, and falls back to the regex tier otherwise.
|
|
35
49
|
|
|
50
|
+
## Compatibility and limits
|
|
51
|
+
|
|
52
|
+
The package runs on Node 20+ and Bun. It is a static review aid, not proof of
|
|
53
|
+
HIG conformance, accessibility, or design quality. Apple-platform checks cite
|
|
54
|
+
the HIG directly; other surfaces use aligned interface-quality rules. See the
|
|
55
|
+
[project guide](../../README.md), [benchmark](../../docs/benchmark.md), and
|
|
56
|
+
[security policy](../../SECURITY.md).
|
|
57
|
+
|
|
36
58
|
## License
|
|
37
59
|
|
|
38
|
-
MIT. Apple HIG reference content the engine cites is © Apple Inc. — see the repository [
|
|
60
|
+
MIT. Apple HIG reference content the engine cites is © Apple Inc. — see the repository [THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md).
|
package/dist/index.js
CHANGED
|
@@ -465,8 +465,8 @@ var webCodeRules = [
|
|
|
465
465
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "ambiguous link text", regex: />\s*(click here|read more|learn more|here|more)\s*</i, fileFilter: WEB_ALL },
|
|
466
466
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "positive tabindex", regex: /tabIndex=\{[1-9]|tabindex="[1-9]/, fileFilter: WEB_ALL },
|
|
467
467
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "aria-hidden on focusable", regex: /aria-hidden=["']true["'][^>]*(?:<button|<a\s|<input|tabIndex)/, fileFilter: WEB_ALL },
|
|
468
|
-
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOver without onFocus", regex:
|
|
469
|
-
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOut without onBlur", regex:
|
|
468
|
+
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOver without onFocus", regex: /<[A-Za-z][\w.:-]*\b(?:(?!\bonFocus\s*=)[^>])*\bonMouseOver\s*=(?:(?!\bonFocus\s*=)[^>])*>/, fileFilter: TSX_JSX, scope: "document" },
|
|
469
|
+
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOut without onBlur", regex: /<[A-Za-z][\w.:-]*\b(?:(?!\bonBlur\s*=)[^>])*\bonMouseOut\s*=(?:(?!\bonBlur\s*=)[^>])*>/, fileFilter: TSX_JSX, scope: "document" },
|
|
470
470
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "autoFocus", regex: /autoFocus\b|autofocus\b/, fileFilter: WEB_ALL },
|
|
471
471
|
// ── Heading & Structure ─────────────────────────────────────
|
|
472
472
|
{ category: "foundations", subcategory: "structure", type: "concern", pattern: "empty heading", regex: /<h[1-6][^>]*>\s*<\/h[1-6]>/, fileFilter: WEB_ALL, scope: "document" },
|
package/package.json
CHANGED
package/src/patterns.test.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { join } from "node:path";
|
|
|
10
10
|
// - AGENTS.md (root)
|
|
11
11
|
// - .claude-plugin/marketplace.json (plugin description)
|
|
12
12
|
// - website/components/AuditDemo.tsx (the "same N rules" copy)
|
|
13
|
-
// -
|
|
13
|
+
// - docs/remotion-showcase.md
|
|
14
14
|
// - demos/remotion-hig-doctor/src/data/report-data.json ("totalRules")
|
|
15
15
|
const EXPECTED_RULE_COUNT = 431;
|
|
16
16
|
test(`rule count is exactly ${EXPECTED_RULE_COUNT}`, () => {
|
|
@@ -668,6 +668,34 @@ describe("no false positives — negative-attribute rules", () => {
|
|
|
668
668
|
const matches = detectPatterns(`<svg viewBox="0 0 24 24"></svg>`, "Icon.tsx");
|
|
669
669
|
expect(matches.some(m => m.pattern === "svg without a11y" && m.type === "concern")).toBe(true);
|
|
670
670
|
});
|
|
671
|
+
test("does NOT flag onMouseOver when onFocus appears earlier in a multi-line tag", () => {
|
|
672
|
+
const code = `<button
|
|
673
|
+
onFocus={preview}
|
|
674
|
+
onMouseOver={preview}
|
|
675
|
+
aria-label="Preview"
|
|
676
|
+
>`;
|
|
677
|
+
expect(detectPatterns(code, "Hero.tsx").some(m => m.pattern === "onMouseOver without onFocus")).toBe(false);
|
|
678
|
+
});
|
|
679
|
+
test("does NOT flag onMouseOver when onFocus appears later in the tag", () => {
|
|
680
|
+
const code = `<button onMouseOver={preview} onFocus={preview}>Preview</button>`;
|
|
681
|
+
expect(detectPatterns(code, "Hero.tsx").some(m => m.pattern === "onMouseOver without onFocus")).toBe(false);
|
|
682
|
+
});
|
|
683
|
+
test("flags onMouseOver when the same tag has no onFocus", () => {
|
|
684
|
+
const code = `<button
|
|
685
|
+
onMouseOver={preview}
|
|
686
|
+
aria-label="Preview"
|
|
687
|
+
>`;
|
|
688
|
+
const matches = detectPatterns(code, "Hero.tsx").filter(m => m.pattern === "onMouseOver without onFocus");
|
|
689
|
+
expect(matches).toHaveLength(1);
|
|
690
|
+
expect(matches[0]?.line).toBe(1);
|
|
691
|
+
});
|
|
692
|
+
test("does NOT flag onMouseOut when onBlur appears in the same multi-line tag", () => {
|
|
693
|
+
const code = `<button
|
|
694
|
+
onMouseOut={hidePreview}
|
|
695
|
+
onBlur={hidePreview}
|
|
696
|
+
>`;
|
|
697
|
+
expect(detectPatterns(code, "Hero.tsx").some(m => m.pattern === "onMouseOut without onBlur")).toBe(false);
|
|
698
|
+
});
|
|
671
699
|
});
|
|
672
700
|
|
|
673
701
|
// ════════════════════════════════════════════════════════════════
|
package/src/patterns.ts
CHANGED
|
@@ -248,8 +248,8 @@ const webCodeRules: PatternRule[] = [
|
|
|
248
248
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "ambiguous link text", regex: />\s*(click here|read more|learn more|here|more)\s*</i, fileFilter: WEB_ALL },
|
|
249
249
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "positive tabindex", regex: /tabIndex=\{[1-9]|tabindex="[1-9]/, fileFilter: WEB_ALL },
|
|
250
250
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "aria-hidden on focusable", regex: /aria-hidden=["']true["'][^>]*(?:<button|<a\s|<input|tabIndex)/, fileFilter: WEB_ALL },
|
|
251
|
-
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOver without onFocus", regex:
|
|
252
|
-
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOut without onBlur", regex:
|
|
251
|
+
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOver without onFocus", regex: /<[A-Za-z][\w.:-]*\b(?:(?!\bonFocus\s*=)[^>])*\bonMouseOver\s*=(?:(?!\bonFocus\s*=)[^>])*>/, fileFilter: TSX_JSX, scope: "document" },
|
|
252
|
+
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "onMouseOut without onBlur", regex: /<[A-Za-z][\w.:-]*\b(?:(?!\bonBlur\s*=)[^>])*\bonMouseOut\s*=(?:(?!\bonBlur\s*=)[^>])*>/, fileFilter: TSX_JSX, scope: "document" },
|
|
253
253
|
{ category: "foundations", subcategory: "accessibility", type: "concern", pattern: "autoFocus", regex: /autoFocus\b|autofocus\b/, fileFilter: WEB_ALL },
|
|
254
254
|
|
|
255
255
|
// ── Heading & Structure ─────────────────────────────────────
|