Skip to content

ref(lint): Enable no-unnecessary-condition outside the CLI - #2194

Open
sentry-junior[bot] wants to merge 4 commits into
mainfrom
junior/lint-no-unnecessary-condition-non-cli
Open

sentry-junior[bot] wants to merge 4 commits into
mainfrom
junior/lint-no-unnecessary-condition-non-cli

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Continues #2123 from @JoshuaKGoldberg. That PR turned on typescript/no-unnecessary-condition for just packages/mcp-core. This one turns it on for every other package except packages/cli. It fixes 63 violations in 31 files across docs-mcp, mcp-cloudflare, mcp-test-client, toolkit-core, logger, smoke-tests, and scripts/. Packages that already pass (games-api, codemod-cli3to4, mcp-server, mcp-server-evals, mcp-server-mocks) are in the override too, so they stay clean.

The CLI has about 380 violations, so it goes in separate batches (src+script, then test). Once those land, the per-path overrides can collapse into one root rule.

Like #2123, this drops checks the types already guarantee. Where a guard is still needed at runtime but the types hid that, it fixes the types and keeps the guard:

  • mcp-cloudflare Env.AI is now optional. /api/search has a tested 503 path for a missing binding.
  • mcp-cloudflare isValidMessage reads parts as unknown. Persisted chat comes from localStorage, and migrateMessage passes unknown shapes through for validation to reject.
  • mcp-test-client oauthClients is now Partial<Record<…>>, so host lookups can miss.
  • docs-mcp FEATURE_TO_SUBPATH is now Partial<Record<…>>. searchPages(...)[0], the resource query param, and the tool-result and AutoRAG content indexes use .at().
  • docs-mcp features agent treats the Mastra object as possibly undefined. Mastra resolves it to undefined when structured output never finishes.
  • mcp-test-client stringifyUnknown uses || because JSON.stringify can return undefined even though its type says string.
  • toolkit-core unwrapParenGroups uses for…of instead of forEach. TypeScript can then see that changed gets set, which removes a false positive.
  • ADVERTISE_AUTHORIZATION_RESPONSE_ISS_PARAMETER_SUPPORTED is typed boolean so the toggle and its TODO stay.
  • logger flattenAttribute keeps its value === null check behind a targeted disable. @sentry/logger is published, and JavaScript callers can pass null.

Behavior changes worth a look: the AutoRAG search route now trusts Cloudflare's declared data/attributes shape (a malformed payload falls into the existing 500 handler), and mcp-test-client drops a rl.question() === null check because readline/promises never resolves null (EOF is still handled in the catch).

via @betegon.

--

View Session [Sentry]

Turns on `typescript/no-unnecessary-condition` for every package except
`packages/cli`, continuing #2123. The CLI gets its own batches.

Checks the types already guarantee are dropped. Where a guard still
matters at runtime, the types now say so and the guard stays: optional
`AI` binding, `Partial<Record>` lookups, `.at()` for indexes that can
miss, and untrusted persisted chat messages.

Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 13, 2026 6:57pm UTC

Request Review

…ssary-condition-non-cli

# Conflicts:
#	.oxlintrc.json
…ssary-condition-non-cli

# Conflicts:
#	.oxlintrc.json
Set `allowConstantLoopConditions: "only-allowed-literals"` on the
non-CLI no-unnecessary-condition override, and restore the original
`while (true)` loop in mcp-test-client. The loop was changed to
`for (;;)` only to satisfy the rule.

Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 861200ae Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant