Repository navigation
ref(lint): Enable no-unnecessary-condition in mcp-core - #2123
Merged
JoshuaKGoldberg merged 1 commit intoNov 11, 2026
Merged
Conversation
Turn on typescript/no-unnecessary-condition for packages/mcp-core as the first step of a per-package rollout. Checks the types already guarantee are removed. Where a guard was load-bearing but the type hid it (array and record index access, Object.entries inference, event contexts), the type is made accurate instead so the guard stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
Author
|
@cursor review |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0b5869e. Configure here.
JoshuaKGoldberg
marked this pull request as ready for review
November 10, 2026 14:18
JoshuaKGoldberg
commented
Nov 10, 2026
| @@ -1,5 +1,5 @@ | |||
| export const LIB_VERSION = | |||
| (typeof process !== "undefined" && process.env?.npm_package_version) || | |||
| (typeof process !== "undefined" && process.env.npm_package_version) || | |||
Member
Author
There was a problem hiding this comment.
[Question] Do we know specifically of any customer/user environments where process exists but process.env doesn't? I've never seen such a thing.
Member
There was a problem hiding this comment.
i don't think so. we also have this in place, so we're good:
toolkit/packages/mcp-core/tsdown.config.ts
Lines 21 to 25 in 737f183
betegon
approved these changes
Nov 10, 2026
JoshuaKGoldberg
deleted the
josh/lint-no-unnecessary-condition-mcp-core
branch
November 11, 2026 14:40
This was referenced Nov 11, 2026
This was referenced Nov 12, 2026
betegon
added a commit
that referenced
this pull request
Nov 13, 2026
## Summary This continues #2123 (thanks @JoshuaKGoldberg). It turns on `typescript/no-unnecessary-condition` for `packages/cli/test/**` and fixes what the rule reports there. It uses the same approach as #2123: drop checks the types already guarantee, and where a check matters at runtime, fix the type so the check stays. ### Key Changes - Builds on #2186, which added the test tsconfig - **Fixed the 47 real reports**: - Dropped checks the types guarantee. - Typed mocks that had no parameters (`vi.fn(() => true)` made `calls[0]?.[0]` `never`). - Removed casts like `(event.extra as Record<…>)?.environ` that hid optional fields. Removing the cast with the `?.` crashed a test, so the field now uses its real optional type. - **Fixed one newly visible `require-array-sort-compare`** in `response-cache-store.test.ts`. - **Two reports in `completions.property.test.ts` show up only when `src/generated/completion-targets.json` exists** (after `script/generate.ts`). Lint is clean both with and without the generated files. No sites were deferred to the `src` batch, and there are no disable comments. <!-- junior-request-attribution:start --> via @betegon. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7d5cd1b81d3d817324abd3315e490aad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7d5cd1b81d3d817324abd3315e490aad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7d5cd1b81d3d817324abd3315e490aad/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: bete <28983162+betegon@users.noreply.github.com>
This was referenced Nov 13, 2026
betegon
added a commit
that referenced
this pull request
Nov 13, 2026
Continues #2123 (thanks @JoshuaKGoldberg). This is the first of three PRs that split #2196 so each part can be reviewed on its own. It turns on `typescript/no-unnecessary-condition` for `packages/cli/script/**` and fixes what the rule reports there. ### What's in it - `.oxlintrc.json`: adds the rule to the existing `packages/cli/script/**/*.ts` override. - `packages/cli/script/tsconfig.json` (new): extends `../tsconfig.json`. Without it, type-aware lint checked scripts against an inferred project with `noUncheckedIndexedAccess` off, which reported false positives (same fix as the test tsconfig in #2186). - 8 scripts: regex groups and array lookups use `.at(i)` so their `undefined` checks stay. It also drops checks the types already guarantee: `command.parameters?.`, `args.with?.`, and a `kind === "tuple"` check after the narrowing that already rules out every other kind. ### Please check - `script/lib/output-schema-fields.ts`: `valibotTypeToString` now calls `unwrapPipe(input)` without the `input ?` guard. Its parameter type isn't nullable. - `script/generate-sdk.ts`: `derivePositional` drops `params.kind === "tuple"` because the earlier branches already handled every other kind. The other two PRs cover the CLI runtime code and the API-facing code. The code is the same as in #2196. <!-- junior-request-attribution:start --> via @betegon. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A5958cecb5dcc235a4bb8f00d1688c52f --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A5958cecb5dcc235a4bb8f00d1688c52f) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A5958cecb5dcc235a4bb8f00d1688c52f/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> 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.
Turns on
typescript/no-unnecessary-conditionfor justpackages/mcp-core, since there are a lot of violations in the repo.It drops checks the types already guarantee. Where a guard is needed at runtime but the types hid that, it fixes the types (checked against the Sentry source) so the guard stays. Just to be safe.