feat(lint): bidirectional binding-root check for visibility predicates (ADR-0089 D3b)#2931
Merged
Merged
Conversation
…s (ADR-0089 D3b)
The `visibility-root-mislayered` rule only flagged the runtime direction
(`data.` root on a `*.view.ts` / `*.page.ts` surface). ADR-0089 D3 spells
out the check in both directions, so make it layer-aware:
- `validateVisibilityPredicates(stack, { layer })` gains an optional layer.
`'runtime'` (default) is unchanged; `'metadata'` flags a `record.`-rooted
predicate on a `*.form.ts` metadata-editing form (which binds `data`).
- Generalize the root matcher to any leading identifier and drive the
message/hint from a per-layer table.
- Export `VisibilityLayer` / `VisibilityOptions`.
Back-compat: the single-argument `os validate` / `compile` call sites keep
runtime behavior. Adds metadata-direction tests; full lint suite green
(204 passed), tsc clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R7oGohmS4pT9H73zoV6Jdb
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2900 (ADR-0089), addressing the remaining gap in D3b (#2903).
Context — what was already done vs. what this adds
The D3b lint rule (
validate-visibility-predicates) already landed with #2900: it flags deprecatedvisibleOn/visibilityaliases (with an autofix-grade rename hint) and mis-layered binding roots, is wired intoos validate/compile, and is tested. A repo-wide sweep ofpackages/+examples/is already clean (the #2900 codemod normalized all first-party sources).The one genuine gap: ADR-0089 D3 specifies the binding-root check in both directions —
— but the rule only implemented the runtime direction (
data.on a*.view.ts/*.page.tssurface). This PR adds the metadata direction.Changes
validateVisibilityPredicates(stack, { layer })gains an optionallayeroption:'runtime'(default, behavior unchanged) — flags adata.-rooted predicate on a runtime view/page surface.'metadata'— flags arecord.-rooted predicate on a*.form.tsmetadata-editing form (which bindsdata, the row under edit).foo.data/my_record.x); the message + hint are driven from a per-layer table.VisibilityLayer/VisibilityOptions.Back-compat
Fully back-compat. The
os validate/compilecall sites pass a single argument and keep the'runtime'default — correct for app views/pages, which are always runtime surfaces. The'metadata'layer is opt-in for a caller that knows it is linting a*.form.ts.Tests
Adds a
metadata layerdescribe block covering:record.flagged, canonicaldata.clean, the runtime/metadata directions being opposites, the alias check staying layer-agnostic, and themy_record.xfalse-positive guard. Full@objectstack/lintsuite green (204 passed, 2 skipped);tsc --noEmitclean. Includes aminorchangeset.Follow-ups (not in this PR)
layer: 'metadata'when linting*.form.tssources — the metadata direction is a tested rule capability here; wiring it to a live sweep of the framework's own metadata forms is a separate, small piece..strict()flip, ADR-0089 D3a: flip.strict()on view/page schemas so mis-layered visibility keys are loud errors #2902) remains the larger deferred item per the ADR's staged rollout.Related: closes part of #2903 · parent #2642 · sibling #2904 (objectui renderers, already merged via objectstack-ai/objectui#2490).
🤖 Generated with Claude Code
https://claude.ai/code/session_01R7oGohmS4pT9H73zoV6Jdb
Generated by Claude Code