Repository navigation
ref(lint): Drop unnecessary conditions in cli runtime code - #2249
Open
sentry-junior[bot] wants to merge 3 commits into
Open
sentry-junior[bot] wants to merge 3 commits into
sentry-junior[bot] wants to merge 3 commits into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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
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 (thanks @JoshuaKGoldberg). This is the second of three PRs that split #2196. It fixes the
typescript/no-unnecessary-conditionreports in CLI code that doesn't read Sentry API responses. It doesn't touch.oxlintrc.json. The PR that turns the rule on forsrcis 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)
banner.ts,help.ts,sixel.ts, the newterminal-size.ts,games/snake-terminal.ts,select-ui/terminal.ts,interactive-login.ts. A piped stream has nocolumns/rows/isRaw/setRawMode, so those fields are optional and the checks stay. A 0×0 terminal still takes the too-small path.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.parseoutput), andformatters/local.ts(envelope attributes can benull).chunk-loader.ts: Node before 20.12 has novm.constants.formatters/markdown.ts:renderMarkdown/renderInlineMarkdownacceptnull/undefinedand render them as empty, becausemarked.lexer(undefined)throws.formatters/colors.ts,monitor/run.ts:Partial<Record<…>>views for lookups with untrusted keys.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 nowfor (;;).db/*,scan/walker.ts,upgrade.ts,delta-upgrade.ts(also drops the redundantgetPrimaryUpgradeSource()wrapper),ghcr.ts,introspect.ts,detect-agent.ts,walk-up.ts,release-notes.ts,clipboard.ts,formatters/sql.ts, and thelocal/*,cli/*,proguard/uuid.ts,wasm-split.tscommands.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]