Skip to content

fix(lint): enable anti-slop/no-shape-in-symbol-names - #20750

Closed
nwparker wants to merge 1 commit into
nwparker/2x-lintfrom
nwparker/anti-slop/no-shape-in-symbol-names
Closed

nwparker wants to merge 1 commit into
nwparker/2x-lintfrom
nwparker/anti-slop/no-shape-in-symbol-names

Conversation

@nwparker

@nwparker nwparker commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​199 $\color{#cf222e}{\Huge{\mathbf{−}}}$​175 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24
Prod 68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208 $\color{#cf222e}{\Huge{\mathbf{−}}}$​178 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30

Stacked on #20726 — review/merge that first. This PR's base is nwparker/2x-lint, so the diff shown here is only the rule flip plus the fixes.

What the rule rejects

anti-slop/no-shape-in-symbol-names bans the case-insensitive substring "shape" in any JS/TS identifier: variables, functions, parameters, types, type parameters, class members, private names, object-literal keys and JSX identifiers. The single exemption is a statically accessed member read owned by another value, so zodObject.shape needs no suppression.

Why it matters. "Shape" names a value's structure rather than its domain role. UserShape, validateArgShape, errorShape and FIELD_SHAPES all say "this is an object with some fields" — which is exactly what the type already says — while telling you nothing about what the value is for or who owns it. The name ends up carrying zero information, and the suffix spreads: once one type is FooShape, its validator becomes validateFooShape and its predicate isFooShaped. Forcing a domain name makes the symbol describe the concept instead of restating that it has properties.

Violations fixed

689 violations across 109 files, now zero. I verified the baseline count directly rather than trusting it: checked out the pre-change tree into a scratch worktree, flipped the rule to error, and counted — exactly 689 across 109 files, which lines up with the 110 files this PR touches (109 sources + the config flip).

Fix pattern

Rename for the domain role, not the structure:

-type FieldShape = 'list' | 'map' | 'whole'
-const FIELD_SHAPES = { ... } satisfies Record<keyof Observation, FieldShape>
+type FieldEncoding = 'list' | 'map' | 'whole'
+const FIELD_ENCODINGS = { ... } satisfies Record<keyof Observation, FieldEncoding>

-function assertGitPushTargetShape(target: unknown): void
+function assertValidGitPushTarget(target: unknown): void

-function describeReadDirPathShape(p: string): ReadDirPathKind
+function classifyReadDirPath(p: string): ReadDirPathKind

Predicates became statements about the value: isDeltaShapedProviderFrameKind → isDeltaProviderFrameKind, isDeleteShapedDiscardEntry → discardDeletesEntryFile, isSkillsCliAgentKeyShaped → isUsableSkillsCliAgentKey. Type aliases dropped the suffix where the remaining name was already unambiguous: GhGraphqlErrorShape → GhGraphqlError.

No wire-visible name was renamed — no IPC or RPC channel, stream opcode, request/response param, persisted field, or i18n key. The --shape=symlink|copy CLI flag that .github/workflows/skill-update-roundtrip.yml passes is unchanged; only the local variable holding it was renamed.

Suppressions

Four groups, all justified inline:

Where Why
browser-pane/annotate/ (12 files, file-wide) In the screenshot annotator a "shape" is the drawn geometry — pen, arrow, rect, ellipse, highlight. A genuine domain noun that pervades every symbol in the module, so file-wide is the honest granularity rather than 60 line suppressions.
repo-icon.tsx, repo-header-project-actions.tsx, mobile/MobileRepoIcon.tsx lucide-react exports the icon component as Shapes — the name is theirs. The matching REPO_LUCIDE_ICONS key is the persisted icon name shared with the desktop picker; renaming it would orphan saved repo icons.
onboarding-state-types.ts, constants.ts shapedSidebar is a persisted onboarding-checklist field and a telemetry enum member. Renaming orphans saved state.
telemetry-event-classification.ts, rpc-send-params.ts, repo-update-params.ts, ui-update-value-tolerance-params.ts zod's own shape property and its exported ZodRawShape type. In rpc-send-params.ts, matching the literal shape property is what selects the ZodObject branch of the conditional type.

No suppression was added merely to avoid a rename. Eight symbols were initially suppressed with the boilerplate excuse "renaming it is a cross-module refactor outside this change." Each was proven to have zero non-TypeScript references repo-wide and renamed instead — including all three blanket file-wide disables outside annotate/, which would have silently exempted any future violation in those files.

What a reviewer should scrutinise

  1. The boundary. This is a pure-rename PR, so the only real risk is an orphaned reference the compiler can't see — a string literal, a JSON key, a workflow input. Concretely: the --shape flag in verify-skill-update-roundtrip.mjs vs. the workflow matrix, the Shapes REPO_LUCIDE_ICONS key, and shapedSidebar.
  2. The renamed JSON output keys in six benchmark scripts (shape → topology/label/variant/inputCase/caseName/lineLayout, guestProcessShape → guestProcessChain). I found no programmatic consumer — they're reachable only via package.json bench scripts and the output is human-read — but if you know of an external dashboard parsing these, say so.
  3. discardDeletesEntryFile / deletesFile in the source-control toast path, the one rename where I also made a public option name consistent with its private helper. Positional call into entryFailureTitle was already correct, so there is no behavior change either way.
  4. Whether the 12 file-wide disables in annotate/ are the right call versus per-line. I think the domain-noun argument holds there and nowhere else.

How it was verified

  • Audit reports zero violations, via both the raw command and pnpm run audit:anti-slop (the CI script). I confirmed the rule genuinely fires by planting a probe violation — it reported 3 errors and exited 1.
  • node config/scripts/run-typecheck-projects-in-parallel.mjs exits 0, before and after the rebase, with no .js/.d.ts/.tsbuildinfo artifacts left behind.
  • 54 test files covering the changed sources and their siblings: 1010 passed, 2 skipped.
  • Boundary audit: extracted all 66 removed shape-containing identifiers from the diff and grepped the entire repo for each — every file type, not just TS. The only survivor is ZodRawShape, which is zod's own and intentionally suppressed. Zero orphans.
  • node --check on every changed .mjs (not covered by tsc); project oxlint clean on all 109 changed source files; oxfmt is a no-op.

Not verified

Stated plainly rather than papered over:

  • The 3 mobile/ files (MobileRepoIcon.tsx, golden-value-pool.ts, use-mobile-tasks-provider-view-projection.test.tsx). mobile/ is a separate pnpm workspace and its node_modules is not installed in this worktree, so its tsc and vitest could not run — I tried, and expo is unresolvable. They lint clean and I read all three diffs in full; they are pure renames, and golden-value-pool.ts renames only the type alias and const binding, not the serialized field names (sender, payloads, settlements, state, effects are untouched), so no golden file is invalidated.
  • browser-cookie-samesite.electron.test.ts (electron-gated), wsl-unc-delete.wsl.test.ts (real-WSL gated), and tests/e2e/terminal-cjk-ime-committed-text.spec.ts (Playwright) are unrunnable here by construction. All three are rename-only hunks read line by line. In the e2e spec only an array variable was renamed — test titles and screenshot slugs are unchanged.

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

Too many files changed for review (110 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@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

  • Rule flipped to error — config/oxlint-anti-slop.json turns anti-slop/no-shape-in-symbol-names on; the audit is expected to stay green against the renames that follow.
  • Repo-wide identifier renames — 689 violations across 109 files renamed to domain roles (assertValidGitPushTarget, isUsableSkillsCliAgentKey, GhGraphqlError, discardDeletesEntryFile, FieldEncoding, etc.), with no logic edits.
  • Suppressions, correctly scoped — -next-line disables for zod's ZodRawShape/.shape, lucide's Shapes, and the persisted shapedSidebar; the only file-wide disables are the 12 in browser-pane/annotate/, where "shape" is the drawn geometry.
  • Benchmark JSON key renames + one test fixture key — the only non-identifier output changes; verified to have no consumer.

I independently ran the boundary audit rather than trusting the PR body: I extracted all 58 unique removed *shape* tokens from the diff's removed lines and grepped the tree for each. The only survivors are ZodRawShape (zod-owned, deliberately suppressed) and _shape (coincidental match against the unrelated 'current_shape_invalid' string literal). The --shape=symlink|copy workflow flag is untouched — only the local variable changed. Benchmark output keys are read by nothing programmatic (compare-benchmark-artifacts.mjs keys on summary*/headlineMs; ci-shard-timings.json keys are file paths; no workflow invokes these scripts). Remaining shape identifiers outside annotate/ are member accesses (exempt by the rule) or explicitly suppressed, and every suppression comment sits directly above its offending line.

One environment caveat: pnpm run audit:anti-slop cannot run in this container (fails at plugin load resolving @oxlint/plugins), so the zero-violation claim is confirmed by manual enumeration rather than the linter itself. That does not change the disposition — the rename surface is exhaustively covered.

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

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from 31e52ab to c765a54 Compare September 15, 2026 03:51
@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from c765a54 to 63d5be6 Compare September 15, 2026 03:56

@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.

Important

The rework that pins oxlint-plugin-anti-slop instead of vendoring it moved the plugin behind a postinstall-generated, gitignored .anti-slop-plugin/ dir — but nothing in CI generates it, and pr.yml has no audit:anti-slop step at all. As of c765a548f3 the lint-parity gate fails and the audit would fail to load its plugin even if the step were added.

Reviewed changes

  • Plugin is now pinned, not vendored — the config/oxlint-plugins/anti-slop/** tree is deleted in favour of the oxlint-plugin-anti-slop git dependency pinned to dmmulroy/anti-slop#c44ef22; the two deslop-only rules (no-call-only-assertions, no-pass-through-type-alias) are dropped from the config.
  • Generated-dir sync script — config/scripts/sync-anti-slop-plugin.mjs copies the pinned package's src into gitignored .anti-slop-plugin/, deletes the unused effect/ dir, and is wired into postinstall; the audit config's jsPlugin specifier is repointed at it.
  • Scripts and ignores — sync:anti-slop-plugin and audit:anti-slop scripts, .anti-slop-plugin/ in .gitignore/oxfmt ignores, and --no-error-on-unmatched-pattern on the lint-staged commands.

I verified the pin against upstream at the pinned SHA: src/index.ts, src/rules/*, src/shared/* and the root LICENSE all exist where the sync script expects them, src/index.ts does not import effect (so deleting it is safe), and upstream's no-shape-in-symbol-names.ts is byte-identical to the previously vendored copy — the 689 renames remain valid. A planted userShape probe still fires, and after a manual sync the audit is green (0 errors over 24,762 files). The generated dir is also correctly invisible to root oxlint and to typecheck.

⚠️ CI cannot run the anti-slop audit

The audit now loads a repo-root .anti-slop-plugin/index.ts that exists only after postinstall runs the sync script, but PR CI installs with --ignore-scripts and never invokes sync:anti-slop-plugin. pr.yml also has no audit:anti-slop step, so config/scripts/pr-workflow-lint-parity.test.mjs fails on this branch today. Both need wiring before the audit can run in CI.

Technical details
# CI cannot load the pinned anti-slop plugin

## Affected sites
- `config/oxlint-anti-slop.json:7` — specifier resolves to repo-root `.anti-slop-plugin/index.ts`, produced only by `postinstall`.
- `package.json:98` — `postinstall` runs `sync-anti-slop-plugin.mjs`, but CI installs script-free.
- `.github/actions/install-node-dependencies/action.yml:93` — `pnpm install --frozen-lockfile --ignore-scripts`.
- `.github/workflows/pr.yml` — no step runs `audit:anti-slop` or `sync:anti-slop-plugin`; `.github/` has zero `anti-slop` references.

## Evidence
- `pnpm exec vitest run config/scripts/pr-workflow-lint-parity.test.mjs` fails: `pr.yml is missing lint steps: oxlint --config config/oxlint-anti-slop.json src config tests mobile --deny-warnings`.
- Simulating the CI state (dependency installed, `.anti-slop-plugin/` absent): `pnpm run audit:anti-slop` exits 1 with `Failed to load JS plugin: ../.anti-slop-plugin/index.ts` / `Cannot find module`.
- After manually running `node config/scripts/sync-anti-slop-plugin.mjs`, the same command is green (0 errors, 24,762 files).

## Required outcome
- PR CI must materialize `.anti-slop-plugin/` (e.g. run `pnpm run sync:anti-slop-plugin` before the audit step) despite the script-free install.
- Add the `audit:anti-slop` step to `pr.yml` so `pr-workflow-lint-parity.test.mjs` passes.

## Open questions for the human
- Is the `pr.yml` step (and the sync) intentionally deferred to the stacked #20726, or does it belong here? As the branch stands it is red.

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

@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.

Important

The new commit rebases this PR onto an updated nwparker/2x-lint, which now owns the anti-slop plugin wiring — and that wiring is still not connected to CI. package.json puts audit:anti-slop in the pnpm lint chain and runs sync-anti-slop-plugin.mjs from postinstall, but .github/ has no audit:anti-slop step and the composite install uses --ignore-scripts. Re-verified at 63d5be67: pr-workflow-lint-parity.test.mjs still fails, and the audit still cannot resolve .anti-slop-plugin/index.ts under the script-free install. That fix now has to land on the base branch (#20726) rather than in this PR.

Reviewed changes

  • Rebased onto the updated base — the plugin pin, sync-anti-slop-plugin.mjs, .anti-slop-plugin/ ignores, package.json scripts, and lockfile entries are no longer part of this PR's diff; they now live on nwparker/2x-lint.
  • This PR is now the rule flip plus the renames — config/oxlint-anti-slop.json flips anti-slop/no-shape-in-symbol-names from off to error, with the 109-file *shape* → domain-role rename set unchanged from the prior review.

No new reviewable surface was introduced by the rebase: the rule flip and the rename set are byte-for-byte what earlier reviews covered, and the previous threads are empty (the prior finding was posted as review body text, not an inline thread). The only outstanding item is the base-owned CI wiring above.

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

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from 63d5be6 to 2d1e873 Compare September 15, 2026 04:24

@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

  • Wiring moved to the base branch — the plugin pin, sync-anti-slop-plugin.mjs, .anti-slop-plugin/ ignores, package.json scripts, and lockfile entries are gone from this PR's diff; they now live on nwparker/2x-lint.
  • This PR is now the rule flip plus the renames — config/oxlint-anti-slop.json flips anti-slop/no-shape-in-symbol-names from off to error, with the 109-file *shape* → domain-role rename set byte-for-byte the same set earlier reviews covered.

The base-owned CI blocker from the previous review is resolved: pr.yml now runs pnpm run audit:anti-slop, and the audit:anti-slop script itself syncs the plugin before linting, so the script-free CI install no longer leaves .anti-slop-plugin/ missing. Re-verified on this head — pr-workflow-lint-parity.test.mjs passes, and pnpm run audit:anti-slop is green (0 warnings / 0 errors over 24,797 files).

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

Flip `anti-slop/no-shape-in-symbol-names` from "off" to "error" and clear
every violation under src, config, tests and mobile.

What the rule bans
------------------
The case-insensitive substring "shape" in any JS/TS identifier: variables,
functions, parameters, types, type parameters, class members, private names,
object-literal keys and JSX identifiers. The one exemption is a statically
accessed member read owned by another value (`zodObject.shape` is fine), so
third-party APIs stay readable without a suppression.

"Shape" names a value's structure rather than its domain role. `UserShape`,
`validateArgShape` and `errorShape` all tell you the symbol is "an object
with some fields" -- which is already what a type says -- while saying
nothing about what the value is for or who owns it. The rule forces the
name to carry the domain instead.

Violations fixed
----------------
689 violations across 109 files at baseline (verified by re-running the
audit against the pre-change tree with the rule set to "error").

Fix pattern
-----------
Rename for the domain role, not the structure:

  -type FieldShape = 'list' | 'map' | 'whole'
  -const FIELD_SHAPES = { ... } satisfies Record<keyof Observation, FieldShape>
  +type FieldEncoding = 'list' | 'map' | 'whole'
  +const FIELD_ENCODINGS = { ... } satisfies Record<keyof Observation, FieldEncoding>

  -function assertGitPushTargetShape(target: unknown): void
  +function assertValidGitPushTarget(target: unknown): void

  -function describeReadDirPathShape(p: string): ReadDirPathKind
  +function classifyReadDirPath(p: string): ReadDirPathKind

Predicates became statements about the value (`isDeltaShapedProviderFrameKind`
-> `isDeltaProviderFrameKind`, `isDeleteShapedDiscardEntry` ->
`discardDeletesEntryFile`, `isSkillsCliAgentKeyShaped` ->
`isUsableSkillsCliAgentKey`). Type aliases dropped the suffix where the
remaining name was already unambiguous (`GhGraphqlErrorShape` ->
`GhGraphqlError`).

No wire-visible name was renamed: no IPC or RPC channel, stream opcode,
request/response param, persisted field, or i18n key. The `--shape=symlink|copy`
CLI flag read by .github/workflows/skill-update-roundtrip.yml is unchanged --
only the local variable holding it was renamed.

Suppressions added
------------------
* src/renderer/src/components/browser-pane/annotate/ (12 files, file-wide):
  in the screenshot annotator a "shape" is the drawn geometry -- pen, arrow,
  rect, ellipse, highlight. That is a genuine domain noun, and it pervades
  every symbol in the module, so file-wide scope is the honest granularity.
* repo-icon.tsx, repo-header-project-actions.tsx, mobile MobileRepoIcon.tsx:
  lucide-react exports the icon component as `Shapes`. The name is theirs,
  and the matching REPO_LUCIDE_ICONS key is the persisted icon name shared
  with the desktop picker -- renaming it would orphan saved repo icons.
* src/shared/onboarding-state-types.ts, src/shared/constants.ts:
  `shapedSidebar` is a persisted onboarding-checklist field and a telemetry
  enum member; renaming it would orphan saved state.
* telemetry-event-classification.ts, rpc-send-params.ts, repo-update-params.ts,
  ui-update-value-tolerance-params.ts: zod's own `shape` property and its
  exported `ZodRawShape` type. In rpc-send-params.ts, matching the literal
  `shape` property is what selects the ZodObject branch of the conditional type.

No suppression was added merely to avoid a rename. Eight symbols initially
suppressed as "a cross-module refactor outside this change" were proven to
have zero non-TypeScript references repo-wide and renamed instead.

Verified
--------
* Audit reports zero violations; confirmed the rule genuinely fires by
  planting a probe violation.
* node config/scripts/run-typecheck-projects-in-parallel.mjs exits 0.
* 54 test files covering the changed sources: 1010 passed, 2 skipped.
* All 66 removed "shape" identifiers grepped repo-wide across every file
  type; the only survivor is `ZodRawShape`, which is zod's.
* node --check on every changed .mjs; project oxlint clean on all changed
  files; oxfmt is a no-op.

Not machine-verified: the 3 mobile/ files (separate pnpm workspace, its
node_modules is not installed in this worktree), and the electron-, WSL- and
Playwright-gated specs. All are rename-only hunks, read in full.
@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from 2d1e873 to aaa1a33 Compare September 15, 2026 04:38
@nwparker
nwparker deleted the branch nwparker/2x-lint September 15, 2026 04:42
@nwparker nwparker closed this Sep 15, 2026
@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded by #20785 — GitHub auto-closed this when the base branch nwparker/2x-lint was deleted on merge of #20726, and refuses to reopen a force-pushed branch. Same commit, now targeting main.

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