Skip to content

ref(lint): Drop unnecessary conditions in cli runtime code - #2249

Open
sentry-junior[bot] wants to merge 3 commits into
mainfrom
junior/lint-nuc-cli-runtime
Open

sentry-junior[bot] wants to merge 3 commits into
mainfrom
junior/lint-nuc-cli-runtime

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Continues #2123 (thanks @JoshuaKGoldberg). This is the second of three PRs that split #2196. It fixes the typescript/no-unnecessary-condition reports in CLI code that doesn't read Sentry API responses. It doesn't touch .oxlintrc.json. The PR that turns the rule on for src is stacked on this one.

The code is the same as in #2196. It drops checks the types already guarantee. Where a check matters at runtime but the types hide that, it widens the type so the check stays.

What's in it (45 files)

  • Terminal and TTY: banner.ts, help.ts, sixel.ts, the new terminal-size.ts, games/snake-terminal.ts, select-ui/terminal.ts, interactive-login.ts. A piped stream has no columns/rows/isRaw/setRawMode, so those fields are optional and the checks stay. A 0×0 terminal still takes the too-small path.
  • Data read from disk or the network: db/migration.ts (legacy JSON config), response-cache-store.ts (cache files from other versions), sourcemap/debug-id.ts (user index maps), sentryclirc-import.ts, telemetry/credential-redaction.ts, event/send.ts (JSON.parse output), and formatters/local.ts (envelope attributes can be null).
  • chunk-loader.ts: Node before 20.12 has no vm.constants.
  • formatters/markdown.ts: renderMarkdown/renderInlineMarkdown accept null/undefined and render them as empty, because marked.lexer(undefined) throws.
  • formatters/colors.ts, monitor/run.ts: Partial<Record<…>> views for lookups with untrusted keys.
  • Variables that a callback, signal handler, or another task sets are declared false as boolean / null as T | null, because control-flow narrowing can't see those writes. Files: local/run.ts, local/server.ts, scan/concurrent.ts, scan/grep.ts, snapshots/archive.ts, telemetry.ts. while (true) loops are now for (;;).
  • Plain dead checks in the rest: db/*, scan/walker.ts, upgrade.ts, delta-upgrade.ts (also drops the redundant getPrimaryUpgradeSource() wrapper), ghcr.ts, introspect.ts, detect-agent.ts, walk-up.ts, release-notes.ts, clipboard.ts, formatters/sql.ts, and the local/*, cli/*, proguard/uuid.ts, wasm-split.ts commands.

Please check

Each removed ?., ??, or truthiness check should be one the declared type really guarantees. Anything that reads disk, env, the network, or TTY state should keep its check through a widened type.

via @betegon.

--

View Session [Sentry]

Fix typescript/no-unnecessary-condition reports in CLI code that does not
read Sentry API responses: terminal and TTY handling, the SQLite cache,
scanners, upgrade and delta-upgrade, telemetry, formatters, and the local
commands. Where a check matters at runtime (piped stdio without TTY
fields, regex groups, map lookups), widen the type so the check stays.
The rule is turned on for src in a follow-up PR. Split out of #2196.

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

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 13, 2026 6:54pm UTC

Request Review

Comment thread packages/cli/src/lib/db/auth.ts Resolved
Restore two guards that the lint cleanup removed:

- `shutdownServer` in the local daemon checks that
  `server.closeAllConnections` exists before calling it, the same check
  `local/run.ts` and `local/server.ts` already use.
- `resolveNightlyChain` skips a `null` manifest again. Manifests are
  registry JSON that binpatch returns unvalidated, so their type is now
  `OciManifest | null`.

Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
Restore the original `signal.aborted`, `child.exitCode`, and
`state.earlyExit` re-checks and `while (true)` loops in run.ts,
server.ts, scan/concurrent.ts, scan/walker.ts, upgrade.ts, walk-up.ts,
and receiver-ingest.ts. The helpers existed only to satisfy
no-unnecessary-condition. The PR that turns the rule on for
packages/cli/src handles those sites in lint config instead.

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

This branch was previously deployed

1 inactive deployment
Preview — 94b6e039 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