@rettangoli/check 0.0.1
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 +295 -0
- package/ROADMAP.md +175 -0
- package/package.json +46 -0
- package/src/cli/bin.js +325 -0
- package/src/cli/check.js +232 -0
- package/src/cli/index.js +1 -0
- package/src/core/analyze.js +227 -0
- package/src/core/discovery.js +83 -0
- package/src/core/exportedFunctions.js +235 -0
- package/src/core/model.js +898 -0
- package/src/core/parsers.js +2726 -0
- package/src/core/registry.js +779 -0
- package/src/core/schema.js +161 -0
- package/src/core/scopeGraph.js +1400 -0
- package/src/core/semantic.js +329 -0
- package/src/diagnostics/autofix.js +191 -0
- package/src/diagnostics/catalog.js +89 -0
- package/src/index.js +2 -0
- package/src/reporters/index.js +13 -0
- package/src/reporters/json.js +42 -0
- package/src/reporters/sarif.js +213 -0
- package/src/reporters/text.js +145 -0
- package/src/rules/compatibility.js +318 -0
- package/src/rules/constants.js +22 -0
- package/src/rules/crossFileSymbols.js +108 -0
- package/src/rules/expression.js +338 -0
- package/src/rules/feParity.js +65 -0
- package/src/rules/index.js +39 -0
- package/src/rules/jempl.js +80 -0
- package/src/rules/lifecycle.js +4 -0
- package/src/rules/listenerConfig.js +556 -0
- package/src/rules/listenerSymbols.js +49 -0
- package/src/rules/methods.js +117 -0
- package/src/rules/refs.js +20 -0
- package/src/rules/schema.js +118 -0
- package/src/rules/shared.js +20 -0
- package/src/rules/yahtmlAttrs.js +238 -0
- package/src/semantic/engine.js +778 -0
- package/src/semantic/index.js +9 -0
- package/src/types/lattice.js +281 -0
- package/src/utils/case.js +9 -0
- package/src/utils/fs.js +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Rettangoli Check (Brainstorm)
|
|
2
|
+
|
|
3
|
+
> Working name: `rettangoli-check` (possible package: `@rettangoli/check`)
|
|
4
|
+
|
|
5
|
+
This package is intended to be a dedicated static analyzer for Rettangoli projects.
|
|
6
|
+
It should validate that component contracts are respected across files before runtime/build errors happen.
|
|
7
|
+
|
|
8
|
+
Execution plan: see `packages/rettangoli-check/ROADMAP.md`.
|
|
9
|
+
Loop retrospective: see `packages/rettangoli-check/LOOP_LEARNINGS.md`.
|
|
10
|
+
|
|
11
|
+
## Current Implementation Status
|
|
12
|
+
|
|
13
|
+
Implemented now:
|
|
14
|
+
|
|
15
|
+
- package + CLI entrypoint (`@rettangoli/check`, `rtgl check`)
|
|
16
|
+
- discovery and component grouping
|
|
17
|
+
- model building for YAML/JS contracts
|
|
18
|
+
- FE parity checks (schema required, forbidden view keys, legacy `.prop=` binding)
|
|
19
|
+
- schema/constants checks
|
|
20
|
+
- listener config checks
|
|
21
|
+
- strict handler naming checks (`handle*` only)
|
|
22
|
+
- cross-file symbol checks (handler/action/method existence)
|
|
23
|
+
- YAHTML attr/prop validation for template selector bindings
|
|
24
|
+
- semantic scope graph (YAHTML + Jempl + FE binding context)
|
|
25
|
+
- schema-aware expression checks (unresolved roots, invalid schema paths, boolean type mismatch)
|
|
26
|
+
- lifecycle signature checks (`handleBeforeMount`, `handleOnUpdate`)
|
|
27
|
+
- inter-component compatibility checks (required props, events, boolean prop binding type)
|
|
28
|
+
- UI primitive/component registry generation from `rettangoli-ui`
|
|
29
|
+
- reporters: `text`, `json`, `sarif`
|
|
30
|
+
- watch mode with incremental component model cache
|
|
31
|
+
- robustness harnesses: export differential + template pipeline fuzzing
|
|
32
|
+
- CI integration in `.github/workflows/ci-ui.yaml` via `bun run check:contracts`
|
|
33
|
+
|
|
34
|
+
Template parser architecture:
|
|
35
|
+
- `docs/template-analysis.md` (YAML -> Jempl -> YAHTML pipeline)
|
|
36
|
+
|
|
37
|
+
Checklist progress is tracked with `[x]/[ ]` in `packages/rettangoli-check/ROADMAP.md`.
|
|
38
|
+
|
|
39
|
+
## CLI Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# default (uses rettangoli.config.yaml fe.dirs when available)
|
|
43
|
+
rtgl check
|
|
44
|
+
|
|
45
|
+
# explicit directory
|
|
46
|
+
rtgl check --dir src/components
|
|
47
|
+
|
|
48
|
+
# JSON output
|
|
49
|
+
rtgl check --dir src/components --format json
|
|
50
|
+
|
|
51
|
+
# SARIF output
|
|
52
|
+
rtgl check --dir src/components --format sarif
|
|
53
|
+
|
|
54
|
+
# enable expression scope/type checks
|
|
55
|
+
rtgl check --dir src/components --expr
|
|
56
|
+
|
|
57
|
+
# watch mode (incremental)
|
|
58
|
+
rtgl check --watch --watch-interval-ms 500
|
|
59
|
+
|
|
60
|
+
# treat warnings as errors
|
|
61
|
+
rtgl check --warn-as-error
|
|
62
|
+
|
|
63
|
+
# run without YAHTML attr checks (contract-only mode)
|
|
64
|
+
rtgl check --dir src/components --no-yahtml
|
|
65
|
+
|
|
66
|
+
# preview safe autofixes
|
|
67
|
+
rtgl check --dir src/components --autofix-dry-run --format json
|
|
68
|
+
|
|
69
|
+
# preview safe autofixes with patch output
|
|
70
|
+
rtgl check --dir src/components --autofix-dry-run --autofix-patch --format json
|
|
71
|
+
|
|
72
|
+
# apply safe autofixes
|
|
73
|
+
rtgl check --dir src/components --autofix --autofix-min-confidence 0.95
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`rtgl-check` command surface:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# check contracts
|
|
80
|
+
rtgl-check --dir src/components --format json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
CLI contract references:
|
|
84
|
+
|
|
85
|
+
- `packages/rettangoli-check/docs/cli-contract.md`
|
|
86
|
+
- `packages/rettangoli-check/docs/semantic-compatibility-guarantees.md`
|
|
87
|
+
- `packages/rettangoli-check/docs/diagnostics-reporting-contract.md`
|
|
88
|
+
- `packages/rettangoli-check/docs/diagnostics-reference.md`
|
|
89
|
+
- `packages/rettangoli-check/docs/diagnostics-sarif-contract.md`
|
|
90
|
+
- `packages/rettangoli-check/docs/security-parser-attack-surface.md`
|
|
91
|
+
|
|
92
|
+
## JS Export Parser Backend
|
|
93
|
+
|
|
94
|
+
`rettangoli-check` now uses Oxc as the single runtime JS export extractor.
|
|
95
|
+
|
|
96
|
+
Legacy regex extraction is retained only in test parity harnesses:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bun run --cwd packages/rettangoli-check test:diff-js-exports
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Known Strict Findings (Current UI Baseline)
|
|
103
|
+
|
|
104
|
+
Current baseline is clean in strict mode:
|
|
105
|
+
|
|
106
|
+
- `packages/rettangoli-ui` contract checks pass with YAHTML enabled
|
|
107
|
+
- CI runs strict contract checks (no `--no-yahtml` bypass)
|
|
108
|
+
|
|
109
|
+
## Why this package
|
|
110
|
+
|
|
111
|
+
`@rettangoli/fe` already has a contract checker (`rtgl fe check`), but today it focuses on a small set of structural rules:
|
|
112
|
+
|
|
113
|
+
- required `.schema.yaml` per component
|
|
114
|
+
- forbidden metadata keys inside `.view.yaml`
|
|
115
|
+
- legacy `.prop=` syntax detection
|
|
116
|
+
|
|
117
|
+
That baseline is good, but many contract violations are still caught late (during build, runtime, or manually).
|
|
118
|
+
|
|
119
|
+
## What we learned from current codebase
|
|
120
|
+
|
|
121
|
+
### FE contract sources
|
|
122
|
+
|
|
123
|
+
Canonical docs are in `packages/rettangoli-fe/docs/`:
|
|
124
|
+
|
|
125
|
+
- `overview.md`
|
|
126
|
+
- `view.md`
|
|
127
|
+
- `schema.md`
|
|
128
|
+
- `store.md`
|
|
129
|
+
- `handlers.md`
|
|
130
|
+
- `methods.md`
|
|
131
|
+
- `constants.md`
|
|
132
|
+
|
|
133
|
+
### Existing FE check implementation
|
|
134
|
+
|
|
135
|
+
Main check path today:
|
|
136
|
+
|
|
137
|
+
- `packages/rettangoli-fe/src/cli/check.js`
|
|
138
|
+
- `packages/rettangoli-fe/src/cli/contracts.js`
|
|
139
|
+
- `packages/rettangoli-fe/src/core/contracts/componentFiles.js`
|
|
140
|
+
|
|
141
|
+
### Runtime/build validations that are currently not fully static
|
|
142
|
+
|
|
143
|
+
Important checks currently happen at build/runtime, not as deep static analysis:
|
|
144
|
+
|
|
145
|
+
- schema contract and methods mapping:
|
|
146
|
+
`packages/rettangoli-fe/src/core/schema/validateSchemaContract.js`
|
|
147
|
+
- listener config validation (handler/action exclusivity, modifiers, debounce/throttle):
|
|
148
|
+
`packages/rettangoli-fe/src/core/view/refs.js`
|
|
149
|
+
- action dispatch to store action name validation:
|
|
150
|
+
`packages/rettangoli-fe/src/core/runtime/lifecycle.js`
|
|
151
|
+
- build-time parse/compose of component files:
|
|
152
|
+
`packages/rettangoli-fe/src/cli/build.js`
|
|
153
|
+
|
|
154
|
+
### UI package shape
|
|
155
|
+
|
|
156
|
+
`packages/rettangoli-ui/src/components/*` consistently uses the FE multi-file model (`.view.yaml`, `.schema.yaml`, optional `.handlers.js`/`.store.js`/`.methods.js`).
|
|
157
|
+
That makes it a strong first target for static checks.
|
|
158
|
+
|
|
159
|
+
## Proposed goals for `rettangoli-check`
|
|
160
|
+
|
|
161
|
+
1. Catch contract violations earlier than runtime.
|
|
162
|
+
2. Give precise file-level diagnostics (and line-level when possible).
|
|
163
|
+
3. Separate rule engine from FE runtime, so checkers can run in CI/editor/pre-commit.
|
|
164
|
+
4. Support both human and machine output (`text`, `json`, later `sarif`).
|
|
165
|
+
|
|
166
|
+
## Rule ideas
|
|
167
|
+
|
|
168
|
+
### V1 (high value, low ambiguity)
|
|
169
|
+
|
|
170
|
+
1. File-set rules
|
|
171
|
+
- `.schema.yaml` required per component
|
|
172
|
+
- no unsupported FE file suffixes in component folders (optional strict mode)
|
|
173
|
+
|
|
174
|
+
2. Schema rules
|
|
175
|
+
- `componentName` required, non-empty, valid custom element format
|
|
176
|
+
- reject `attrsSchema`
|
|
177
|
+
- `methods` must be object schema with `properties`
|
|
178
|
+
|
|
179
|
+
3. Cross-file symbol rules
|
|
180
|
+
- `schema.methods.properties.*` must exist in `.methods.js` exports
|
|
181
|
+
- exported methods in `.methods.js` should be documented in `schema.methods` (warn-level first)
|
|
182
|
+
- `refs.*.eventListeners.*.handler` must exist in `.handlers.js`
|
|
183
|
+
- `refs.*.eventListeners.*.action` must exist in `.store.js`
|
|
184
|
+
|
|
185
|
+
4. Listener config static validation
|
|
186
|
+
- exactly one of `handler` or `action`
|
|
187
|
+
- `debounce` and `throttle` are mutually exclusive
|
|
188
|
+
- modifier types (`boolean`, non-negative number)
|
|
189
|
+
|
|
190
|
+
5. Component identity rules
|
|
191
|
+
- detect duplicate `componentName` across project
|
|
192
|
+
- optional: enforce expected mapping between folder/file base name and schema component name
|
|
193
|
+
|
|
194
|
+
6. Constants rules
|
|
195
|
+
- `.constants.yaml` root must be an object
|
|
196
|
+
|
|
197
|
+
### V2 (medium complexity)
|
|
198
|
+
|
|
199
|
+
1. Refs and ID contracts
|
|
200
|
+
- if ID refs are used, matched element IDs should satisfy camelCase constraints used by runtime
|
|
201
|
+
|
|
202
|
+
2. Store/handlers shape checks
|
|
203
|
+
- `handleBeforeMount` should not be async (or return Promise)
|
|
204
|
+
- basic export-order/lint checks for `.store.js` (if still desired as strict rule)
|
|
205
|
+
|
|
206
|
+
3. API consistency checks for UI libraries
|
|
207
|
+
- event naming conventions (`kebab-case`, suffix consistency)
|
|
208
|
+
- payload contract hints from schema vs emitted event docs (warn-level)
|
|
209
|
+
|
|
210
|
+
### V3 (advanced / optional)
|
|
211
|
+
|
|
212
|
+
1. Template expression linting and unresolved symbol checks.
|
|
213
|
+
2. Inter-component prop compatibility checks (requires component registry graph).
|
|
214
|
+
3. Autofix mode for mechanical issues.
|
|
215
|
+
|
|
216
|
+
## Architecture proposal
|
|
217
|
+
|
|
218
|
+
## 1. Core flow
|
|
219
|
+
|
|
220
|
+
1. Discover component files from configured dirs.
|
|
221
|
+
2. Parse YAML files (`js-yaml`) and JS files (AST-based, likely `@babel/parser`).
|
|
222
|
+
3. Build a component model:
|
|
223
|
+
- metadata (`category`, `component`, paths)
|
|
224
|
+
- schema model
|
|
225
|
+
- view refs/listeners model
|
|
226
|
+
- JS export indexes for store/handlers/methods
|
|
227
|
+
4. Run rule engine over model.
|
|
228
|
+
5. Format diagnostics.
|
|
229
|
+
|
|
230
|
+
## 2. Module boundaries
|
|
231
|
+
|
|
232
|
+
- `src/discovery/` file walking and grouping
|
|
233
|
+
- `src/parsers/` yaml/js/template helpers
|
|
234
|
+
- `src/model/` normalized IR for rules
|
|
235
|
+
- `src/rules/` one file per rule with code + tests
|
|
236
|
+
- `src/reporters/` text/json/sarif formatters
|
|
237
|
+
- `src/cli/` command wiring
|
|
238
|
+
|
|
239
|
+
## 3. Integration points
|
|
240
|
+
|
|
241
|
+
Short-term:
|
|
242
|
+
|
|
243
|
+
- keep `rtgl fe check` as-is
|
|
244
|
+
- add optional command path that can call new checker
|
|
245
|
+
|
|
246
|
+
Long-term:
|
|
247
|
+
|
|
248
|
+
- make `rtgl fe check` delegate to `@rettangoli/check` for FE rules
|
|
249
|
+
- allow package-specific presets (`fe`, `ui`, custom)
|
|
250
|
+
|
|
251
|
+
## Suggested CLI surface (draft)
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# full project scan from rettangoli.config.yaml
|
|
255
|
+
rtgl check
|
|
256
|
+
|
|
257
|
+
# explicit directories
|
|
258
|
+
rtgl check --dirs src/components --dirs src/pages
|
|
259
|
+
|
|
260
|
+
# output modes
|
|
261
|
+
rtgl check --format text
|
|
262
|
+
rtgl check --format json
|
|
263
|
+
rtgl check --format sarif
|
|
264
|
+
|
|
265
|
+
# rule controls
|
|
266
|
+
rtgl check --preset fe
|
|
267
|
+
rtgl check --preset ui
|
|
268
|
+
rtgl check --warn-as-error
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Minimal milestone plan
|
|
272
|
+
|
|
273
|
+
1. Bootstrap package with CLI + discovery + current FE parity rules.
|
|
274
|
+
2. Add cross-file symbol rules (handler/action/method existence).
|
|
275
|
+
3. Add duplicate component name and method-doc coverage diagnostics.
|
|
276
|
+
4. Wire into CI in `rettangoli-ui` and one example app.
|
|
277
|
+
|
|
278
|
+
## Open design questions
|
|
279
|
+
|
|
280
|
+
1. Naming: `rettangoli-check` vs `rettangoli-contracts` vs `rettangoli-lint`.
|
|
281
|
+
2. Should `rtgl fe check` remain FE-specific wrapper, or fully replaced by generic `rtgl check`?
|
|
282
|
+
3. Error code strategy:
|
|
283
|
+
- keep existing `RTGL-CONTRACT-xxx`
|
|
284
|
+
- or introduce package-specific namespaces (example: `RTGL-CHECK-FE-xxx`)
|
|
285
|
+
4. Strictness defaults:
|
|
286
|
+
- what is error vs warning in CI by default?
|
|
287
|
+
|
|
288
|
+
## Immediate next step (implementation)
|
|
289
|
+
|
|
290
|
+
Create `@rettangoli/check` with:
|
|
291
|
+
|
|
292
|
+
- package scaffolding
|
|
293
|
+
- parser/model foundation
|
|
294
|
+
- parity checks from existing `@rettangoli/fe` check
|
|
295
|
+
- at least one new high-value cross-file rule (`action` -> `.store.js` export exists)
|
package/ROADMAP.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Rettangoli Check Roadmap
|
|
2
|
+
|
|
3
|
+
This roadmap is intentionally incremental. Each step should be shippable on its own.
|
|
4
|
+
|
|
5
|
+
## Steps
|
|
6
|
+
|
|
7
|
+
- [x] 1. Lock baseline and test fixtures.
|
|
8
|
+
Deliverable: maintain scenario-based fixtures under `test/scenarios/` as the baseline contract.
|
|
9
|
+
|
|
10
|
+
- [x] 2. Scaffold package runtime.
|
|
11
|
+
Deliverable: add `package.json`, `src/index.js`, `src/cli/index.js`, and a runnable `node` CLI entry.
|
|
12
|
+
|
|
13
|
+
- [x] 3. Implement project discovery.
|
|
14
|
+
Deliverable: collect FE component groups from configured dirs (`.view.yaml`, `.schema.yaml`, `.store.js`, `.handlers.js`, `.methods.js`, `.constants.yaml`).
|
|
15
|
+
|
|
16
|
+
- [x] 4. Add normalized component model (IR).
|
|
17
|
+
Deliverable: parsed YAML/JS contracts in one in-memory model used by all rules.
|
|
18
|
+
|
|
19
|
+
- [x] 5. Port existing FE contract rules (parity mode).
|
|
20
|
+
Deliverable: equivalent behavior to current `rtgl fe check` for schema-required and forbidden view keys.
|
|
21
|
+
|
|
22
|
+
- [x] 6. Implement YAHTML selector/binding parser pass.
|
|
23
|
+
Deliverable: parse selector, attrs, `:prop`, `?bool`, control-flow lines, with stable diagnostics.
|
|
24
|
+
|
|
25
|
+
- [x] 7. Implement attr allowlist validation by tag.
|
|
26
|
+
Deliverable: unknown attr failure per tag (`rtgl-button banana=ripe` style errors), with file:line output.
|
|
27
|
+
|
|
28
|
+
- [x] 8. Build canonical UI contract registry.
|
|
29
|
+
Deliverable: registry generated from `rettangoli-ui` + FE schema contracts (tag, attrs/props, events, methods).
|
|
30
|
+
|
|
31
|
+
- [x] 9. Add cross-file symbol rules.
|
|
32
|
+
Deliverable: verify `refs.*.handler` in `.handlers.js`, `refs.*.action` in `.store.js`, and `schema.methods` vs `.methods.js` exports.
|
|
33
|
+
|
|
34
|
+
- [x] 10. Add schema and identity hard checks.
|
|
35
|
+
Deliverable: `componentName` format checks, duplicate `componentName` detection, constants root-object validation.
|
|
36
|
+
|
|
37
|
+
- [x] 11. Add reporting modes and severity controls.
|
|
38
|
+
Deliverable: `text` and `json` reporters, error/warn levels, non-zero exit on errors, optional `--warn-as-error`.
|
|
39
|
+
|
|
40
|
+
- [x] 12. Integrate with CLI and CI.
|
|
41
|
+
Deliverable: `rtgl check` command, optional `rtgl fe check` delegation path, CI job for `rettangoli-ui`.
|
|
42
|
+
|
|
43
|
+
- [x] 13. Enforce strict handler naming contract.
|
|
44
|
+
Deliverable: listener `handler` values and `.handlers.js` exports must start with `handle`.
|
|
45
|
+
|
|
46
|
+
## Exit Criteria for First Release
|
|
47
|
+
|
|
48
|
+
1. Detects invalid attrs/props in YAHTML views against registry.
|
|
49
|
+
2. Detects missing handler/action/method symbols across files.
|
|
50
|
+
3. Maintains compatibility with current FE contract checks.
|
|
51
|
+
4. Provides stable error codes and machine-readable JSON output.
|
|
52
|
+
|
|
53
|
+
## Next Phase: Oxc Parser Migration
|
|
54
|
+
|
|
55
|
+
- [x] A. Add `oxc-parser` as JS parsing backend.
|
|
56
|
+
Deliverable: parser abstraction in `src/core/parsers.js` with Oxc-based extraction.
|
|
57
|
+
|
|
58
|
+
- [x] B. Implement AST-based export extraction with Oxc.
|
|
59
|
+
Deliverable: robust handling for named exports, aliases, multi-declarator exports, and default-export detection.
|
|
60
|
+
|
|
61
|
+
- [x] C. Run dual-mode parity checks (`legacy-regex` vs `oxc`) in scenario tests.
|
|
62
|
+
Deliverable: no behavior regressions on existing scenarios; mismatches reported as test failures.
|
|
63
|
+
|
|
64
|
+
- [x] D. Expand scenario coverage for JS export edge cases before cutover.
|
|
65
|
+
Deliverable: dedicated scenarios for complex export syntaxes and commented/dead code cases.
|
|
66
|
+
|
|
67
|
+
- [x] E. Switch default extractor to Oxc after parity is proven.
|
|
68
|
+
Deliverable: `oxc` default enabled.
|
|
69
|
+
|
|
70
|
+
- [x] F. Remove legacy regex extractor once stable.
|
|
71
|
+
Deliverable: single AST-based runtime path with Oxc; legacy regex kept only in test parity harness.
|
|
72
|
+
|
|
73
|
+
## Mid-Term Priorities (Compiler-Grade)
|
|
74
|
+
|
|
75
|
+
These are the next large workstreams to move from rule-checker quality to compiler-grade static analysis.
|
|
76
|
+
|
|
77
|
+
- [ ] 1. Build a typed YAHTML AST + parser pipeline.
|
|
78
|
+
Deliverable: replace line-heuristic parsing with an explicit YAHTML AST, node kinds, and stable source ranges (line+column+offset).
|
|
79
|
+
|
|
80
|
+
- [x] 2. Build semantic analysis passes (symbol table + scope graph).
|
|
81
|
+
Deliverable: resolve refs, handlers, actions, methods, constants, and template expression symbols across component files.
|
|
82
|
+
|
|
83
|
+
- [x] 3. Add static lifecycle and handler contract validation.
|
|
84
|
+
Deliverable: enforce lifecycle semantics (`handleBeforeMount` sync-only, known lifecycle names), handler signatures, and payload shape checks.
|
|
85
|
+
|
|
86
|
+
- [x] 4. Add schema-aware expression/type checking.
|
|
87
|
+
Deliverable: validate `${...}` and listener payload expressions against schema props/method signatures/constants with precise diagnostics.
|
|
88
|
+
|
|
89
|
+
- [x] 5. Add inter-component contract compatibility checks.
|
|
90
|
+
Deliverable: validate parent-to-child prop/event/method compatibility using a project component graph and merged registry.
|
|
91
|
+
|
|
92
|
+
- [ ] 6. Add diagnostic quality upgrades.
|
|
93
|
+
Deliverable: attach rule category + machine-safe metadata to every diagnostic and provide consistent codeframes/ranges.
|
|
94
|
+
|
|
95
|
+
- [x] 7. Add compiler-grade reporter outputs.
|
|
96
|
+
Deliverable: add SARIF output and keep deterministic JSON contracts for CI, code scanning, and editor integrations.
|
|
97
|
+
|
|
98
|
+
- [x] 8. Add incremental engine + watch mode.
|
|
99
|
+
Deliverable: file graph cache, invalidation model, and fast incremental re-checks for local development.
|
|
100
|
+
|
|
101
|
+
- [x] 9. Add robustness testing strategy (fuzz + differential).
|
|
102
|
+
Deliverable: fuzz YAHTML/JS inputs and differential tests against FE runtime/build outcomes to detect semantic drift.
|
|
103
|
+
|
|
104
|
+
- [x] 10. Tighten CI enforcement to strict mode.
|
|
105
|
+
Deliverable: remove temporary `--no-yahtml` path once baseline issues are fixed and enforce strict contracts in all main pipelines.
|
|
106
|
+
|
|
107
|
+
## Next Execution Order (Recommended)
|
|
108
|
+
|
|
109
|
+
- [x] A. Implement Oxc parity harness in scenario runner (dual-backend assertion).
|
|
110
|
+
- [x] B. Add 15-20 export-edge scenarios (re-exports, type-only exports, default forms, parse-failure fallback).
|
|
111
|
+
- [x] C. Start YAHTML AST foundation (parser + node model + source ranges).
|
|
112
|
+
- [x] D. Add lifecycle/handler semantic rules on top of the new AST/IR.
|
|
113
|
+
|
|
114
|
+
## Compiler-Grade Program Roadmap (Phased)
|
|
115
|
+
|
|
116
|
+
Goal: move from "strong rule checker" to "deterministic compiler-grade analyzer" with precise source mapping, semantic passes, and CI-grade outputs.
|
|
117
|
+
|
|
118
|
+
### Phase 1: Stabilize strict baseline (high value, low risk)
|
|
119
|
+
|
|
120
|
+
- [x] P1.1 Remove temporary `--no-yahtml` CI bypass after fixing current strict UI findings.
|
|
121
|
+
Deliverable: strict YAHTML attr/prop checks are always enforced in CI for UI packages.
|
|
122
|
+
|
|
123
|
+
- [x] P1.2 Complete Oxc migration hardening.
|
|
124
|
+
Deliverable: parity harness (`legacy-regex` vs `oxc`) + export edge-case scenarios + legacy regex runtime path removed.
|
|
125
|
+
|
|
126
|
+
- [x] P1.3 Add deterministic diagnostics contract tests.
|
|
127
|
+
Deliverable: snapshot-style checks for code/severity/message/file/line stability.
|
|
128
|
+
|
|
129
|
+
### Phase 2: Parser and semantic foundation (compiler core)
|
|
130
|
+
|
|
131
|
+
- [x] P2.1 Introduce typed YAHTML AST with source ranges.
|
|
132
|
+
Deliverable: node kinds + stable `line:column:offset` for selector/attr/binding nodes.
|
|
133
|
+
|
|
134
|
+
- [x] P2.2 Build semantic IR and scope graph across FE + Jempl + template scopes.
|
|
135
|
+
Deliverable: resolvable symbols for refs, handlers, actions, methods, constants, loop variables, and branch scopes.
|
|
136
|
+
|
|
137
|
+
- [x] P2.3 Add expression analyzer for `${...}` and listener payload expressions.
|
|
138
|
+
Deliverable: unresolved-symbol and invalid-path diagnostics with precise ranges.
|
|
139
|
+
|
|
140
|
+
### Phase 3: Type and contract reasoning
|
|
141
|
+
|
|
142
|
+
- [x] P3.1 Schema-aware expression/type checking.
|
|
143
|
+
Deliverable: expression values validated against schema props/method contracts and constants shapes.
|
|
144
|
+
|
|
145
|
+
- [x] P3.2 Lifecycle and handler semantic checks.
|
|
146
|
+
Deliverable: enforce lifecycle semantics (sync/async constraints, naming contracts, payload shape expectations).
|
|
147
|
+
|
|
148
|
+
- [x] P3.3 Inter-component compatibility graph checks.
|
|
149
|
+
Deliverable: parent->child prop/event/method compatibility validation using project registry graph.
|
|
150
|
+
|
|
151
|
+
### Phase 4: Compiler UX and scale
|
|
152
|
+
|
|
153
|
+
- [x] P4.1 Compiler-grade reporter outputs.
|
|
154
|
+
Deliverable: SARIF + deterministic JSON contracts + improved text codeframes.
|
|
155
|
+
|
|
156
|
+
- [x] P4.2 Incremental engine and watch mode.
|
|
157
|
+
Deliverable: dependency graph cache + invalidation strategy for fast local re-checks.
|
|
158
|
+
|
|
159
|
+
- [x] P4.3 Robustness program (fuzz + differential testing).
|
|
160
|
+
Deliverable: fuzz YAHTML/Jempl inputs and compare checker findings against FE runtime/build outcomes.
|
|
161
|
+
|
|
162
|
+
## Planned 10-Iteration Loop Track (Immediate)
|
|
163
|
+
|
|
164
|
+
This track is designed for the next Codex loop run (`gpt-5.3-codex`, high reasoning effort).
|
|
165
|
+
|
|
166
|
+
- [x] I01. Add Oxc parity harness in scenario runner and baseline it on current scenarios.
|
|
167
|
+
- [x] I02. Add first export-edge scenario pack (re-export, alias, default forms).
|
|
168
|
+
- [x] I03. Add second export-edge scenario pack (commented/dead code/type-only-like patterns).
|
|
169
|
+
- [x] I04. Remove one regex-only branch proven redundant by parity + tests.
|
|
170
|
+
- [x] I05. Add YAHTML AST node model draft and fixture tests (no rule migration yet).
|
|
171
|
+
- [x] I06. Add source-range plumbing (`line:column`) for selector/binding diagnostics.
|
|
172
|
+
- [x] I07. Add semantic symbol table pass for handlers/actions/methods/constants.
|
|
173
|
+
- [x] I08. Add first unresolved-symbol rule for template expressions.
|
|
174
|
+
- [x] I09. Add deterministic diagnostics contract/snapshot tests.
|
|
175
|
+
- [x] I10. Add SARIF reporter foundation with one scenario-backed contract.
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rettangoli/check",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Static contract checker for Rettangoli projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js",
|
|
9
|
+
"./cli": "./src/cli/index.js"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"rtgl-check": "./src/cli/bin.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test:scenarios": "node ./test/run-scenarios.js",
|
|
16
|
+
"test:diff-js-exports": "node ./scripts/differential-js-exports.js",
|
|
17
|
+
"test:fuzz-template-pipeline": "node ./scripts/fuzz-template-pipeline.js",
|
|
18
|
+
"test:fuzz-jempl-parser": "node ./scripts/fuzz-jempl-parser.js",
|
|
19
|
+
"test:jempl-parser-contract": "node ./scripts/test-jempl-parser-contract.js",
|
|
20
|
+
"test:scope-graph-range-contract": "node ./scripts/test-scope-graph-range-contract.js",
|
|
21
|
+
"test:fe-frontend-component-identity-contract": "node ./scripts/test-fe-frontend-component-identity-contract.js",
|
|
22
|
+
"test:fe-frontend-handler-contract": "node ./scripts/test-fe-frontend-handler-contract.js",
|
|
23
|
+
"test:fe-frontend-lifecycle-contract": "node ./scripts/test-fe-frontend-lifecycle-contract.js",
|
|
24
|
+
"test:fe-frontend-oxc-contract": "node ./scripts/test-fe-frontend-oxc-contract.js",
|
|
25
|
+
"test:fe-frontend-schema-normalization-contract": "node ./scripts/test-fe-frontend-schema-normalization-contract.js",
|
|
26
|
+
"test:semantic-engine-contract": "node ./scripts/test-semantic-engine-contract.js",
|
|
27
|
+
"test:type-system-contract": "node ./scripts/test-type-system-contract.js",
|
|
28
|
+
"test:yahtml-parser-snapshots": "node ./scripts/test-yahtml-parser-snapshots.js",
|
|
29
|
+
"test:yahtml-parser-crash": "node ./scripts/test-yahtml-parser-crash-containment.js",
|
|
30
|
+
"test:fuzz-yahtml-parser": "node ./scripts/fuzz-yahtml-parser.js",
|
|
31
|
+
"test:fuzz-fe-contract-combinations": "node ./scripts/fuzz-fe-contract-combinations.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"README.md",
|
|
36
|
+
"ROADMAP.md"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@rettangoli/fe": "workspace:1.0.0-rc3",
|
|
41
|
+
"jempl": "0.3.2-rc2",
|
|
42
|
+
"js-yaml": "^4.1.0",
|
|
43
|
+
"oxc-parser": "^0.112.0",
|
|
44
|
+
"yahtml": "0.0.5"
|
|
45
|
+
}
|
|
46
|
+
}
|