Repository navigation
fix(lint): enable anti-slop/no-reflect-get - #20786
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0662410c00bd1bd5661435efb80829ddd50545e4 and 3c2dfe1. 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe pull request enables four anti-slop lint rules and adds foreign-scan coverage for unused suppressions. Production code and tests replace selected Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The migration preserves the inspected runtime contracts and introduces no established production risk, so it is mergeable. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 50 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the full 68-file diff that flips anti-slop/no-reflect-get to error and clears the repo to zero.
- Rule enabled —
config/oxlint-anti-slop.jsonflipsno-reflect-getfromofftoerror. - Production rewrites —
Reflect.get(x, 'k')became'k' in x ? x.k : nullaftertypeof === 'object'guards (managed-hook-detection-commands.ts,managed-hook-installer.ts,worktree-name-retirement.ts,daemon-client-rpc-request.ts); CodexreadStringnow delegates to the existingcodex-item-field-readers; mobilesettings-read-operations.tsaddssettingsField(). - Test rewrites — private-state reads moved to bracket access (
runtime['layoutQueues'],service['retainedPaths']) or documented read-only accessors (CodexSubagentExecutions.retentionSizes(),SearchSubprocessLineAccumulator.retainedCapacityBytes()); e2e specs addeddeclare globalWindowblocks for typed reads. - Suppressions — 42
no-reflect-getdisables, each on aProxygettrap default forward, plus 3consistent-type-definitionsand 1no-varfor declaration-merged e2e globals. - Mutation anchors —
operation-mutations.tsandrecording-runner.test.tsanchor text updated to match the rewritten source.
I verified the rewrite equivalence myself rather than relying on the description: codex-item-field-readers returns {} for non-objects and null for missing/short strings exactly as the old inline readString did; settingsField boxes via Object() with the same missing-key result; and the undefined -> null swaps all flow into consumers that guard with Array.isArray / typeof / == null. Locally: pnpm audit:anti-slop is 0/0, oxlint over all 67 changed TS files is 0/0, and all 43 changed vitest files pass (430 passed, 2 skipped).
Two observations recorded without action needed: the two production accessors widen public API purely for test observation (read-only and documented; bracket access is used elsewhere in this same diff if you'd rather stay consistent), and mobile/ deps are absent in this worktree so mobile tests/tsc were not executed — mobile CI is the real gate, as the PR body already notes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
1eefba7 to
0662410
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one coverage gap worth closing before merge.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review (1dd4f4f9c7 → 0662410c00), a single squashed commit on main; the rest of the 70-file diff is unchanged from the previously reviewed version.
- Broadened the changed-code gate's unused-directive exemption —
check-changed-code-quality.mjsreplacesCASTING_DISABLE_PATTERN/isCastingDirectiveUnusedWarningwithFOREIGN_SCAN_DISABLE_PATTERN/isForeignScanDirectiveUnusedWarning, now coveringanti-slop/directives as well astypescript/consistent-type-assertions. Required because the root scan does not load the anti-slop plugin, so every anti-slop suppression in this PR reads as unused there. - Added a unit test —
casting-code-quality.test.mjsgains ananti-slop/no-reflect-getfixture (plus anantiSlopDirectivehelper) asserting the exemption fires. - Dropped six redundant
Proxytype assertions —new Proxy(x, h)already returnstypeof x, soas Map<string, unknown>/as OrchestrationDb/as AgentSessionJournal/as AutoUpdaterMock/as LaneStatecame off, along with the now-unusedAgentSessionJournalimport (terminal-listing.spec.ts,mailbox-pointer-stage.test.ts,structured-agent-session-runtime.test.ts,updater-test-harness.ts,codex-pane-selection-lane.test.ts). This keeps the PR's "zero net-newascasts" claim true. - Reverted one rewrite —
session-write-subscriber-allocation.test.tsgoes back toReflect.get(target, property, receiver)plus a suppression. - Removed an unused
no-vardirective —project-group-creation-visibility.spec.tsnow carries a plain comment over the ambientdeclare global { var … };no-vardoes not fire in an ambient declaration, whichoxlinton the changed set confirms.
I re-ran oxlint over all nine delta files (0 warnings / 0 errors) and the gate's own unit suite (pnpm exec vitest run config/scripts/casting-code-quality.test.mjs, 6 passed).
ℹ️ Nitpicks
- The PR description still lists
1x // eslint-disable-next-line no-varamong the suppressions, but that directive was removed in0662410c00(the ambientdeclare global { var … }now has a plain comment). Worth updating so the suppression inventory matches the diff.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // Why: a rule enabled only by a scan-specific config is off (or its plugin absent) under the | ||
| // root config, so the suppression the owning scan requires reads as unused there and the root | ||
| // scan reports it as a warning this gate counts. Exempt exactly those directives; the scan that | ||
| // owns each rule still fails on a suppression that stops covering a real violation. |
There was a problem hiding this comment.
The rationale asserts that "the scan that owns each rule still fails on a suppression that stops covering a real violation", but that does not hold for anti-slop/. pnpm audit:anti-slop (package.json:168) runs oxlint without --report-unused-disable-directives, and oxlint 1.80 reports nothing by default, so a stale // oxlint-disable-next-line anti-slop/... on a changed line is now caught by no scan — the root scan exempts it and the owning scan is silent. Before this change the root scan's --report-unused-disable-directives-severity warn counted it (the gate tallies warnings), so the delta removes the only check that reported these.
Technical details
# Stale anti-slop suppressions are no longer reported
## Affected sites
- `config/scripts/check-changed-code-quality.mjs:324-327` — comment claims the owning scan enforces the suppression; it does not.
- `package.json:168` — `audit:anti-slop` lacks `--report-unused-disable-directives-severity`.
## Evidence
- `node_modules/.bin/oxlint --config config/oxlint-anti-slop.json <file-with-stale-directive>` → `Found 0 warnings and 0 errors.`
- Same file with `--report-unused-disable-directives-severity warn` → `Unused oxlint-disable directive (no problems were reported).`
- `check-changed-code-quality.mjs:407-416` counts every returned diagnostic toward `failures`, so the pre-change root scan did fail on these.
## Required outcome
- A stale `anti-slop/*` suppression on a changed line should still fail a CI step, or the comment should stop claiming that it does.
## Suggested approach (optional)
- Add `--report-unused-disable-directives-severity warn` to the `audit:anti-slop` command in `package.json` (it already passes `--deny-warnings`), so the owning scan reports stale suppressions repo-wide.0662410 to
3c2dfe1
Compare
There was a problem hiding this comment.
Caution
The rebase onto main (@22ce8d6) resolved the check-changed-code-quality.mjs conflict in favor of main's version, which exports isCastingDirectiveUnusedWarning / isAntiSlopDirectiveUnusedWarning — but casting-code-quality.test.mjs still imports and calls isForeignScanDirectiveUnusedWarning, a name that no longer exists. pnpm test now fails two tests in that file.
Reviewed changes
This run re-reviewed the single commit 3c2dfe1c, a rebase of 0662410c onto main @22ce8d6. The other 68 files are unchanged from the previously reviewed version.
- Rebased onto newer
main— picks up the sibling anti-slop rule flips (no-reflect-apply,no-module-mocking,no-unknown-type-aliases) and, importantly, main's ownisAntiSlopDirectiveUnusedWarningexemption incheck-changed-code-quality.mjs. - Dropped the branch's gate change — the earlier
FOREIGN_SCAN_DISABLE_PATTERN/isForeignScanDirectiveUnusedWarningrename ofcheck-changed-code-quality.mjsis gone; that file now matchesmain, so this PR no longer touches it. - Left a stale reference behind —
casting-code-quality.test.mjsstill imports and calls the removedisForeignScanDirectiveUnusedWarning(lines 9, 98, 126), which fails at runtime.
I verified the failure directly: node_modules/.bin/vitest run config/scripts/casting-code-quality.test.mjs at head gives 2 failed, 4 passed with TypeError: isForeignScanDirectiveUnusedWarning is not a function. The file is in config/vitest.config.ts's include list, so pnpm test covers it. Anti-slop lint on the 68 changed source files is 0 warnings / 0 errors under config/oxlint-anti-slop.json.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| diagnosticTouchesAddedLines, | ||
| findCastingDirectivesMissingSafety, | ||
| isCastingDirectiveUnusedWarning | ||
| isForeignScanDirectiveUnusedWarning |
There was a problem hiding this comment.
isForeignScanDirectiveUnusedWarning no longer exists: the rebase kept main's check-changed-code-quality.mjs, which exports isCastingDirectiveUnusedWarning and isAntiSlopDirectiveUnusedWarning. This import (and the calls at lines 98 and 126) therefore throw, so vitest run config/scripts/casting-code-quality.test.mjs fails 2 tests.
Technical details
# Restore the gate-exemption tests to main's export names
## Affected sites
- `config/scripts/casting-code-quality.test.mjs:9` — imports `isForeignScanDirectiveUnusedWarning`, which `check-changed-code-quality.mjs` at head does not export.
- `config/scripts/casting-code-quality.test.mjs:98` — the casting-directive test should call `isCastingDirectiveUnusedWarning` (main's name).
- `config/scripts/casting-code-quality.test.mjs:126` — the anti-slop test should call `isAntiSlopDirectiveUnusedWarning` (main's name).
## Evidence
- Head's `check-changed-code-quality.mjs` (== `main`) exports `isCastingDirectiveUnusedWarning` (line 324) and `isAntiSlopDirectiveUnusedWarning` (line 338); `isForeignScanDirectiveUnusedWarning` appears nowhere in the repo.
- `node_modules/.bin/vitest run config/scripts/casting-code-quality.test.mjs` → 2 failed, 4 passed, `TypeError: isForeignScanDirectiveUnusedWarning is not a function`.
- `config/vitest.config.ts` includes `config/scripts/**/*.test.mjs`, so `pnpm test` runs this file.
## Required outcome
- `pnpm test` passes, and the two exemption tests exercise main's actual functions rather than a removed one.
## Suggested approach
- Import `isCastingDirectiveUnusedWarning` and `isAntiSlopDirectiveUnusedWarning`; call the casting one at line 98 and the anti-slop one at line 126.3c2dfe1 to
952e4f1
Compare
`anti-slop/no-reflect-get` rejects every call to `Reflect.get`. The
reflective read bypasses ordinary property access and throws away the
type evidence the compiler would otherwise give you: the result is
`any`/`unknown` with no narrowing, so a typo in the key or a shape drift
in the source object is invisible until runtime. The rule's remedy is to
parse dynamic input into a named domain type (or narrow it with `in`)
and then read the field normally.
Baseline: 86 violations across 67 files. Now zero unsuppressed
violations under
`npx oxlint --config config/oxlint-anti-slop.json --ignore-pattern 'config/oxlint-plugins/anti-slop/**' src config tests mobile`.
Fix pattern
-----------
44 of the 86 were rewritten. The dominant shape was an `unknown` value
read through `Reflect.get` right after a `typeof === 'object'` guard;
those became `in`-narrowed property access, which TypeScript checks:
- Reflect.get(value, 'agents')
+ 'agents' in value ? value.agents : null
Two further shapes:
- `Reflect.get(Object(x), 'k')` on a possibly-primitive envelope became a
small named reader that boxes once and indexes a
`Record<string, unknown>` (`settingsField` in
mobile/src/transport/settings-read-operations.ts).
- Tests reaching into private state moved to TypeScript's checked
bracket-index escape hatch (`runtime['layoutQueues']`), or to a
documented read-only accessor on the owning class
(`SearchSubprocessLineAccumulator.retainedCapacityBytes()`,
`CodexSubagentExecutions.retentionSizes()`).
No type assertion was added anywhere: the diff contains zero net-new
`as` casts, `as any`, `as unknown as`, `@ts-ignore`, or
`@ts-expect-error`, so nothing was laundered into the sibling
assertion rules.
Suppressions
------------
42x `// oxlint-disable-next-line anti-slop/no-reflect-get` across 38
files. Every one is the default-forward branch of a `Proxy` `get` trap:
get(target, property, receiver) {
...
return Reflect.get(target, property, receiver)
}
`Reflect.get(target, property, receiver)` is the only construct that
forwards with correct `receiver` semantics; `target[property]` invokes
an accessor with the wrong `this` and silently breaks getters that read
sibling state. There is no typed alternative, so these are suppressed
rather than rewritten.
3x `// oxlint-disable-next-line typescript-eslint/consistent-type-definitions
-- declaration merging requires interface` in
tests/e2e/github-url-smart-input-transition.spec.ts,
tests/e2e/linear-url-workspace-entry.spec.ts, and
tests/e2e/worktree-active-delete-scroll-position.spec.ts. Replacing
`Reflect.get(window, 'x')` with typed `window.x` requires a
`declare global { interface Window }` block, and `interface` is
mandatory for declaration merging. Matches the existing convention at
tests/e2e/helpers/runtime-types.ts:63.
1x `// eslint-disable-next-line no-var -- main-process gate handle for
this spec` in tests/e2e/project-group-creation-visibility.spec.ts, for
the same reason a `var` global is needed to type the handle. Matches
tests/e2e/agent-session-log-tail-stability.spec.ts:24.
Also updates two source-text anchors in mobile's rpc-recording mutation
harness (mobile/src/test-support/rpc-recording/operation-mutations.ts
and recording-runner.test.ts), which pin the exact text of the rewritten
line in settings-read-operations.ts and would otherwise fail with
"Mutant anchor matched 0 sites, expected 1".
952e4f1 to
28283ed
Compare
`anti-slop/no-reflect-get` rejects every call to `Reflect.get`. The
reflective read bypasses ordinary property access and throws away the
type evidence the compiler would otherwise give you: the result is
`any`/`unknown` with no narrowing, so a typo in the key or a shape drift
in the source object is invisible until runtime. The rule's remedy is to
parse dynamic input into a named domain type (or narrow it with `in`)
and then read the field normally.
Baseline: 86 violations across 67 files. Now zero unsuppressed
violations under
`npx oxlint --config config/oxlint-anti-slop.json --ignore-pattern 'config/oxlint-plugins/anti-slop/**' src config tests mobile`.
Fix pattern
-----------
44 of the 86 were rewritten. The dominant shape was an `unknown` value
read through `Reflect.get` right after a `typeof === 'object'` guard;
those became `in`-narrowed property access, which TypeScript checks:
- Reflect.get(value, 'agents')
+ 'agents' in value ? value.agents : null
Two further shapes:
- `Reflect.get(Object(x), 'k')` on a possibly-primitive envelope became a
small named reader that boxes once and indexes a
`Record<string, unknown>` (`settingsField` in
mobile/src/transport/settings-read-operations.ts).
- Tests reaching into private state moved to TypeScript's checked
bracket-index escape hatch (`runtime['layoutQueues']`), or to a
documented read-only accessor on the owning class
(`SearchSubprocessLineAccumulator.retainedCapacityBytes()`,
`CodexSubagentExecutions.retentionSizes()`).
No type assertion was added anywhere: the diff contains zero net-new
`as` casts, `as any`, `as unknown as`, `@ts-ignore`, or
`@ts-expect-error`, so nothing was laundered into the sibling
assertion rules.
Suppressions
------------
42x `// oxlint-disable-next-line anti-slop/no-reflect-get` across 38
files. Every one is the default-forward branch of a `Proxy` `get` trap:
get(target, property, receiver) {
...
return Reflect.get(target, property, receiver)
}
`Reflect.get(target, property, receiver)` is the only construct that
forwards with correct `receiver` semantics; `target[property]` invokes
an accessor with the wrong `this` and silently breaks getters that read
sibling state. There is no typed alternative, so these are suppressed
rather than rewritten.
3x `// oxlint-disable-next-line typescript-eslint/consistent-type-definitions
-- declaration merging requires interface` in
tests/e2e/github-url-smart-input-transition.spec.ts,
tests/e2e/linear-url-workspace-entry.spec.ts, and
tests/e2e/worktree-active-delete-scroll-position.spec.ts. Replacing
`Reflect.get(window, 'x')` with typed `window.x` requires a
`declare global { interface Window }` block, and `interface` is
mandatory for declaration merging. Matches the existing convention at
tests/e2e/helpers/runtime-types.ts:63.
1x `// eslint-disable-next-line no-var -- main-process gate handle for
this spec` in tests/e2e/project-group-creation-visibility.spec.ts, for
the same reason a `var` global is needed to type the handle. Matches
tests/e2e/agent-session-log-tail-stability.spec.ts:24.
Also updates two source-text anchors in mobile's rpc-recording mutation
harness (mobile/src/test-support/rpc-recording/operation-mutations.ts
and recording-runner.test.ts), which pin the exact text of the rewritten
line in settings-read-operations.ts and would otherwise fail with
"Mutant anchor matched 0 sites, expected 1".

Based on #20726 (now merged) (
nwparker/2x-lint). Review only the top commit; base that PR first.Flips
anti-slop/no-reflect-getfromofftoerrorinconfig/oxlint-anti-slop.jsonand clears the repo to zero.What the rule rejects, and why it matters
Every call to
Reflect.get. The reflective read bypasses ordinary property access and throws away the type evidence the compiler would otherwise give you: the result isany/unknownwith no narrowing, so a typo in the key or a shape drift in the source object is invisible until runtime. The remedy the rule pushes you toward is to narrow (or parse) dynamic input into a real type and then read the field normally, so the key is checked.The one construct the rule cannot replace is a
Proxygettrap's default forward — see Suppressions.Violations fixed
86 at baseline across 67 files. 44 rewritten, 42 suppressed. Audit is now clean:
Fix pattern
The dominant shape was an
unknownread throughReflect.getright after atypeof === 'object'guard. Those becamein-narrowed property access, which TypeScript actually checks:Two further shapes:
Reflect.get(Object(x), 'k')on a possibly-primitive envelope became a small named reader that boxes once and indexes aRecord<string, unknown>(settingsFieldinmobile/src/transport/settings-read-operations.ts).runtime['layoutQueues']), or to a documented read-only accessor on the owning class (SearchSubprocessLineAccumulator.retainedCapacityBytes(),CodexSubagentExecutions.retentionSizes()).No type assertion was added anywhere. The diff contains zero net-new
ascasts,as any,as unknown as,@ts-ignore, or@ts-expect-error, so nothing was laundered into the sibling assertion rules to make this one go green.Suppressions
42x
// oxlint-disable-next-line anti-slop/no-reflect-getacross 38 files. Every one is the default-forward branch of aProxygettrap:Reflect.get(target, property, receiver)is the only construct that forwards with correctreceiversemantics.target[property]invokes an accessor with the wrongthisand silently breaks getters that read sibling state through the proxy. There is no typed alternative, so these are suppressed rather than rewritten. "Zero violations" here means zero unsuppressed violations.3x
// oxlint-disable-next-line typescript-eslint/consistent-type-definitions -- declaration merging requires interfaceintests/e2e/github-url-smart-input-transition.spec.ts,tests/e2e/linear-url-workspace-entry.spec.ts,tests/e2e/worktree-active-delete-scroll-position.spec.ts. ReplacingReflect.get(window, 'x')with typedwindow.xrequires adeclare global { interface Window }block, andinterfaceis mandatory for declaration merging. Matches the existing convention attests/e2e/helpers/runtime-types.ts:63. (The anti-slop audit config does not include that rule, so a clean audit hid a red main lint gate until the whole changed set was run under the main.oxlintrc.json.)1x
// eslint-disable-next-line no-var -- main-process gate handle for this specintests/e2e/project-group-creation-visibility.spec.ts, for the same typed-global reason. Matchestests/e2e/agent-session-log-tail-stability.spec.ts:24.What a reviewer should scrutinise
undefined->nullswaps.Reflect.get(x, 'k')yieldsundefinedfor a missing key; the'k' in x ? x.k : nullrewrite yieldsnull. Each site was checked against its consumer — all of them guard withArray.isArray/typeof/== null, so the swap is unobservable. Worth a second pair of eyes if you know a consumer that distinguishes the two.receiver(src/main/runtime/missing-worktree-terminal-reconciliation.ts:28,src/main/updater-test-harness.ts:150). Both target getter-free plain objects, soreceiverwas inert, but that is an invariant of the target, not of the trap.typeof prop === 'string' &&added beforeprop in namespaceinuseIpcEvents-zoom-routing.test.tsanduseIpcEvents-rate-limit-hydration.test.ts. This is a real semantic narrowing: symbol-keyed lookups now land on the fallback path. It is unreachable here (everymakeEvents()target is an{}-rooted object literal with no own symbol keys, andObject.prototypecarries noSymbol.iterator/toPrimitive/toStringTag), but it is a narrowing.CodexSubagentExecutions.retentionSizes(),SearchSubprocessLineAccumulator.retainedCapacityBytes()). Both read-only and documented, but they do widen API surface where three sibling sites in this same diff instead used bracket access. Say the word and they become bracket access too.mobile/src/test-support/rpc-recording/mutation anchors. That harness pins the exact source text of a line insettings-read-operations.tsand hard-fails withMutant anchor matched 0 sites, expected 1if the text drifts. Two anchors had to move with the rewrite: thebot-overrides-envelopeentry inoperation-mutations.tsand the synthetic-duplicate fixture inrecording-runner.test.ts.How this was verified
Ran and green:
pnpm audit:anti-slop— exit 0. Confirmed the rule is genuinely firing (not silently disabled) by planting aReflect.getprobe, seeing it reported, and removing it.oxlintunder the main.oxlintrc.jsonon all 68 changed files — exit 0. The pre-commit hook re-ranoxlint,oxlint --config config/oxlint-react-doctor.json, andoxfmt --writeover the staged set.node config/scripts/run-typecheck-projects-in-parallel.mjs— exit 0, before and after the rebase onto the corrected base.orca-runtime.test.ts, which is the entry point for the changedorca-runtime-tests/terminal-listing.spec.tshelper). 1,839 tests passed, 3 skipped, 0 failed.operation-mutations.ts: each resolves to a file that contains itsbeforetext exactly once.git diff --name-only <base> --diff-filter=Ais empty; no.js,.d.ts, or.tsbuildinfoanywhere in the diff; working tree clean.Could not verify:
mobile/is a separate pnpm workspace and its dependencies are not installed in this worktree (mobile/node_modulesis empty;vitestfails atCannot find module 'expo/tsconfig.base.json'). Somobile's tests andtsc --noEmitnever ran, and the root typecheck script does not covermobile. The three mobile files in this diff were verified by lint (oxlintundermobile/.oxlintrc), byoxfmt, and by the static anchor check above — not by execution. Mobile CI is the gate here.tests/e2e/*.spec.tsare Playwright specs and were not executed. They were typechecked and linted. Notetsc -p config/tsconfig.e2e.jsonhas 219 pre-existing errors on this branch; none are in the four spec files touched here.Recreated from #20751, which GitHub auto-closed when its base branch was deleted on merge of #20726. Same branch, same commit, now targeting
maindirectly.