fix(sdk): promote three bug-catching lint rules to error and fix the fallout - #2945
Open
alex-connolly wants to merge 1 commit into
Open
fix(sdk): promote three bug-catching lint rules to error and fix the fallout#2945alex-connolly wants to merge 1 commit into
alex-connolly wants to merge 1 commit into
Conversation
…fallout Follow-up to #2944. That bug shipped because the rule which would have caught it was set to `warn`, so nothing failed CI. This promotes three rules that catch runtime defects rather than style preferences, and clears the codebase of them so the gate stays green. Promoted to error: - typescript/no-non-null-asserted-optional-chain — `a?.b!` is undefined at runtime while typed as present - typescript/no-base-to-string — stringifying an object yields "[object Object]", silently gutting error messages and analytics payloads - eslint/preserve-caught-error — rethrowing without `cause` discards the original stack Two real defects surfaced by this: - tokenBridge.getFee passed `async () => {...}` to Promise.all without invoking it, so Promise.all resolved the function object and the chain-id validation never ran. Note this restores validation that has been dead: callers passing mismatched chain ids will now get the intended error. - PayWithCoins reported sale failures via `error.toString()` on a SignOrderError ({ type, data }), so every failure event carried the literal string "[object Object]" instead of the failure type. Also fixed: an undefined provider could reach NetworkSwitchDrawer via `from?.browserProvider!`; OrderSummary dereferenced a possibly-missing smartCheckoutResult; SaleWidget built block-explorer links containing "undefined"; fundingBalanceFees pushed fees with a missing required token. `oxlint --fix` was not used. On this repo it rewrites `.sort()` to `.toSorted()` (ES2023, while tsconfig targets ES2022), drops entries from React dependency arrays, and leaves dead whitespace. Every change here is hand-written. Deferred, with counts, to keep this reviewable: - no-floating-promises (230) — the rule closest to #2944's root cause. Needs per-site judgment (`void` for fire-and-forget, real handling for user-triggered actions), so it gets its own PR. - no-unsafe-enum-comparison (93) — needs a canonical type per comparison - react-hooks/exhaustive-deps (235) — every fix changes render behaviour Do not enable the `radix` rule. It is off (style category), and its autofix is what caused #2944. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
View your CI Pipeline Execution ↗ for commit 06508eb
☁️ Nx Cloud last updated this comment at |
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.
Follow-up to #2944.
Why
#2944 shipped because the rule that would have caught it was set to
warn, so nothing failed CI. This promotes three rules that catch runtime defects rather than style preferences, and clears the codebase so the gate stays green.typescript/no-non-null-asserted-optional-chaina?.b!— undefined at runtime, typed as presenttypescript/no-base-to-string"[object Object]"in error messages and analyticseslint/preserve-caught-errorcause, discarding the original stackTwo real defects surfaced
1. Bridge fee validation has been dead code.
tokenBridge.getFeepassed an uninvoked async function toPromise.all, so it resolved the function object andvalidateChainIdsnever ran:2. Sale failure analytics reported nothing.
PayWithCoinscallederror.toString()on aSignOrderError({ type, data }, not anError), so everycheckoutPrimarySalePaymentMethods_FailEventFailedevent carried the literal string"[object Object]". Now sendserror.type.Also fixed
NetworkSwitchDrawerviafrom?.browserProvider!— the same component fix(checkout-widgets): parse hex chain ids so the bridge stops demanding a network switch #2944 hardensOrderSummarydereferenced a possibly-missingsmartCheckoutResultSaleWidgetbuilt block-explorer links containingundefinedfundingBalanceFeespushed fees with a missing requiredtokenOn
oxlint --fixNot used. It is not safe on this repo. A trial run produced:
.sort()→.toSorted()in 11 places — ES2023 array methods (Chrome 110 / Safari 16.4 / Node 20), shipped unpolyfilled. Note this is worse than a compile error:widgets-libsets"lib": ["dom", "dom.iterable", "esnext"], sotoSortedtype-checks there and would have shipped silently. It only fails to compile in packages that inherittarget: ES2022fromtsconfig.base.json(orderbook, wallet, checkout/sdk, …). Verified both ways.cancellablePromise.tsWhich is the same failure mode as #2944: an autofix applied without review. Every change here is hand-written.
Deferred, with counts
no-floating-promisesvoidfor genuine fire-and-forget, real handling for user-triggered actions. Blanket-voiding would silence the signal rather than fix it. Own PR.no-unsafe-enum-comparisonreact-hooks/exhaustive-depsDo not enable the
radixrule. It is currently off (stylecategory), and its autofix is what caused #2944.Testing
pnpm typecheckclean across widgets-lib, orderbook, wallet, bridge-sdk, dex-sdkoxlint packages/reports 0 errors🤖 Generated with Claude Code