Migration skill census: one checker run, casts and fetch from code, scripts pass the idiomatic rules #157
Loading…
Reference in a new issue
No description provided.
Delete branch "census-skill-upgrade"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feedback from an adopter on the migration skill (
skills/safe-ts-migrate) and its census script.What was wrong (reproduced on main)
apps packages scripts), the census reportedno-optional-field1146 times wheresafe-ts check apps packages scripts --idiomaticreports 821: a type that aparseJson<T>in another part reads is exempt from that rule. It also reportedunused-code13 times wherecheckreports 83."idiomatic": truein package.json:no-swallowed-erroron thegit ls-filesfallback (catch { return undefined; }). The other findings in the feedback (unhandled-failure,no-object-dictionary,require-array-sort-compare) were already fixed by #90. The repo test linted without the idiomatic rules, so it missed this one.as-caststill counted non-casts. #90 had already fixed multi-line import/export renames. The remaining false positives were English inside strings and templates (test('… is rejected as DUPLICATE_SEQ'), a SQL migration template with-- … as JSON) and mapped-type key remaps whose[sits on the line above:raw-fetchcounted a feature pack's safefetchimported by name (import { fetch } from "@evobug_com/safe-ts-feature-browser/fetch"), and a method namedfetch(async fetch(input, init) {).module-letin test files: doesn't reproduce on main. #90 already skips test files, using the checker's definition of a test file.no-mutable-globalstill reports thoselets. The one hit left on the adopter's tree is a real moduleletin a script.What changed
census.mjsrunssafe-ts check <the dirs/files it was given> --json --idiomaticonce (.by default;--entryis still honoured). There is no more chunking or position-based deduplication, so two casts at one position ({} as never as T) count twice, ascheckreports them. The report and the JSON show the command's entries ("entries": ["apps", "packages", "scripts"])..vuefile's markup outside<script>, and theasof a key remap, including across lines. A cast inside${...}still counts.raw-fetchreads the file's named imports. If a file importsfetch(orx as fetch), its barefetch(calls aren't the global.{ fetch as safeFetch }leaves the bare name global. Method definitions are skipped.globalThis.fetch(andwindow.fetch(now count. A parameter or local variable namedfetchisn't followed (documented): such a call still counts.gitFilesusesspawnSyncand checks the exit status instead of try/catch.docs/guide/migration-skill.md, whichadoption.md's "Upgrading and bulk fixes" links to): bump every package together (with the npm lockfile /ERESOLVEnote), take the census, runsafe-ts migrate mut <dirs> --writewhen moving to 0.5+, runsafe-ts fix <rule> <dirs>(prints the diff;--writeapplies), audit''/0comparisons, reinstall the skill with--force. I checked each command againstsafe-ts --help. The docs use<version>so the examples don't go stale.What is still reported
${...}, andas unknown as/as never/as any.fetchthrough any spelling the census can see, an aliased global (const fetch = globalThis.fetch), axios and XMLHttpRequest.src/sim.tscovers string/template English (not counted), a multi-line key remap (not counted) and a template cast (counted). The newsrc/requests.tscovers an imported packfetch(not counted), a method (not counted) andglobalThis.fetch(counted).Tests
packages/safe-ts-skill/test/skill.test.ts: 11 pass.safe-ts check src --idiomatic --jsonrun, per rule and file.idiomaticand also runssafe-ts check --idiomaticoncensus.mjs,safe-ts.mjsandinstall.mjs(expects[]). Put back on main's census, it reportsno-swallowed-error.cargo nextest run -p safe_ts_core --test docs: 4 pass.npm run test:docs: builds..claude/**un-ignored),vp lint .claudeis clean.Adopter tree, before → after
safe-ts check apps packages scripts --idiomaticno-optional-fieldunused-codeas-castraw-fetchfetch)module-letOn this repo's own
packages examples docs, every hit the new census drops is a false positive: test names, a string holding an import line, fixture cases, and a packfetchimport.🤖 Generated with Claude Code