|
| 1 | +--- |
| 2 | +"@objectstack/lint": patch |
| 3 | +--- |
| 4 | + |
| 5 | +fix(lint): `lintDataModel` reads only the canonical `reference` target (#13250) |
| 6 | + |
| 7 | +`refOf` in `packages/lint/src/data-model-rules.ts` resolved |
| 8 | +`def?.reference || def?.reference_to`, so a relationship field spelled with the |
| 9 | +rejected alias resolved a target. #11567 settled that `reference` is the only |
| 10 | +relationship spelling `@objectstack/spec` declares — `FieldSchema` answers |
| 11 | +`reference_to` with `unrecognized_keys` and *"Did you mean `reference_to` → |
| 12 | +`reference`?"* — and put it as "one key, one answer, on both doors". |
| 13 | + |
| 14 | +`@objectstack/lint` runs over an in-memory, schema-parsed stack, so the alias |
| 15 | +cannot legitimately appear here at all: the tolerance was inert. Where it did |
| 16 | +fire, it made the rule whose entire job is to catch a relationship with no |
| 17 | +target — `relationship/missing-reference` — report a valid target for a field |
| 18 | +that has none, i.e. the one component that exists to tell an author their |
| 19 | +metadata is wrong was the component accepting the wrong spelling. |
| 20 | + |
| 21 | +This mirrors the deliberate canonical-only narrowing already recorded in-file |
| 22 | +for `refOf` in `packages/lint/src/validate-security-posture.ts`, including its |
| 23 | +`typeof r === 'string'` guard — which also makes the declared |
| 24 | +`string | undefined` return type true, where the old `||` chain returned |
| 25 | +whatever truthy value it found (a non-string `reference` was reported as a |
| 26 | +resolved target). |
| 27 | + |
| 28 | +What changes for a consumer, only for metadata the spec already refuses: |
| 29 | +`relationship/missing-reference` (error) now fires on a relationship field |
| 30 | +whose only target spelling is `reference_to`, and the rules that need a |
| 31 | +resolved target (`relationship/master-detail-required`, `rollup/missing-summary` |
| 32 | +and the rest of the relationship family) no longer treat such a field as |
| 33 | +pointing anywhere. Canonical `reference` is untouched. |
| 34 | + |
| 35 | +Scope note: the two remaining tolerant readers named in #13250 — |
| 36 | +`packages/verify/src/derive.ts` and |
| 37 | +`packages/plugins/plugin-security/src/security-plugin.ts` — are deliberately |
| 38 | +NOT narrowed here. Both were measured to sit on populations the alias can |
| 39 | +actually reach (raw `registerObject`, which skips Zod by design, and an app |
| 40 | +config that never passes through a `define*` parse), so narrowing them is a |
| 41 | +triage call rather than a defect fix. |
0 commit comments