@web-hig/core 1.12.2 → 1.12.4
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/README.md +148 -0
- package/package.json +14 -1
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @web-hig/core
|
|
2
|
+
|
|
3
|
+
Shared evaluator engine for [The Web HIG](https://github.com/frozonfreak/hig) — load the rule registry, parse project contracts, and build multidimensional conformance reports.
|
|
4
|
+
|
|
5
|
+
This package is **not** a UI library. It implements tooling around the HIG **behavioural contract** (accessibility, motion, SSR, tokens, and related rule IDs).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @web-hig/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Most teams install **`@web-hig/cli`** instead, which depends on this package. Use **`@web-hig/core`** when building custom CI, editors, or agent integrations.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
The engine reads **`rules/registry.yaml`** from a HIG contract tree on disk. It does **not** embed the full registry in the npm tarball.
|
|
22
|
+
|
|
23
|
+
| Setup | `WEB_HIG_ROOT` |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| [ `@web-hig/install` ](../install/) with **`practical`** or **`full`** profile | `docs/hig` (contains `rules/registry.yaml`) |
|
|
26
|
+
| Git clone of [frozonfreak/hig](https://github.com/frozonfreak/hig) | repository root |
|
|
27
|
+
| Custom vendor layout | directory that contains `rules/registry.yaml` |
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
export WEB_HIG_ROOT=docs/hig # typical product repo after init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If unset, `resolveHigRoot()` walks up from `process.cwd()` looking for `rules/registry.yaml`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
import {
|
|
41
|
+
resolveHigRoot,
|
|
42
|
+
loadRegistry,
|
|
43
|
+
loadProjectConfig,
|
|
44
|
+
filterRulesByContract,
|
|
45
|
+
createReport,
|
|
46
|
+
printTerminalReport,
|
|
47
|
+
severityBucketForRule,
|
|
48
|
+
} from '@web-hig/core';
|
|
49
|
+
|
|
50
|
+
const higRoot = resolveHigRoot(process.cwd());
|
|
51
|
+
if (!higRoot) throw new Error('Set WEB_HIG_ROOT or vendor docs/hig from @web-hig/install');
|
|
52
|
+
|
|
53
|
+
const registry = loadRegistry(higRoot);
|
|
54
|
+
const { config } = loadProjectConfig(process.cwd());
|
|
55
|
+
const profile = config?.profile ?? 'practical';
|
|
56
|
+
const archetype = config?.archetype ?? 'application';
|
|
57
|
+
|
|
58
|
+
const staticRules = filterRulesByContract(registry, { profile, archetype });
|
|
59
|
+
|
|
60
|
+
const report = createReport({
|
|
61
|
+
higVersion: registry.version,
|
|
62
|
+
profile,
|
|
63
|
+
archetype,
|
|
64
|
+
framework: config?.framework?.name ?? null,
|
|
65
|
+
findings: [],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log(printTerminalReport(report));
|
|
69
|
+
console.log(`Applicable static rules: ${staticRules.length}`);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
### Registry
|
|
77
|
+
|
|
78
|
+
| Export | Description |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `resolveHigRoot(startDir?)` | Find directory containing `rules/registry.yaml` |
|
|
81
|
+
| `loadRegistry(higRoot)` | Load parsed registry (`version`, `rules` Map) |
|
|
82
|
+
| `parseRegistryYaml(string)` | Parse registry YAML text |
|
|
83
|
+
| `filterRulesByContract(registry, { profile, archetype })` | Rules with `static` evaluation for profile + archetype |
|
|
84
|
+
|
|
85
|
+
**Profiles:** `quick` · `practical` · `full`
|
|
86
|
+
**Archetypes:** `content` · `commerce` · `application` · `auth`
|
|
87
|
+
|
|
88
|
+
### Project contract
|
|
89
|
+
|
|
90
|
+
| Export | Description |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `loadProjectConfig(cwd, fileName?)` | Parse `web-hig.yaml` (default name) |
|
|
93
|
+
| `defaultProjectConfig(higVersion)` | Defaults when no config file exists |
|
|
94
|
+
|
|
95
|
+
See [web-hig.example.yaml](https://github.com/frozonfreak/hig/blob/main/examples/web-hig.example.yaml).
|
|
96
|
+
|
|
97
|
+
### Reports (Layer 8 / evaluator)
|
|
98
|
+
|
|
99
|
+
| Export | Description |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| `createReport({ higVersion, profile, archetype, framework, findings })` | Report object with `severity_counts` |
|
|
102
|
+
| `printTerminalReport(report)` | Human-readable summary |
|
|
103
|
+
| `severityBucketForRule(severity)` | Maps `error` → `blocking`, `warning` → `warnings`, `info` → `observations` |
|
|
104
|
+
|
|
105
|
+
Finding shape aligns with [EVALUATOR.md](https://github.com/frozonfreak/hig/blob/main/EVALUATOR.md):
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"rule_id": "HIG-MOT-001",
|
|
110
|
+
"dimension": "motion",
|
|
111
|
+
"severity_bucket": "blocking",
|
|
112
|
+
"message": "Application CSS uses transition: all.",
|
|
113
|
+
"location": "src/app.css:12",
|
|
114
|
+
"evaluation": "static"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Rule metadata
|
|
121
|
+
|
|
122
|
+
Each registry entry includes:
|
|
123
|
+
|
|
124
|
+
- `severity` — `error` | `warning` | `info`
|
|
125
|
+
- `requirement` — short normative summary
|
|
126
|
+
- `profiles`, `archetypes`, `evaluation` — applicability
|
|
127
|
+
- `autofix` — `safe` | `unsafe` | `none`
|
|
128
|
+
- `module`, `hig_section` — links into the spec
|
|
129
|
+
- `eslint_rule` — planned linter id (when present)
|
|
130
|
+
|
|
131
|
+
Normative source: [HIG.md](https://github.com/frozonfreak/hig/blob/main/HIG.md) · Registry: [rules/registry.yaml](https://github.com/frozonfreak/hig/blob/main/rules/registry.yaml)
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Related packages
|
|
136
|
+
|
|
137
|
+
| Package | Role |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| [`@web-hig/cli`](../cli/) | `web-hig check`, `explain`, `init` |
|
|
140
|
+
| [`@web-hig/install`](../install/) | Pin HIG docs and agent rules into your repo |
|
|
141
|
+
|
|
142
|
+
Architecture: [NPM-TOOLING.md](https://github.com/frozonfreak/hig/blob/main/NPM-TOOLING.md)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT · [The Web HIG](https://github.com/frozonfreak/hig)
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-hig/core",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.4",
|
|
4
4
|
"description": "Shared evaluator engine for The Web HIG conformance tooling",
|
|
5
|
+
"homepage": "https://github.com/frozonfreak/hig/tree/main/packages/core#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/frozonfreak/hig/issues"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"web-hig",
|
|
11
|
+
"hig",
|
|
12
|
+
"accessibility",
|
|
13
|
+
"conformance",
|
|
14
|
+
"eslint",
|
|
15
|
+
"design-system"
|
|
16
|
+
],
|
|
5
17
|
"type": "module",
|
|
6
18
|
"exports": {
|
|
7
19
|
".": "./index.mjs"
|
|
8
20
|
},
|
|
9
21
|
"files": [
|
|
22
|
+
"README.md",
|
|
10
23
|
"index.mjs",
|
|
11
24
|
"lib"
|
|
12
25
|
],
|