Skip to content

refactor: delete scripts/ and the duplicate lib/linemap.ts - #315

Merged
nownabe merged 2 commits into
mainfrom
refactor/297-delete-scripts-linemap
Sep 20, 2026
Merged

nownabe merged 2 commits into
mainfrom
refactor/297-delete-scripts-linemap

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

Two pieces of the tree had no consumers and only cost maintenance:

  • scripts/check-metadata.ts, scripts/check-suggest.ts, scripts/check-suggestion.ts were manual one-off checks never wired into package.json, CI or docs. What they assert is already covered by tests/suggest.test.ts, tests/github.test.ts and tests/pr/metadata.test.ts, so they could only drift against the modules they poke at (two of them still import the v1 codec slated for removal in [Refactor] Remove the dead resolve-event path and the v1 metadata codec #298).
  • lib/linemap.ts was a second LCS buildLineMap with the same contract as lib/pr/linemap.ts. Production imports only lib/pr/linemap (via lib/pr/reanchor.ts and lib/suggest.ts); the copy was reachable from its own test alone. Two implementations of one contract silently diverge — and the trailing-newline convention that lib/anchor.buildLineIndex depends on is exactly the kind of thing that drifts.

What

  • git rm -r scripts/ (144 lines).
  • Deleted lib/linemap.ts + tests/linemap.test.ts (104 lines), after porting the trailing-newline convention case into tests/pr/linemap.test.ts.
  • Dropped the stray biome-ignore comment in lib/pr/linemap.ts — the repo lints with oxlint, so it directed nothing.

249 lines removed, 9 added.

Deletion safety

Grepped the whole tree (excluding node_modules/.git) for scripts/check, check-metadata, check-suggest, check-suggestion: three hits, all inside the scripts' own // Run: header comments. package.json, .github/workflows/*, README.md, AGENTS.md and docs/ have none. Importers of the top-level lib/linemap: exactly tests/linemap.test.ts:2. There is no @/lib alias and no lib/index.ts barrel, so no indirect path existed.

Test evidence

The ported case as written in tests/linemap.test.ts:47-52 passes against lib/pr/linemap.ts unchanged — both implementations split on "\n" identically. That makes it a green-on-arrival test, so I checked it actually has teeth by mutating lib/pr/linemap.ts to strip a trailing newline before splitting:

(fail) linemap > treats a trailing newline as a final (empty) line, matching buildLineIndex
error: expect(received).toBe(expected)  Expected: 4  Received: undefined
  at tests/pr/linemap.test.ts:58

The original assertions (a → 2, b → 3) survived that mutation untouched — they never tested the convention. The ported test therefore also asserts that the trailing empty line maps (map.get(3) === 4), which is the assertion that fails when the convention changes. Mutation reverted; suite green.

Checks

bun run test 689 pass / 0 fail (61 files, down from 695/62 — the 6 dropped are the deleted tests/linemap.test.ts), check:lint clean, check:format clean, bun run build OK.

bun run typecheck fails on tests/AppSubmitFailure.test.tsx:81,105 (Property 'setIssueThreadResolved' is missing ... in type 'Transport'). This is pre-existing on main at 7e0ecb9 and unrelated to this PR: that file was last touched by #307 and #310 later added setIssueThreadResolved to Transport without updating its two mock transports. This PR touches neither file. It needs its own fix.

Closes #297

@nownabe

nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

The red typecheck is the pre-existing main breakage; fixed in #317. Merge #317 first, then rebase or re-run CI here.

nownabe added a commit that referenced this pull request Sep 20, 2026
…317)

## Why

`bun run typecheck` is red on `main` since #310 merged: it added
`setIssueThreadResolved` to the `Transport` interface, while
`tests/AppSubmitFailure.test.tsx` (added by #307, which branched before
#310) still builds two `Transport` mocks without it. Every open PR's CI
inherits the failure.

## What

Add a `setIssueThreadResolved` stub (`{ ok: true }`) to
`failingTransport()` and `happyTransport()` in
`tests/AppSubmitFailure.test.tsx`. No behaviour change; the five tests
in that file still pass.

Checks: `typecheck` clean, `test tests/AppSubmitFailure.test.tsx` 5
pass, `check:lint` and `check:format` clean.

Merge this first so the CI of #315 and the other open PRs goes green.
@nownabe
nownabe force-pushed the refactor/297-delete-scripts-linemap branch from 4c99277 to 1848277 Compare September 20, 2026 06:34
These three scripts were never wired into package.json, CI or docs, and their assertions are already covered by tests/suggest.test.ts, tests/github.test.ts and tests/pr/metadata.test.ts. Keeping them only invites drift against the modules they poke at.
lib/linemap.ts was a second LCS line map with the same contract as lib/pr/linemap.ts; production only ever imported the latter, so the copy was reachable from its own test alone. Two implementations of the same contract can silently diverge, and the trailing-newline convention lib/anchor.buildLineIndex depends on is exactly the kind of thing that drifts.

The port of that convention test now asserts the trailing empty line maps too, so it actually fails if the split convention changes.
@nownabe
nownabe force-pushed the refactor/297-delete-scripts-linemap branch from 1848277 to 92dc2c2 Compare September 20, 2026 07:02
@nownabe
nownabe merged commit 9041fb1 into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the refactor/297-delete-scripts-linemap branch September 20, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] Delete scripts/ and the duplicate lib/linemap.ts

1 participant