Skip to content

Commit a61b8ab

Browse files
fix(lint): field/embedded-sub-fields fix names the field group that inlines the child (#36307)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XC63go34oEMBFaBgqpoDC8N)_ Fixes #36281 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:作者给「组合/重复」字段声明了子字段时,检查工具打印的修复建议以前说「建子对象并设成表格内联编辑」就能在父表单里编辑明细;现在改成「建子对象,并在父对象的字段分组里点名它」,同时说明内联方式只决定怎么编辑行。 - 为什么做:属于「检查工具的建议要和平台真实规则一致」这条线,替照着建议改元数据的作者和 AI 解决「照做之后父表单里没有明细行、子对象只是一个标签页」的问题。 - 出错会怎样:只改一句提示文字和两处测试,规则何时触发、级别和位置都不变;写错的话作者看到的仍是一句不准的建议,直接回退这个 PR 即可。 - 要你做什么:无。 ## What changes State at head `bc156e739` (one commit). - `packages/lint/src/data-model-rules.ts`: the `field/embedded-sub-fields` fix line. It said the child object plus "`inlineEdit: 'grid'` edits it inline". Since the parent-field-group rule (#35889, with #35921), a child is inlined in the parent's form only when a field group of the parent names it in `relatedList`; the FK's `inlineEdit` only picks grid or form. The line now reads: "Make the typed list a child object whose `master_detail` field points back here, name it in a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key." (193 characters, under the 200 cap.) This follows the spec text `EMBEDDED_JSON_TYPED_LIST` and the rule's `os explain` paragraph, which already name the field group. - Message text only: the rule id, severity, path and when it fires are unchanged. - `packages/lint/src/data-model-rules.fix-lines.test.ts`: the exact-text pin of this fix line is updated to the new text (it asserts the hint text, nothing else). - `packages/lint/src/data-model-rules.embedded-sub-fields.test.ts`: new top-level `describe` in the rule's existing harness file: the fix names `master_detail`, `fieldGroups[].relatedList` and "`inlineEdit` only picks how rows are edited", and no longer carries `inlineEdit: 'grid'`. - `.changeset/36281-embedded-sub-fields-hint.md`: `@objectstack/lint` patch. Read first: `packages/lint/src/data-model-rules.ts` (the one changed string, R14), then the new `describe` at the end of `data-model-rules.embedded-sub-fields.test.ts`. Two-minute check: `pnpm --filter @objectstack/lint exec vitest run src/data-model-rules.embedded-sub-fields.test.ts src/data-model-rules.fix-lines.test.ts` shows 2 files, 26 tests passed. ## Tests All readings at head `bc156e739`. <details><summary>Targeted tests, typecheck, whole lint package</summary> - `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/data-model-rules.embedded-sub-fields.test.ts src/data-model-rules.fix-lines.test.ts`: Test Files 2 passed (2), Tests 26 passed (26). - `pnpm --filter @objectstack/lint typecheck`: exit 0 (tsc --noEmit, then check:test-typecheck OK). - `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2`: Test Files 224 passed (224), Tests 9409 passed, 5 skipped (9414). </details> <details><summary>Ablation (one-time, not kept)</summary> `node scripts/ablation-replace.mjs` swapped the new second half of the fix back to "`inlineEdit: 'grid'` edits it inline": anchor 1 to 0, blob f16e42d to 1f785d0f961a. Both pins went red: "routes to `fieldGroups[].relatedList` and gives `inlineEdit` only the form factor" and "field/embedded-sub-fields: one line, whatever the type, the keys or the names" (2 failed, 24 passed). Restored: blob equals HEAD (f16e42d), `git diff HEAD` empty. Vitest reads `src/` through the relative import, so no rebuild was needed. </details> <details><summary>Gates run locally</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 63 commands for this diff. 61 exit 0 (`check:docs-transcript-drift` and `check:lean-entry-closure` after building lint and objectql; first run exit 3, prerequisite). 2 NOT MEASURED, exit 3 prerequisite: `check:dual-build-cjs-loads` (needs a full `pnpm build`; CI runs it) and `check-plugin-teardown-shape.mjs --self-test` (checker health only; needs an unshallowed clone). `--ran` reconciliation: 63 derived, 61 run, 2 NOT-MEASURED, 0 UNRUN, exit 0. </details> ## Acceptance notes - Other `inlineEdit` hits in `packages/lint/src` (non-test), left as they are: `data-model-rules.ts` doc comments near the bulk rule, the group map and R5 already say the field group, not `inlineEdit`, inlines the child; `validate-field-consumers.ts` reads `inlineEdit` only as the form factor (grid or form); `showcase-shape.fixtures.ts` sets `inlineEdit: true` on a list view, a different key. - Outside `packages/lint`, `content/docs/data-modeling/field-types.mdx` says "`inlineEdit: 'grid'` edits the rows as an inline grid on the parent's form (where a field group of the parent names the child)". It states the group condition, so it is not wrong, only ordered the old way. Not changed here (not on this card's file surface). - The pin went into the rule's existing harness file as a top-level `describe`, not a new card-named file (AGENTS.md: a new pin for a component with a shared harness goes into that file). ## Verification Local only; CI runs the full farm. Net added lines: +28 / -4 (net +24) against merge base 76cb366. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5kDGa1ViantgrfH797)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 729b642 commit a61b8ab

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/lint': patch
3+
---
4+
5+
fix(lint): the `field/embedded-sub-fields` fix names the field group that inlines the child
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The rule's fix line told the author to make the typed list a child object and that `inlineEdit: 'grid'` edits it inline. A child is inlined in its parent's form only when a field group of the parent names it in `relatedList`; the FK's `inlineEdit` picks grid or form, nothing more. An author who followed the old line got a child shown as a tab, with no lines on the parent's form. The fix now reads: make the typed list a child object whose `master_detail` field points back here, name it in a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key. When the rule fires, its id, severity and path are unchanged.

‎packages/lint/src/data-model-rules.embedded-sub-fields.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,17 @@ describe('field/embedded-sub-fields — one-line verdict, `os explain` carries t
116116
}
117117
});
118118
});
119+
120+
describe('field/embedded-sub-fields — the fix names the field group that inlines the child', () => {
121+
// A parent field group whose `relatedList` names the child places it on the
122+
// parent's form; the FK's `inlineEdit` only picks grid or form (spec
123+
// `EMBEDDED_JSON_TYPED_LIST`). A hint teaching `inlineEdit` as the switch
124+
// leaves the author a child that is only a tab.
125+
it('routes to `fieldGroups[].relatedList` and gives `inlineEdit` only the form factor', () => {
126+
const [issue] = findings(audit({ type: 'repeater', fields: SUB_ROWS }));
127+
expect(issue!.fix).toContain('`master_detail`');
128+
expect(issue!.fix).toContain('`fieldGroups[].relatedList`');
129+
expect(issue!.fix).toContain('`inlineEdit` only picks how rows are edited');
130+
expect(issue!.fix).not.toContain("inlineEdit: 'grid'");
131+
});
132+
});

‎packages/lint/src/data-model-rules.fix-lines.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ describe('[#22161] data-model-rules.ts — one remedy line per fix', () => {
178178

179179
it('field/embedded-sub-fields: one line, whatever the type, the keys or the names', () => {
180180
const fix =
181-
'Make the typed list a child object whose `master_detail` field points back here ' +
182-
"(`inlineEdit: 'grid'` edits it inline), and remove the key.";
181+
'Make the typed list a child object whose `master_detail` field points back here, name it in ' +
182+
'a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key.';
183183
for (const type of ['repeater', 'composite']) {
184184
const objects = [
185185
{

‎packages/lint/src/data-model-rules.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,8 @@ export function lintDataModel(objects: any[]): LintIssue[] {
11141114
`object-level ${type} is untyped JSON with no sub-fields`,
11151115
path: `${fieldPath}.${declared[0]}`,
11161116
fix:
1117-
'Make the typed list a child object whose `master_detail` field points back here ' +
1118-
"(`inlineEdit: 'grid'` edits it inline), and remove the key.",
1117+
'Make the typed list a child object whose `master_detail` field points back here, name it in ' +
1118+
'a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key.',
11191119
});
11201120
}
11211121
}

0 commit comments

Comments
 (0)