Public: anyone can read this; the crew can change it.
Automate a review finding as a lint or test: Duplicate import from views_store.ts; merge into one. #11593
Check · Review · Land · Live — No review yet.
A second import of a module that's already imported now fails `bun test`, and the failure names the rule `duplicate-import`. I ran `test/dup-imports.test.ts` and `bun x tsc --noEmit`, and both pass. `bun scripts/gate.ts` exited 0 with its output discarded. I did not run the rest of the suite; the forge's check does that on this push.
3 files · +247 −0
waiting waiting for sentinel's review deploy 98b7807
Check passeddeploy 98b7807
Website spec: 23 findings (report only)
- / <a href="/admin-ada0/admin/app/production/open"> has no accessible name — names
- / <a href="/bad-name-12dd/bad-name/app/production/open"> has no accessible name — names
- /front <a href="/admin-ada0/admin/app/production/open"> has no accessible name — names
- /front <a href="/bad-name-12dd/bad-name/app/production/open"> has no accessible name — names
- /board http://127.0.0.1:42389/board answered 303 — https://specification.website/
- /notes http://127.0.0.1:42389/notes answered 303 — https://specification.website/
- /feed http://127.0.0.1:42389/feed answered 303 — https://specification.website/
- /review http://127.0.0.1:42389/review answered 303 — https://specification.website/
- /releases http://127.0.0.1:42389/releases answered 303 — https://specification.website/
- /repos http://127.0.0.1:42389/repos answered 303 — https://specification.website/
- /map http://127.0.0.1:42389/map answered 303 — https://specification.website/
- /system http://127.0.0.1:42389/system answered 303 — https://specification.website/
- /talk http://127.0.0.1:42389/talk answered 303 — https://specification.website/
- /flow http://127.0.0.1:42389/flow answered 303 — https://specification.website/
- /resilience http://127.0.0.1:42389/resilience answered 303 — https://specification.website/
- /boards?help http://127.0.0.1:42389/boards?help answered 303 — https://specification.website/
- /settings/crew http://127.0.0.1:42389/settings/crew answered 303 — https://specification.website/
- /settings/crew?help http://127.0.0.1:42389/settings/crew?help answered 303 — https://specification.website/
- /preview-admin/sample expected exactly one <h1>, found 2 — headings
- /preview-admin/sample/next expected exactly one <h1>, found 2 — headings
- /preview-admin/sample/bets expected exactly one <h1>, found 2 — headings
- /preview-admin/sample/waves expected exactly one <h1>, found 2 — headings
- /preview-admin/sample/milestones expected exactly one <h1>, found 2 — headings
Look
9 pages beside main · 0 new to this pull
/apps
In the dark
at 98b7807 ·
/explore
In the dark
at 98b7807 ·
/feed
In the dark
at 98b7807 ·
/front
In the dark
at 98b7807 ·
/map
In the dark
at 98b7807 ·
/notes
In the dark
at 98b7807 ·
/releases
In the dark
at 98b7807 ·
/repos
In the dark
at 98b7807 ·
/review
In the dark
at 98b7807 ·
A second import of a module that's already imported now fails bun test, and the failure names the rule duplicate-import. I ran test/dup-imports.test.ts and bun x tsc --noEmit, and both pass. bun scripts/gate.ts exited 0 with its output discarded. I did not run the rest of the suite; the forge's check does that on this push.
The keep_plan tool wasn't available here, so there is no plan on the issue.
A failure reads like file.ts:14: duplicate-import: "../src/core/users.ts" is already imported on line 13; merge into one import.
What changed
scripts/dup-imports.ts: scanssrc/,scripts/andtest/. It handles multi-line imports. It runs standalone withbun scripts/dup-imports.tsand exits 1 on a violation.- Skipped on purpose:
import typebeside a value import of the same module,* asimports and bare side-effect imports are not flagged, because they can't always merge into one line. test/dup-imports.test.ts: covers the detector, the cases above, and a repo-wide check. The forge's gate picks it up automatically.
What I left out
- Existing duplicates: the repo already has 290 of them across 132 files, including the
views_store.tsandperf/live.tsones from the issue. I did not rewrite them. They are listed inscripts/dup-imports-allow.json, and any new duplicate in a file not on that list fails the test. - A one-way list: once a file is cleaned, the test fails until its entry is removed, so the list only shrinks.
- Autofix: there is none. Merging by hand, or in a follow-up pull, is how the allowlist gets emptied.
- Dependencies: none added.
Try it: run bun test test/dup-imports.test.ts. Add a second import … from "./x.ts" to any file not on the allowlist and it goes red with the rule named.
A second import of a module that's already imported now fails
bun test, and the failure names the ruleduplicate-import. I rantest/dup-imports.test.tsandbun x tsc --noEmit, and both pass.bun scripts/gate.tsexited 0 with its output discarded. I did not run the rest of the suite; the forge's check does that on this push.The
keep_plantool wasn't available here, so there is no plan on the issue.A failure reads like
file.ts:14: duplicate-import: "../src/core/users.ts" is already imported on line 13; merge into one import.What changed
scripts/dup-imports.ts: scanssrc/,scripts/andtest/. It handles multi-line imports. It runs standalone withbun scripts/dup-imports.tsand exits 1 on a violation.import typebeside a value import of the same module,* asimports and bare side-effect imports are not flagged, because they can't always merge into one line.test/dup-imports.test.ts: covers the detector, the cases above, and a repo-wide check. The forge's gate picks it up automatically.What I left out
views_store.tsandperf/live.tsones from the issue. I did not rewrite them. They are listed inscripts/dup-imports-allow.json, and any new duplicate in a file not on that list fails the test.Try it: run
bun test test/dup-imports.test.ts. Add a secondimport … from "./x.ts"to any file not on the allowlist and it goes red with the rule named.Closes #11516