chore: fix 87 eslint warnings across the codebase#7112
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
We detected some changes at Caution DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release. |
There was a problem hiding this comment.
Pull request overview
Mechanical lint cleanups to reduce ESLint warning noise across the TypeScript/React CLI codebase, primarily by adopting nullish-coalescing patterns and removing stale ESLint suppressions.
Changes:
- Replaced many
||/if (!x) x = ypatterns with??,??=, and related refactors to satisfyprefer-nullish-coalescing. - Removed stale
eslint-disabledirectives and added targeted suppressions where non-Error throws/rejects are intentional. - Updated a couple of
Promise.reject(...)sites in production code to always reject withErrorinstances.
Reviewed changes
Copilot reviewed 60 out of 60 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-cloudflare/src/tunnel.ts | ??= for URL detection |
| packages/e2e/setup/auth.ts | Remove stale eslint disable |
| packages/cli/src/index.ts | Remove stale eslint disable |
| packages/cli-kit/src/public/node/ui.tsx | isTTY coalescing refactor |
| packages/cli-kit/src/public/node/themes/factories.ts | Use ?? for asset sizing |
| packages/cli-kit/src/public/node/themes/conf.ts | Lazy init via ??= |
| packages/cli-kit/src/public/node/themes/api.ts | Remove stale eslint disable |
| packages/cli-kit/src/public/node/serial-batch-processor.ts | Lazy start via ??= |
| packages/cli-kit/src/public/node/result.ts | Suppress intentional non-Error throw |
| packages/cli-kit/src/public/node/path.ts | Use ?? for INIT_CWD |
| packages/cli-kit/src/public/node/os.ts | Env var selection via ?? |
| packages/cli-kit/src/public/node/mimes.ts | Use ?? fallback |
| packages/cli-kit/src/public/node/local-storage.test.ts | Remove stale eslint disables |
| packages/cli-kit/src/public/node/http.ts | Ensure rejected values are Error |
| packages/cli-kit/src/public/node/hooks/prerun.ts | Use ??= for command parsing |
| packages/cli-kit/src/public/node/global-context.ts | Lazy init via ??= |
| packages/cli-kit/src/public/node/error-handler.ts | Ensure rejected values are Error |
| packages/cli-kit/src/public/node/dot-env.ts | Use ?? for regex capture fallback |
| packages/cli-kit/src/public/node/api/admin.ts | ??= for API version resolution |
| packages/cli-kit/src/public/node/analytics.ts | ?? defaults for metrics fields |
| packages/cli-kit/src/private/node/ui/hooks/use-select-state.ts | Use ??= for first item |
| packages/cli-kit/src/private/node/ui/components/TokenizedText.tsx | Use ?? for link label fallback |
| packages/cli-kit/src/private/node/ui/components/Table/Table.tsx | Use ?? for header fallbacks |
| packages/cli-kit/src/private/node/conf-store.ts | Lazy init via ??= |
| packages/app/src/cli/utilities/json-schema.ts | Use ?? for errors array |
| packages/app/src/cli/utilities/extensions/theme/host-theme-manager.ts | Use ??= for lazy create |
| packages/app/src/cli/utilities/developer-platform-client/partners-client.ts | Singleton init via ??= |
| packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts | Singleton init via ??= |
| packages/app/src/cli/services/webhook/trigger-options.ts | Use ?? for prompts/defaults |
| packages/app/src/cli/services/payments/extension-config-builder.ts | Use ?? for context resolution |
| packages/app/src/cli/services/local-storage.ts | Lazy init via ??= |
| packages/app/src/cli/services/init/template/npm.ts | Use ?? for deps object |
| packages/app/src/cli/services/info.test.ts | Use ?? in object spread |
| packages/app/src/cli/services/generate.ts | Use ?? for registrationLimit |
| packages/app/src/cli/services/function/build.ts | Use ?? for targeting default |
| packages/app/src/cli/services/flow/serialize-partners-fields.ts | Use ?? for description |
| packages/app/src/cli/services/extensions/common.ts | Use ?? for template path |
| packages/app/src/cli/services/dev/update-extension.test.ts | Inline suppress reject-errors in tests |
| packages/app/src/cli/services/dev/select-app.ts | Remove negated condition |
| packages/app/src/cli/services/dev/processes/uninstall-webhook.ts | Use ?? fallbacks |
| packages/app/src/cli/services/dev/graphiql/server.ts | Targeted lint suppressions + ??= |
| packages/app/src/cli/services/dev/extension/localization.ts | Use ?? over ternary |
| packages/app/src/cli/services/dev.ts | Use ??= for port selection |
| packages/app/src/cli/services/context/identifiers-extensions.ts | Use ?? for URI fallback |
| packages/app/src/cli/services/context/breakdown-extensions.ts | Use ?? for version fallback |
| packages/app/src/cli/services/build/steps/include-assets/copy-source-entry.ts | Remove negated condition |
| packages/app/src/cli/services/build/steps/include-assets-step.ts | Remove negated condition |
| packages/app/src/cli/services/app/select-app.ts | Use ?? for version/modules defaults |
| packages/app/src/cli/services/app-logs/utils.ts | Prefer ?? over ` |
| packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.tsx | Use ?? for render fallback |
| packages/app/src/cli/services/app-logs/logs-command/render-json-logs.ts | Use ?? for cursor |
| packages/app/src/cli/services/app-logs/logs-command/poll-app-logs.test.ts | Use ?? defaults in test helper |
| packages/app/src/cli/services/app-logs/dev/poll-app-logs.ts | Use ?? for cursor |
| packages/app/src/cli/services/app-context.ts | Use ??= for remoteApp fetch |
| packages/app/src/cli/prompts/init/init.ts | Use ??= and ?? fallbacks |
| packages/app/src/cli/prompts/generate/extension.ts | Use ?? for name fallback |
| packages/app/src/cli/models/app/identifiers.ts | Use ??= for dotenv init |
| packages/app/src/cli/commands/app/webhook/trigger.ts | Use ?? for secret fallback |
| packages/app/src/cli/commands/app/function/run.ts | Use ?? for export fallback |
| packages/app/src/cli/commands/app/app-logs/sources.ts | Remove negated condition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
07d02b4 to
5965a70
Compare
d167d8f to
731c405
Compare
Coverage report
Test suite run success3993 tests passing in 1527 suites. Report generated by 🧪jest coverage report action from ccb06f4 |
7d8f828 to
b23df55
Compare
Resolve the majority of eslint warnings (107 → 20 remaining): - Replace 72 || with ?? (prefer-nullish-coalescing) for safer null/undefined handling - Replace 18 if-assign patterns with ??= for conciseness - Replace 4 ternaries with ?? where equivalent - Remove 4 stale eslint-disable directives - Fix 2 prefer-promise-reject-errors by wrapping in Error - Fix 4 no-negated-condition by flipping if/else branches - Suppress 1 only-throw-error in Result pattern (intentional generic TError) - Suppress 5 prefer-promise-reject-errors in tests (intentional non-Error rejections) - Suppress 1 prefer-nullish-coalescing where empty string fallthrough is intended The 20 remaining warnings are all switch-exhaustiveness-check which require domain-specific decisions about handling new enum/union variants. Co-authored-by: Claude Code <claude-code@anthropic.com>
b23df55 to
ccb06f4
Compare

What
Fix 87 out of 107 eslint warnings across the codebase. Zero behavior changes — all mechanical refactors.
Why
The lint output was noisy with warnings that obscured real issues. Cleaning them up makes CI output cleaner and establishes a healthier baseline. The remaining 20 warnings are all
switch-exhaustiveness-checkwhich require domain-specific decisions about handling new enum/union variants.Changes
prefer-nullish-coalescing— 72||→??replacementsUsing
??instead of||is safer because it only coalescesnull/undefined, not other falsy values like0,"", orfalse. The eslint rule only flags cases where the types make this substitution safe.One case was intentionally kept as
||with a suppression comment:resolveGraphiQLKeyingraphiql/server.tswhere an empty string after.trim()should fall through to the derived key.prefer-nullish-coalescing— 18if (!x) x = y→x ??= yReplaces verbose null-guard assignment patterns with the concise nullish coalescing assignment operator. Applied to singleton patterns, lazy initialization, and default value assignments.
prefer-nullish-coalescing— 4 ternary →??Replaces
x ? x : fallbackternaries with the equivalentx ?? fallback.Stale
eslint-disabledirectives — 4 removedRemoved unused suppression comments in:
cli-kit/src/public/node/local-storage.test.ts(2×no-explicit-any)cli-kit/src/public/node/themes/api.ts(no-non-null-assertion)cli/src/index.ts(specific-imports-in-bootstrap-code)e2e/setup/auth.ts(no-restricted-imports)prefer-promise-reject-errors— 2 fixed, 5 suppressedFixed in production code (
error-handler.ts,http.ts) by wrapping rejection values innew Error().Suppressed in
update-extension.test.ts(5 occurrences) where tests intentionally reject with non-Error objects to exercise error-shape handling logic.only-throw-error— 1 suppressedIn
result.ts, thevalueOrBug()method on theErrclass throwsthis.errorwhich is genericTError— not necessarily anErrorinstance. This is intentional for the Result pattern, so suppressed with a comment.no-negated-condition— 4 fixedFlipped if/else branches to remove negations for readability:
app-logs/sources.ts—!isEmpty()→isEmpty()with swapped branchesinclude-assets-step.ts—!== undefinedternary →=== undefinedternarycopy-source-entry.ts—!== undefined→=== undefinedwith swapped branchesselect-app.ts—!app→appwith swapped branchesBefore / After
prefer-nullish-coalescingswitch-exhaustiveness-checkeslint-disableprefer-promise-reject-errorsonly-throw-errorno-negated-conditionTesting
pnpm lintpasses with 0 errors