Repository navigation
chore(lint): unmask no-unsafe-dictionary-type behind effect's Record - #287
Merged
Merged
Conversation
3 tasks
`effect(no-unsafe-dictionary-type)` and `effect(no-known-value-widening)`
only treat `Record<K, V>` as the built-in while no local binding is named
`Record`, so `import { Record } from "effect"` hid every such site in the
file. Alias the module (`Record as R`; `Rec` in Query.ts, where `R` is the
resource type parameter) in codecs.ts, filter.ts and Query.ts, and record
the convention next to the rule's tier entry in vite.config.ts.
Make `nest` generic over its leaf value type, which removes four of the
rule's sites in codecs.ts (three of them previously hidden). The rest of
the unmasked sites (`flatten`, and the decode loop in `Query.schema`) have
no types-only fix and are now visible warn-tier debt. Handlers.ts and
codecs.test.ts keep the unaliased import: other open PRs edit them.
No runtime or emitted-declaration change: `dist/` is byte-identical to
trunk's build.
Closes #275
Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc
Co-Authored-By: Claude <noreply@anthropic.com>
take the alias: `src/Handlers.ts`, `src/Middleware.ts` and `src/internal/codecs.test.ts` now import it as `Rec`. That unmasks one `no-unsafe-dictionary-type` site (`Handlers.ts`, `projected`) and one `no-known-value-widening` site (`Middleware.ts`, `SUPPORT_FAMILIES`), so the visible count of both rules equals the true count. `codecs.ts`, `filter.ts`, `Assemble.test.ts` and `Handlers.test.ts` switch from `R` to `Rec`, the spelling `Query.ts` and trunk's `schemaExt.ts` use, and the `vite.config.ts` note now says to spell the alias `Rec` everywhere. `Query.schema`'s filter decode splits the flat record with `Rec.filter` instead of a loop into two annotated `Record<string, unknown>` locals, which clears both remaining sites there. `Rec.filter` writes through effect's `assignProperty`, so a `__proto__` key stays an own property. A new test routes `filter[<Object.prototype member>]` to the grammar and drops a bare key of that name next to a valid filter. Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc Co-Authored-By: Claude <noreply@anthropic.com>
thomasfosterau
force-pushed
the
issue-275-masked-dictionary-lint
branch
from
October 8, 2026 22:36
2fc9e05 to
e32e7b2
Compare
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #275.
effect(no-unsafe-dictionary-type)treatsRecord<K, V>as the built-in only while no local binding is namedRecord(isBuiltIn→hasVisibleTypeBindingin the plugin'sinternal/anti-slop/dictionary-types.ts).import { Record } from "effect"creates that binding, so every such site in the file disappears.effect(no-known-value-widening)goes through the sameisBuiltIncheck and has the same blind spot.This PR:
RecordasRec. Insrc/:Query.ts,Handlers.ts,Middleware.ts,internal/codecs.tsandinternal/filter.ts. In tests:internal/codecs.test.ts, plusAssemble.test.tsandHandlers.test.ts, which usedR. With trunk'sinternal/schemaExt.ts, the repository now has one spelling.Ris ruled out because it is the resource type parameter in many files: 51 places inQuery.ts, for example, andHandlers.tstoo. No file insrc/,test/,examples/orscripts/still binds effect'sRecordasRecord, whether through a named import, a multi-line named import orimport * as Record.nestincodecs.tsis now generic over its leaf value type (<V>(flat: { readonly [key: string]: V }) => Record<string, V | Record<string, V>>). Call sites inferV.Query.schema's filter decode splits the flat record withRec.filter(flatValues, (_, key) => isFilterKey(key))and its negation. Before, a loop filled twoRecord<string, unknown>locals.Rec.filterwrites through effect'sassignProperty, so a__proto__key stays an own property, and the split cannot write through a prototype.vite.config.ts: never bind effect'sRecordmodule asRecord, and spell the aliasReceverywhere.Counts (
vp lint --format json, per rule)"True" is the count with every import of effect's
Recordinsrc/andtest/temporarily aliased. On this branch there is nothing left to alias, so true equals visible.no-unsafe-dictionary-typevisibleno-unsafe-dictionary-typetrueno-known-value-wideningvisibleno-known-value-wideningtrued8d9f18On trunk, 8 sites of
no-unsafe-dictionary-typewere hidden:codecs.ts:nest's return,nested, the group cast,flatten's return andflat;Query.ts:othersandfilterKeysin the filter decode;Handlers.ts:projected.5 sites of
no-known-value-wideningwere hidden:codecs.ts×2,filter.ts,Query.tsandMiddleware.ts(SUPPORT_FAMILIES).After this PR:
nestand 2 byRec.filter.nest's parameter, which was already visible, is fixed too.flatten's return and itsflatlocal incodecs.ts, andprojectedinHandlers.ts.flatten's leaves come fromObject.entrieson arbitrary group objects, so it needs a group type guard. That's a code change outside this issue.Both rules are still above zero, so they stay at
warn.Why a note and not a lint rule
oxlint's
no-restricted-importsmatches the imported name, so it also reportsimport { Record as Rec } from "effect". I probed it.effect/prefer-namespace-importswould enforce a namespace import, but it does that for every module, which is why it isoff. That leaves a custom JS plugin rule as the only mechanical guard. The issue's done-when allows a note. A guard is a possible follow-up, and that's the owner's call.Verification
All run in a fresh clone at the head commit, rebased on trunk
d8d9f18:pnpm install --frozen-lockfile: passvp run build: passvp check: pass (0 errors, 4348 warnings)vp run check(sources, type-level tests, examples, emitted declarations): pass ("check: every type gate green")vp run -r test:unit: pass (root 2477/2477; examples 45, 41, 54)?x=1&x[y]=2is a 500 #260/fix(Query): drop undeclared query parameters when the query declares nothing (#260) #264 prototype-safety suites (Query.test.ts,Query.filter.test.ts,Middleware.query.test.ts,internal/codecs.test.ts,Assemble.test.ts,Handlers.test.ts) pass on their own: 1250/1250.Query.filter.test.ts(Query.schema with filter: true), for eachObject.prototypemember name (constructor,__proto__,toString,hasOwnProperty,valueOf):filter[<name>]is routed to the grammar and answeredUnknown filter field "<name>"at that key;filter[status]andpage[limit], decode to just the filter and page;Object.prototypeis not polluted.vp run docgen(every JSDoc@examplecompiled and executed): pass (224 examples)fallow audit --format json --quiet --explain --gate-marker agent: verdictpassfallow audit --base origin/trunk: pass ("No issues in 10 changed files"; 15 inherited findings excluded)Changeset
None. Published behaviour does not change.
.changeset/for every change to published behaviour (not applicable)dist/does change. I diffed it against a trunkd8d9f18build:dist/index.jschanges only at the filter split. The loop becomes twoRecord.filtercalls, with the same keys on the same side. The old loop passes the new test, as noted above.dist/index.d.tsdiffers only in the member order of one union: the requirements ofConformance.verify'sEffect. The set of members is the same.Notes
no-known-value-wideningwas right.Query.schemasites are cleared.Rec.internal/codecs.test.tsconflicted with perf: define only __proto__ on the response-path copies (#269 follow-up) #285.@mpsuesser/oxlint-plugin-effect. The issue leaves that to you, and nothing was filed. The plugin should treat a value-only namespace import as a type binding only when it's referenced asRecord.X, never as a bareRecord<…>.nestsignature change was checked againstsrc/internal/codecs.test.ts. Its call sites inferV(string, orstring | string[]).🤖 Generated with Claude Code
Generated by Claude Code