Skip to content

refactor: fold the last frontmatterEnd copy into markdown-scan - #68

Merged
Bhekani Khumalo (bhekanik) merged 1 commit into
mainfrom
refactor/frontmatter-end
Aug 27, 2026
Merged

Bhekani Khumalo (bhekanik) merged 1 commit into
mainfrom
refactor/frontmatter-end

Conversation

@bhekanik

Copy link
Copy Markdown
Collaborator

What

Moves the duplicated frontmatterEnd into lib/sdk/markdown-scan.ts. Both copies are gone;
focus.ts and vault-updates.ts import it.

The comment on the vault-updates copy named its own duplicate in focus.ts and explained why it
had been left alone. That reason stopped applying when markdown-scan.ts landed.

How the two copies differed

Only in the parameter type:

-function frontmatterEnd(lines: string[]): number {          // focus.ts
+function frontmatterEnd(lines: readonly string[]): number { // vault-updates.ts

The bodies were byte-identical. The vault-updates signature is the one that moved, per the
instruction and because readonly string[] is the wider of the two; focus.ts passes a mutable
array, which satisfies it.

Verification

  • bunx tsc --noEmit clean, bun run lint clean, anti-slop-check clean on changed lines.
  • 818 tests passing before, 818 after. No test file is touched by this branch.
  • git diff --stat: 16 insertions, 27 deletions across three files.

Observation, not changed

focus.ts has its own isArchivedHeading(line), a third variant of the archived-heading test that
markdown-scan.ts now owns for the other two files. It is not a copy: it accepts levels 2-6 only
(the others accept 1-6) and matches with a \b(?:ARCHIVED|HISTORICAL)\b regex against the raw
heading text rather than against canonicalised words. Folding it in would change behaviour, so it
needs its own decision rather than a move.

The comment on the vault-updates copy named its own duplicate in focus.ts and
explained why it had been left alone. That reason no longer holds now there is a
module for exactly this.

The two copies had identical bodies. The only difference was the parameter type:
vault-updates took `readonly string[]`, focus.ts took `string[]`. The
vault-updates signature is the one that moved, being the wider of the two, and
focus.ts's callers pass a mutable array, which satisfies it.

No behaviour change. Tests untouched, 818 before and 818 after.
@bhekanik
Bhekani Khumalo (bhekanik) marked this pull request as ready for review August 27, 2026 16:49
@bhekanik
Bhekani Khumalo (bhekanik) merged commit 7374350 into main Aug 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant