Migration skill: scripts pass the lint preset, census precision, an upgrade path #90
Loading…
Reference in a new issue
No description provided.
Delete branch "skill-upgrade-and-census"
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?
Problem
An adopter upgraded a 729-file project from 0.3.0 to 0.4.0 and reported four problems with the migration skill:
.claude/skills/safe-ts-migrate/scripts/census.mjs:unhandled-failure(onreadFileSync,statSync,JSON.parseandnew RegExp),no-object-dictionary×9, and a sort without a comparator. They had to exclude.claude/**from lint.as-castcounted renames. Most of the 42 hits were renames in import lists that span several lines (type Building as SimBuilding,) and mapped-type key remapping ([E in AdminEvent as E['type']]).module-letandminus-one-sentinelwere noisy. 85 of the 86module-lethits were test files'let errorsthatbeforeEachresets.minus-one-sentinelcouldn't tell a named index sentinel (const NONE = -1, used in typed arrays) from "not found".npm installstopped withERESOLVE.Solution
census.mjsandinstall.mjsnow pass oxlint with the preset (safe-ts.mjsalready did). The test also turns on the Node pack, which is wherereadFileSyncandstatSyncget reported.orExit(what, step). It printscensus: <what failed>: <why>and exits 2.Maps (aCountsclass); the JSON report and the baseline format don't change. Every sort has a comparator.NaN.SKILL.mdis next toscripts/, so a copy in the project'sscripts/doesn't exclude the project).as-cast/double-cast:import {/export {/export type {list that spans several lines are skipped.export const x = {doesn't count as a list.asof[K in Keys as NewKey]is removed from the line before matching.module-letskips test files. I chose skipping over a separate count. A test file is what the checker calls one:*.test.*/*.spec.*, in atest,tests,__tests__or__mocks__folder, or importing a test runner. Each test file is its own module, so itsletisn't state the app shares, and the checker'sno-mutable-globalstill reports it. Documented inreferences/census.md.minus-one-sentinel:export const,static readonly, a type annotation, oras const(the last two weren't counted at all before).=== NONE,.fill(NONE)) aren't counted.-1that means the same thing still counts, and that is the place to fix.references/census.md.SKILL.md(after Workflow; its description now also says "upgrade") and as a section at the end ofdocs/guide/migration-skill.md.@evobug_compackage together, then take the census. Apply fixes one rule at a time and review each, with thestrict-truthiness/x?: string/x !== ''case spelled out. Audit''and0comparisons. Reinstall the skill with--force.ERESOLVEremedy: install all the packages in onenpm install [email protected] [email protected] …(npm keeps each in its current dependency field), or drop their lockfile entries.safe-ts fix <rule>is mentioned only as "if your version has it".^0.4.0already means>=0.4.0 <0.5.0for 0.x, which is right for packages released together. TheERESOLVEcame from the lockfile still holding an old version, not from the ranges.I kept clear of the spots PR #89 edits: the top of "Rules for the whole migration", workflow step 5, the references table, review-checklist, templates, and step 5 and the file table of migration-skill.md. CHANGELOG will probably need a small merge under Unreleased. The
string-if-chainpattern is unchanged.Testing
node --test --import ./packages/safe-ts-transform/register.mjs packages/safe-ts-skill/test/skill.test.ts: 10 pass. New tests:oxlint --deny-warnings: clean. A plantedreadFileSyncin the same folder is reported, which shows the run really lints the files..tsfile put inside the skill's folder."two", gives acensus: …message and exit 2.src/sim.ts: renames in a multi-line import and export list, a mapped-type remap, andconst NONE = -1with.fill(NONE)/=== NONE.user.spec.tsgets a top-levellet. Pattern counts asserted.sim.tsand the spec file'slet; the new one counts none of them.packages examples docs. Onlyas-cast(219 → 213) andmodule-let(15 → 5) changed. Each place removed is a rename, a mapped-type remap, or a file under a test folder. Feature counts are the same.npm run test:std: 370 pass.cargo nextest run -p safe_ts_core --test docs: 3 pass.node scripts/docs-typecheck.mjs: 605 examples compile.npm run test:docs).Left out
typescript/require-array-sort-comparerule needs oxlint's type-aware mode. I didn't run that mode; instead every sort in the scripts has a comparator.oxlint --fix -A all -D safe-ts/<rule>doesn't turn off the plugin's other rules, and thatstrict-truthinesshas no autofix, so--fixdoesn't apply it. The upgrade steps point to the editor's quick fixes orsafe-ts fix <rule>instead. That command belongs to the other lane.Created with Claude Opus 5.5 in Claude Code.
63c867bc2a7bb9e271eb