Repository navigation
ref(lint): Enable no-unnecessary-condition outside the CLI - #2194
Open
sentry-junior[bot] wants to merge 4 commits into
Open
sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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
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.
Continues #2123 from @JoshuaKGoldberg. That PR turned on
typescript/no-unnecessary-conditionfor justpackages/mcp-core. This one turns it on for every other package exceptpackages/cli. It fixes 63 violations in 31 files acrossdocs-mcp,mcp-cloudflare,mcp-test-client,toolkit-core,logger,smoke-tests, andscripts/. 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, thentest). 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-cloudflareEnv.AIis now optional./api/searchhas a tested 503 path for a missing binding.mcp-cloudflareisValidMessagereadspartsasunknown. Persisted chat comes from localStorage, andmigrateMessagepasses unknown shapes through for validation to reject.mcp-test-clientoauthClientsis nowPartial<Record<…>>, so host lookups can miss.docs-mcpFEATURE_TO_SUBPATHis nowPartial<Record<…>>.searchPages(...)[0], theresourcequery param, and the tool-result and AutoRAG content indexes use.at().docs-mcpfeatures agent treats the Mastraobjectas possibly undefined. Mastra resolves it toundefinedwhen structured output never finishes.mcp-test-clientstringifyUnknownuses||becauseJSON.stringifycan returnundefinedeven though its type saysstring.toolkit-coreunwrapParenGroupsusesfor…ofinstead offorEach. TypeScript can then see thatchangedgets set, which removes a false positive.ADVERTISE_AUTHORIZATION_RESPONSE_ISS_PARAMETER_SUPPORTEDis typedbooleanso the toggle and its TODO stay.loggerflattenAttributekeeps itsvalue === nullcheck behind a targeted disable.@sentry/loggeris published, and JavaScript callers can passnull.Behavior changes worth a look: the AutoRAG search route now trusts Cloudflare's declared
data/attributesshape (a malformed payload falls into the existing 500 handler), andmcp-test-clientdrops arl.question() === nullcheck becausereadline/promisesnever resolvesnull(EOF is still handled in thecatch).via @betegon.
--
View Session [Sentry]