Skip to content

Commit b14ab11

Browse files
committed
refactor(lint): fold the local collectionEntries copy into the #7186 helper
#7186 landed `packages/lint/src/collection-entries.ts` on main after this branch was cut. The local 15-line duplicate documented as "folds into that helper when it lands" now does — same semantics, same array/name-keyed-map handling, same walk order, so no verdict or path changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F8q5J1MQyocgtNspb15fSn
1 parent 358e8ff commit b14ab11

1 file changed

Lines changed: 1 addition & 23 deletions

File tree

packages/lint/src/validate-predicate-path-refs.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import { parseCelToAst } from '@objectstack/formula';
121121
import { getMetadataTypeSchema } from '@objectstack/spec/kernel';
122122
import { findClosestMatches, formatSuggestion } from '@objectstack/spec';
123123

124+
import { collectionEntries } from './collection-entries.js';
124125
import { formViewSites } from './view-walk.js';
125126

126127
export const PREDICATE_PATH_UNRESOLVED = 'predicate-path-unresolved';
@@ -438,29 +439,6 @@ function isRec(v: unknown): v is AnyRec {
438439
return !!v && typeof v === 'object' && !Array.isArray(v);
439440
}
440441

441-
/**
442-
* Records in a collection authored either as an array or as a name-keyed map,
443-
* each with its config PATH. Local rather than shared because the two other
444-
* copies in this package are being consolidated under #7186 — this one folds
445-
* into that helper when it lands, and duplicating it now is cheaper than
446-
* colliding with an in-flight refactor of `view-walk.ts`.
447-
*/
448-
function collectionEntries(v: unknown, base: string): Array<{ rec: AnyRec; path: string }> {
449-
if (Array.isArray(v)) {
450-
const out: Array<{ rec: AnyRec; path: string }> = [];
451-
for (let i = 0; i < v.length; i++) {
452-
if (isRec(v[i])) out.push({ rec: v[i] as AnyRec, path: `${base}[${i}]` });
453-
}
454-
return out;
455-
}
456-
if (isRec(v)) {
457-
return Object.entries(v)
458-
.filter(([, def]) => isRec(def))
459-
.map(([name, def]) => ({ rec: { name, ...(def as AnyRec) }, path: `${base}.${name}` }));
460-
}
461-
return [];
462-
}
463-
464442
/**
465443
* The `schemaId` a form view resolves its row shape from, or `undefined` when
466444
* the view is not schema-bound. Read off `ViewDataSourceSchema`'s `schema`

0 commit comments

Comments
 (0)