unbounded-spread through tuple aliases, code-range-compare skips tables of measures, prototype patches through imported helpers, stable-shape once per literal #161
Loading…
Reference in a new issue
No description provided.
Delete branch "spread-range-patch"
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?
Four small items from an adopter's feedback on 0.5.1. Each has its own commit, fixtures, docs and CHANGELOG line.
1.
unbounded-spread: a tuple type named by an aliasWas wrong: a tuple without a rest element has a fixed length, but the rule only recognised one written in place.
Changed:
known_lengthis now a three-wayLength(known, unknown, or known if certain imported types are fixed tuples). It follows type aliases of the same file,Readonly<...>, unions of tuples (ignoring| undefined), and labelled and optional elements. It also readsa ?? b,c ? a : bandv!of such lists. Imported aliases go to the whole-program pass: each file records itstuple_aliases, the finding becomes aSitewithlists, andRun::project_fixed_tuplefollows re-exports and aliases of aliases across files.Still reported:
[number, ...number[]],type Wrapped<T> = Tused asWrapped<number[]>, a union with an array, and[...v, ...rest]. Fixtures:unbounded_spread/tuples.ts,tuple_types.ts,tuple_reexport.ts.2.
code-range-compare: tables of tuning numbers (sound part only)Was wrong:
const SHAKE = Object.freeze({ px: 7, ms: 650, reach: 1.5 }); elapsed > SHAKE.mswas reported as picking members by their codes.Changed: codes are whole numbers (places in a list). A table with a value that isn't a whole number holds measures, so the rule skips it. Docs and README now say "code object of whole numbers".
Still reported: any table of whole numbers, including hand-written code tables with gaps (fixtures
Step,Gappedinclosed_set_guards/main.ts). Tuning tables that hold only whole numbers are also still reported. That includes the adopter's own probeObject.freeze({ ms: 300, maxRange: 12 }): I found no sound way to tell those from codes. Options are listed below.Adopter tree, before → after: 139 → 114. All 25 that disappear are tuning tables (camera shake, procedural atlas metrics, smoke, grass LOD, tree shake, snow prints, object contact, a house-art layout table, fire light). Every one has a fraction among its values. No code table disappears: PHASE ×54, LifeStage ×45, PanicStage, Weather, SimError, PileState, GriefTie, GriefStage, FieldStage and BuildingKind are all still reported. Two tuning tables of whole numbers are still reported (4 findings).
3.
no-foreign-prototype-patch: helper imported from another fileWas wrong:
patchMethod(HTMLElement.prototype, "glow", ...)was reported only whenpatchMethodwas declared in the same file. The docs said so.Changed: each file records what its top-level functions do with their parameters (
lifetime::patch_helpers): which ones they patch, and which they hand to another function of the file or an imported one. A call that hands a foreign prototype to an imported function (or to a local one that hands it on) becomes aPatchCall. The whole-program pass resolves it (Run::patching_params) by name, as a namespace member, as the default export, through re-exports, and through chains across files. It also followsconstcopies, plain and destructured. Ano-mutable-globalfinding on the same call is dropped, as the file's own pass already does. Docs sentence updated (rule page, guidestate.md, README).Still reported / still silent: a helper that only reads its parameter, an argument the helper doesn't patch, and the module's own class (
no-mutable-global's) — fixturelifetime/imported.tswithpatchers*.ts.Adopter tree: 18 → 25. The 7 new findings are all real: pixi prototypes patched through an imported
pixiPatchhelper.4.
stable-shape: one finding per literalWas wrong: a literal with three conditional spreads gave the same finding three times, once at each spread.
Changed: one finding per literal, at its first conditional spread. Where the message is the spread's own, it adds how many spreads the literal has. The fixture harness compares sets, so a test in
tests/messages.rschecks the count. On the adopter tree no other rule repeats a finding with the same rule and span. The only same-line repeats are separate calls on one line, which is expected.Tests
cargo nextest run --workspace(fast profile): 413 passed.npm run test:rewrites(full mode): passes after a bless. Every moved count was compared against main's full-mode report. All differences are on the new fixture lines, or on lines that moved down by one after an added import. One new line,text no-foreign-prototype-patch namespace-import 4, gets a reason: the message names the helper as it is imported by name. Note: main (2cd63b1e) already fails full mode ontext aliased-mut call(14 → 16) and on 3 of thenew missing-mut hoist-constsites, both frommut_two_names(#150). The bless includes those.workceilings hold: the new summaries allocate only for what they keep.npm run test:soundness: 16 of 110 classes escape, exactlyescaping.txt.npm run test:docs: builds.Open question (item 2)
What should happen to code-like tables of whole numbers that hold thresholds (
{ ms: 300, maxRange: 12 },{ x: 28, up: 48, down: 8 })? Options:codesOftables always codes. This drops real code tables with gaps, such as save formats with removed members./** @ordered */or aconstper threshold, which the docs now do.🤖 Generated with Claude Code