Commit b99c778
refactor(cli): remove unused exported helpers (#2046)
### Problem
Six exported helpers in `packages/cli/src/utils` are dead — each a thin
singular/prefix wrapper delegating to a plural/kept counterpart:
| file | symbol | status |
| --- | --- | --- |
| `utils/editor.ts` | `detectExistingEditor` | zero references (plural
`detectExistingEditors` is used) |
| `utils/agent.ts` | `resolveAgentTargetPath` | zero references (plural
`resolveAgentTargetPaths`) |
| `utils/agent.ts` | `selectAgentTargetPath` | zero references (plural
`selectAgentTargetPaths`) |
| `utils/agent.ts` | `detectExistingAgentTargetPath` | **test-only** —
referenced only by its own spec |
| `utils/terminal.ts` | `infoMsg` | zero references (only
`warnMsg`/`errorMsg` are used) |
| `utils/terminal.ts` | `noteMsg` | zero references |
**Why they are safe to delete (not just unreferenced):** `src/utils` is
not a public API surface — `package.json#exports` has no `./utils/*`
entry, and the public `.` entry (`index.ts`) only does `export * from
'@voidzero-dev/vite-plus-core'`. So these are internal-only.
### Fix
- Delete the six functions.
- `detectExistingAgentTargetPath` was exercised only by its own
`describe` block; its two singular assertions are migrated to the plural
`detectExistingAgentTargetPaths` (identical behaviour — the singular was
just `detectExistingAgentTargetPaths(...)?.[0]`): a one-file case now
asserts `['CLAUDE.md']`, and the symlink case still asserts `undefined`
(the plural returns `undefined` when nothing non-symlink is found).
- `rfcs/init-editor-configs.md` mentioned `selectAgentTargetPath` /
`detectExistingAgentTargetPath` in its design-analogy table; that table
now references the surviving plural functions (`selectAgentTargetPaths`
/ `detectExistingAgentTargetPaths`, mirrored by `selectEditors` /
`detectExistingEditors`) so the doc stays accurate.
- `terminal.ts`'s `info`/`note` half of the "info/note/warn/error" set
is gone, so the section comment is trimmed to the remaining
`warn`/`error`.
### Verification
```bash
# no code references remain to any removed symbol (excluding the plural forms we keep)
for s in detectExistingEditor resolveAgentTargetPath selectAgentTargetPath \
detectExistingAgentTargetPath infoMsg noteMsg; do
grep -rn "${s}\b" packages | grep -vE 'node_modules|/dist/' | grep -vE "${s}s\b"
done # → no output
pnpm exec oxlint packages/cli/src/utils/{editor,agent,terminal}.ts \
packages/cli/src/utils/__tests__/agent.spec.ts # clean
```
The migrated `detectExistingAgentTargetPaths` assertions match the
function's actual returns (`['CLAUDE.md']` for one file; `undefined` for
a symlink-only dir). Kept functions (`detectExistingEditors`,
`resolveAgentTargetPaths`, `selectAgentTargetPaths`,
`detectExistingAgentTargetPaths`, `warnMsg`, `errorMsg`) are untouched.
Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>1 parent 01360d3 commit b99c778
5 files changed
Lines changed: 10 additions & 46 deletions
File tree
- packages/cli/src/utils
- __tests__
- rfcs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
376 | 375 | | |
377 | 376 | | |
378 | 377 | | |
379 | | - | |
| 378 | + | |
380 | 379 | | |
381 | 380 | | |
382 | 381 | | |
| |||
389 | 388 | | |
390 | 389 | | |
391 | 390 | | |
392 | | - | |
| 391 | + | |
393 | 392 | | |
394 | 393 | | |
395 | 394 | | |
396 | 395 | | |
397 | 396 | | |
398 | 397 | | |
399 | | - | |
| 398 | + | |
400 | 399 | | |
401 | 400 | | |
402 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 177 | | |
191 | 178 | | |
192 | 179 | | |
| |||
203 | 190 | | |
204 | 191 | | |
205 | 192 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 193 | | |
211 | 194 | | |
212 | 195 | | |
| |||
259 | 242 | | |
260 | 243 | | |
261 | 244 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | 245 | | |
267 | 246 | | |
268 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | 276 | | |
281 | 277 | | |
282 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 40 | + | |
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
| |||
53 | 48 | | |
54 | 49 | | |
55 | 50 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
0 commit comments