Skip to content

fix(lint): enable anti-slop/no-reflect-get - #20786

Merged
nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-reflect-get
Sep 15, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-reflect-get

Conversation

@nwparker

@nwparker nwparker commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 51 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160 $\color{#cf222e}{\Huge{\mathbf{−}}}$​77 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32

Based on #20726 (now merged) (nwparker/2x-lint). Review only the top commit; base that PR first.

Flips anti-slop/no-reflect-get from off to error in config/oxlint-anti-slop.json and 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 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 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 Proxy get trap's default forward — see Suppressions.

Violations fixed

86 at baseline across 67 files. 44 rewritten, 42 suppressed. Audit is now clean:

pnpm audit:anti-slop   # exit 0

Fix pattern

The dominant shape was an unknown read through Reflect.get right after a typeof === 'object' guard. Those became in-narrowed property access, which TypeScript actually checks:

-  const agents = detectedManagedHookAgents(Reflect.get(value, 'agents'))
-  const versions = Reflect.get(value, 'versions')
+  const agents = detectedManagedHookAgents('agents' in value ? value.agents : null)
+  const versions = 'versions' in value ? value.versions : 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 to make this one go green.

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 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 interface in tests/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. 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. (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 spec in tests/e2e/project-group-creation-visibility.spec.ts, for the same typed-global reason. Matches tests/e2e/agent-session-log-tail-stability.spec.ts:24.

What a reviewer should scrutinise

  • undefined -> null swaps. Reflect.get(x, 'k') yields undefined for a missing key; the 'k' in x ? x.k : null rewrite yields null. Each site was checked against its consumer — all of them guard with Array.isArray/typeof/== null, so the swap is unobservable. Worth a second pair of eyes if you know a consumer that distinguishes the two.
  • Two proxy traps that dropped receiver (src/main/runtime/missing-worktree-terminal-reconciliation.ts:28, src/main/updater-test-harness.ts:150). Both target getter-free plain objects, so receiver was inert, but that is an invariant of the target, not of the trap.
  • typeof prop === 'string' && added before prop in namespace in useIpcEvents-zoom-routing.test.ts and useIpcEvents-rate-limit-hydration.test.ts. This is a real semantic narrowing: symbol-keyed lookups now land on the fallback path. It is unreachable here (every makeEvents() target is an {}-rooted object literal with no own symbol keys, and Object.prototype carries no Symbol.iterator/toPrimitive/toStringTag), but it is a narrowing.
  • Two public accessors added to production classes purely for test observation (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 in settings-read-operations.ts and hard-fails with Mutant anchor matched 0 sites, expected 1 if the text drifts. Two anchors had to move with the rewrite: the bot-overrides-envelope entry in operation-mutations.ts and the synthetic-duplicate fixture in recording-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 a Reflect.get probe, seeing it reported, and removing it.
  • oxlint under the main .oxlintrc.json on all 68 changed files — exit 0. The pre-commit hook re-ran oxlint, oxlint --config config/oxlint-react-doctor.json, and oxfmt --write over the staged set.
  • node config/scripts/run-typecheck-projects-in-parallel.mjs — exit 0, before and after the rebase onto the corrected base.
  • Vitest over 57 files: every changed test file, plus the test files covering each changed non-test source (and orca-runtime.test.ts, which is the entry point for the changed orca-runtime-tests/terminal-listing.spec.ts helper). 1,839 tests passed, 3 skipped, 0 failed.
  • Statically validated all 9 mutation anchors in operation-mutations.ts: each resolves to a file that contains its before text exactly once.
  • No files added: git diff --name-only <base> --diff-filter=A is empty; no .js, .d.ts, or .tsbuildinfo anywhere 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_modules is empty; vitest fails at Cannot find module 'expo/tsconfig.base.json'). So mobile's tests and tsc --noEmit never ran, and the root typecheck script does not cover mobile. The three mobile files in this diff were verified by lint (oxlint under mobile/.oxlintrc), by oxfmt, and by the static anchor check above — not by execution. Mobile CI is the gate here.
  • tests/e2e/*.spec.ts are Playwright specs and were not executed. They were typechecked and linted. Note tsc -p config/tsconfig.e2e.json has 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 main directly.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e21351c6-6252-4f2b-b75d-51df1ebdcf12

📥 Commits

Reviewing files that changed from the base of the PR and between 0662410c00bd1bd5661435efb80829ddd50545e4 and 3c2dfe1.

📒 Files selected for processing (3)
  • config/oxlint-anti-slop.json
  • src/main/runtime/runtime-linear-command-surface.ts
  • src/renderer/src/components/editor/tiptap-marked-facade.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The pull request enables four anti-slop lint rules and adds foreign-scan coverage for unused suppressions. Production code and tests replace selected Reflect property access with guarded direct access, shared helpers, or typed accessors. Intentional Proxy forwarding remains documented with targeted suppressions. End-to-end tests add global declarations and typed property keys.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 3c2df

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: enabling the anti-slop no-reflect-get lint rule.
Description check ✅ Passed The description is detailed and on topic. It explains the change, rationale, implementation, linked issues, testing, and known verification limits. Some template headings and checklist items are not r…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.json flips no-reflect-get from off to error.
  • Production rewrites — Reflect.get(x, 'k') became 'k' in x ? x.k : null after typeof === 'object' guards (managed-hook-detection-commands.ts, managed-hook-installer.ts, worktree-name-retirement.ts, daemon-client-rpc-request.ts); Codex readString now delegates to the existing codex-item-field-readers; mobile settings-read-operations.ts adds settingsField().
  • Test rewrites — private-state reads moved to bracket access (runtime['layoutQueues'], service['retainedPaths']) or documented read-only accessors (CodexSubagentExecutions.retentionSizes(), SearchSubprocessLineAccumulator.retainedCapacityBytes()); e2e specs added declare global Window blocks for typed reads.
  • Suppressions — 42 no-reflect-get disables, each on a Proxy get trap default forward, plus 3 consistent-type-definitions and 1 no-var for declaration-merged e2e globals.
  • Mutation anchors — operation-mutations.ts and recording-runner.test.ts anchor 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-reflect-get branch 2 times, most recently from 1eefba7 to 0662410 Compare September 15, 2026 06:45

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.mjs replaces CASTING_DISABLE_PATTERN / isCastingDirectiveUnusedWarning with FOREIGN_SCAN_DISABLE_PATTERN / isForeignScanDirectiveUnusedWarning, now covering anti-slop/ directives as well as typescript/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.mjs gains an anti-slop/no-reflect-get fixture (plus an antiSlopDirective helper) asserting the exemption fires.
  • Dropped six redundant Proxy type assertions — new Proxy(x, h) already returns typeof x, so as Map<string, unknown> / as OrchestrationDb / as AgentSessionJournal / as AutoUpdaterMock / as LaneState came off, along with the now-unused AgentSessionJournal import (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-new as casts" claim true.
  • Reverted one rewrite — session-write-subscriber-allocation.test.ts goes back to Reflect.get(target, property, receiver) plus a suppression.
  • Removed an unused no-var directive — project-group-creation-visibility.spec.ts now carries a plain comment over the ambient declare global { var … }; no-var does not fire in an ambient declaration, which oxlint on 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-var among the suppressions, but that directive was removed in 0662410c00 (the ambient declare global { var … } now has a plain comment). Worth updating so the suppression inventory matches the diff.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +324 to +327
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-reflect-get branch from 0662410 to 3c2dfe1 Compare September 15, 2026 07:46

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 own isAntiSlopDirectiveUnusedWarning exemption in check-changed-code-quality.mjs.
  • Dropped the branch's gate change — the earlier FOREIGN_SCAN_DISABLE_PATTERN / isForeignScanDirectiveUnusedWarning rename of check-changed-code-quality.mjs is gone; that file now matches main, so this PR no longer touches it.
  • Left a stale reference behind — casting-code-quality.test.mjs still imports and calls the removed isForeignScanDirectiveUnusedWarning (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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

diagnosticTouchesAddedLines,
findCastingDirectivesMissingSafety,
isCastingDirectiveUnusedWarning
isForeignScanDirectiveUnusedWarning

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-reflect-get branch from 3c2dfe1 to 952e4f1 Compare September 15, 2026 08:19
`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".
@nwparker
nwparker force-pushed the nwparker/anti-slop/no-reflect-get branch from 952e4f1 to 28283ed Compare September 15, 2026 08:19
@nwparker
nwparker merged commit f107499 into main Sep 15, 2026
7 checks passed
@nwparker
nwparker deleted the nwparker/anti-slop/no-reflect-get branch September 15, 2026 08:24
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
`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".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant