Skip to content

Commit e510e49

Browse files
BYKclaude
andauthored
chore(scan,dsn): trim session cruft from comment-heavy files (#810)
## Summary Cleanup pass over the `scan/` and `dsn/` modules after the grep + worker-pool stack (#791, #804, #805, #807, #797) landed. Removed comment bloat accumulated across the 6+ review cycles those PRs went through — redundant bug-history narration, repeated explanations of `ref/unref` boolean semantics, "pre-PR-N" references, and other scars that wouldn't survive a fresh-eyes read. **Net −708 LOC across 12 files. No behavior changes.** ## Per-file reductions | File | Before | After | Δ | |---|---:|---:|---:| | `src/lib/scan/worker-pool.ts` | 466 | 312 | −33% | | `src/lib/scan/grep.ts` | 985 | 712 | −28% | | `src/lib/dsn/code-scanner.ts` | 541 | 377 | −30% | | `src/lib/scan/grep-worker.js` | 153 | 114 | −25% | | `src/lib/dsn/scan-options.ts` | 70 | 52 | −26% | | `src/lib/init/tools/grep.ts` | 122 | 98 | −20% | | `src/lib/init/tools/glob.ts` | 74 | 59 | −20% | Plus minor trims in `types.ts`, `walker.ts`, `path-utils.ts`, `scan/glob.ts`, and `script/text-import-plugin.ts`. ## What was removed - Redundant explanations of `Worker.ref()` / `.unref()` boolean semantics (stated 3× in `worker-pool.ts` — kept once, on the primary ref/unref helper pair). - Multi-paragraph "earlier iteration did X, deadlocked, so we now do Y" histories — kept in git log where they belong. - "pre-PR-3" / "pre-refactor" / "previous version" narration that explained how code used to look before the current session's work. - File-header docstrings that repeated what the module structure and exports already told you. - Rationale comments for `biome-ignore`s that were already justified by adjacent context. ## What was kept - Every `biome-ignore` comment (all still justified). - Every "why" comment tied to a real gotcha (e.g., the length-change warning on case-insensitive literal prefilters, the `/g` flag cloning rationale, the pipeline-failure detector explanation). - Every JSDoc on exported functions and types. - All inline comments that explain non-obvious constraints (sandbox enforcement, cache-contract stability, etc.). ## Test plan - [x] `bunx tsc --noEmit` — clean - [x] `bun run lint` — clean (1 pre-existing markdown warning) - [x] `bun test --timeout 15000 test/lib test/commands test/types` — **5641 pass, 0 fail** - [x] `bun test test/isolated` — 138 pass - [x] `bun run bench --size large --runs 3` — no perf regression (`scan.grepFiles` 167ms, `scanCodeForDsns` 232ms — matching pre-trim numbers) - [x] `bun run build --single` — binary builds and exits cleanly on `sentry project view` from empty dir (3 consecutive runs, all exit=1) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a8bceda commit e510e49

12 files changed

Lines changed: 306 additions & 1014 deletions

File tree

script/text-import-plugin.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
/**
22
* esbuild plugin that polyfills Bun's `with { type: "text" }` import
3-
* attribute.
3+
* attribute (esbuild only supports `json`). Intercepts matching
4+
* imports, reads the file, and default-exports its contents as a
5+
* string. Runtime behavior matches Bun's native handling.
46
*
5-
* esbuild doesn't natively support the `text` import attribute (only
6-
* `json`), but Bun does. Our CLI code uses it to load the grep worker
7-
* source as a string at bundle time (see
8-
* `src/lib/scan/worker-pool.ts`). Without this plugin, esbuild errors
9-
* with `Importing with a type attribute of "text" is not supported`
10-
* on any file that imports a sibling `.js` as text.
11-
*
12-
* The plugin intercepts imports whose `with` attribute matches
13-
* `{ type: "text" }`, reads the file from disk, and emits it as a JS
14-
* module that default-exports the file's contents as a string.
15-
* Runtime behavior matches Bun's native handling, so the same source
16-
* works in dev (via `bun run`) and in compiled binaries (esbuild +
17-
* `bun build --compile` two-step).
18-
*
19-
* Used by both `script/build.ts` (single-file executable) and
20-
* `script/bundle.ts` (CJS library bundle for npm).
7+
* Used by `script/build.ts` (single-file executable) and
8+
* `script/bundle.ts` (CJS library bundle) so the grep-worker source
9+
* in `src/lib/scan/worker-pool.ts` loads correctly in both dev and
10+
* compiled builds.
2111
*/
2212

2313
import { readFileSync } from "node:fs";
2414
import { resolve as resolvePath } from "node:path";
2515
import type { Plugin } from "esbuild";
2616

2717
const TEXT_IMPORT_NS = "text-import";
28-
/** Match-any filter for esbuild's plugin API. Hoisted for top-level-regex lint. */
2918
const ANY_FILTER = /.*/;
3019

3120
export const textImportPlugin: Plugin = {

0 commit comments

Comments
 (0)