Skip to content

Conversation

@crutch12
Copy link
Contributor

@crutch12 crutch12 commented Nov 30, 2025

Summary

I've checked your https://github.com/cowprotocol/cowswap/blob/develop/CONTRIBUTING.md file and it looks great!

And it says:

Critical Architectural Rule: The common/ directory is leaf-only and MUST NOT depend on modules/. This ensures clean dependency flow and prevents circular dependencies.

But, as I can see, a lot of cowswap-frontend/common files (33) do imports from cowswap-frontend/modules.

Therefore I wrote some eslint rules (no-restricted-imports) to restrict such imports in future.

To Test

  1. Open any cowswap-frontend/common/** .ts file (e.g. apps/cowswap-frontend/src/common/utils/fetch.ts)
  2. Add import from 'modules' (e.g. import { useAccountModalState } from 'modules/account')
  3. Now you should see eslint error: 'modules/account' import is restricted from being used by a pattern. eslint(no-restricted-imports).

If you see an error, the rule works correctly.

Background

Also I added eslint-disable no-restricted-imports marks in current files (33) to ignore this eslint error for now.
But rewrite those files would be better ofc. (is it a good idea?)

Summary by CodeRabbit

  • Chores
    • Updated ESLint configuration to enforce stricter import restrictions within the frontend common code.
    • Added temporary lint suppression directives across multiple files to preserve existing imports and silence new import restrictions (includes TODO notes for future refactors).

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 30, 2025

@crutch12 is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 30, 2025

Walkthrough

Adds file-level ESLint disable comments for no-restricted-imports across many cowswap-frontend common files, introduces a few trailing-comma formatting changes in select hooks, and updates ESLint configuration and a library ESLint extends path. No runtime or API logic changes.

Changes

Cohort / File(s) Summary
Containers with ESLint disable
apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx, apps/cowswap-frontend/src/common/containers/CoWAmmBanner/types.ts, apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx, apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx
Added /* eslint-disable no-restricted-imports */ at top of files. No functional changes.
Cancel-order hooks & helpers
apps/cowswap-frontend/src/common/hooks/useCancelOrder/onChainCancellation.ts, .../useGetOnChainCancellation.ts, .../useSendOnChainCancellation.ts
Added ESLint disable comments; onChainCancellation.ts also added trailing commas in two function parameter lists and in two error-log calls (formatting only).
Utility & context hooks
apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts, useEnhancedActivityDerivedState.ts, useGetExecutedBridgeSummary.ts, useGetMarketDimension.ts, useGetSurplusFiatValue.ts, useOnSelectNetwork.tsx, useSwapAndBridgeContext.ts, useSwapAndBridgeOverview.ts, useSwapResultsContext.ts
Added no-restricted-imports ESLint disables. No logic changes.
Rate / price hooks
apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts, apps/cowswap-frontend/src/common/pure/ExecutionPrice/hooks/useExecutionPriceFiat.ts
Added ESLint disables and minor trailing-comma formatting in function parameters / argument lists only. No behavioral changes.
Pure components with ESLint disable
apps/cowswap-frontend/src/common/pure/CoWAmmBannerContent/index.tsx, .../ConfirmationPendingContent/ConfirmationPendingContentShell.tsx, .../CurrencyInputPanel/CurrencyInputPanel.tsx, .../CurrencyInputPanel/types.ts, .../ReceiveAmount/index.tsx, .../ReceiveAmountInfo/index.tsx
Added no-restricted-imports ESLint disables. No runtime changes.
Updaters (global & orders)
apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts, SentryUpdater.ts, WidgetTokensUpdater.tsx, orders/CancelledOrdersUpdater.ts, orders/OrdersFromApiUpdater.ts, orders/PendingOrdersUpdater.ts, orders/SpotPricesUpdater.ts, orders/UnfillableOrdersUpdater/.../useUpdateIsUnfillableFlag.ts, orders/UnfillableOrdersUpdater/.../UnfillableOrderUpdater.ts
Added no-restricted-imports ESLint disables across updater files. No functional changes.
Utils with ESLint disable
apps/cowswap-frontend/src/common/utils/doesOrderHavePermit.ts
Added no-restricted-imports ESLint disable. No functional changes.
ESLint configuration changes
eslint.config.js
Added a rule restricting imports matching modules/* from apps/cowswap-frontend/src/common/**/*.{ts,tsx,js,jsx} (duplicate/redundant restriction blocks present).
Library ESLint extends path
libs/wallet-provider/.eslintrc.json
Changed extends from ../../.eslintrc.json to ../../eslint.config.js. No behavioral changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on:
    • Justification for broad no-restricted-imports suppression across many common files.
    • The new import restriction rule in eslint.config.js (check duplication/overlap).
    • Confirm trailing-comma edits in onChainCancellation.ts, useRateInfoParams.ts, and useExecutionPriceFiat.ts are intentional formatting only.

Possibly related PRs

Suggested reviewers

  • shoom3301
  • limitofzero

Poem

🐰 I hopped through files, a quiet little chore,
I whispered "eslint" and nudged commas more,
Modules kept tidy, rules set at the door,
A soft linty hop — then back to my burrow. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding ESLint restrictions to prevent modules imports inside the common directory.
Description check ✅ Passed The description provides clear context (architectural rule violation), implementation approach (ESLint rules), testing instructions, and acknowledges technical debt (TODO comments). All key sections are adequately covered.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fd90e5 and 7c38493.

📒 Files selected for processing (3)
  • apps/cowswap-frontend/src/common/hooks/useGetExecutedBridgeSummary.ts (1 hunks)
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx
  • apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useGetExecutedBridgeSummary.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@crutch12
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@crutch12
Copy link
Contributor Author

recheck

github-actions bot added a commit that referenced this pull request Nov 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (11)
apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts (1)

1-1: Same note on file-wide no-restricted-imports disable

As in common/pure/ReceiveAmount/index.tsx, a file-level disable will also exempt any future modules/* imports added here. If you later tighten this up, consider per-import eslint-disable-next-line no-restricted-imports comments instead.

apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx (1)

1-1: File-wide suppression continues to allow new modules/* imports

This follows the same pattern as other common/* files: the top-of-file disable will also cover any new modules/* imports added here. If/when you start paying down the TODOs in this component, it may be worth scoping the disable to just the offending imports.

apps/cowswap-frontend/src/common/updaters/orders/CancelledOrdersUpdater.ts (1)

1-1: Legacy modules/* dependency masked for the whole file

The file-level no-restricted-imports disable correctly unblocks the existing modules/orders usage, but it will also hide any new restricted imports added later in this updater. Same consideration as other common/* files: if you want stricter enforcement over time, narrowing the disable to just the modules/* import lines would help.

apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/hooks/useUpdateIsUnfillableFlag.ts (1)

1-1: Consistent with other legacy exceptions for modules/* imports

This file-wide suppression matches the approach in other common/* files. Just be aware it will also cover any new modules/* imports added here until the TODO is addressed.

apps/cowswap-frontend/src/common/pure/ConfirmationPendingContent/ConfirmationPendingContentShell.tsx (1)

1-1: File-level no-restricted-imports disable for existing modules/account usage

Same as other common/* files: this unblocks the current modules/account import but will also hide any future modules/* imports in this file until it’s refactored.

apps/cowswap-frontend/src/common/hooks/useGetSurplusFiatValue.ts (1)

1-1: Legacy modules/* import exemption mirrors other surplus/bridge hooks

This file-wide disable keeps the existing modules/usdAmount dependency working but will also allow any additional modules/* imports in this file without lint errors until you tackle the TODO.

apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx (1)

1-1: Same note about scoping the no-restricted-imports disable

This mirrors the pattern in useEnhancedActivityDerivedState: if feasible, prefer an inline // eslint-disable-next-line no-restricted-imports on the modules/* imports instead of disabling the rule for the whole file, so other restricted imports remain enforced.

apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx (1)

1-1: Scoped disable would keep other no-restricted-imports protections active

As with the other common files, you might eventually want to replace the file-level /* eslint-disable no-restricted-imports */ with inline // eslint-disable-next-line no-restricted-imports on the modules/* imports, so the rule still guards against other restricted imports in this file.

apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts (1)

1-1: File-level no-restricted-imports disable mirrors other common files

Same comment as above: for long-term cleanliness, consider scoping the disable to the modules/trade import line rather than disabling no-restricted-imports for the entire file.

apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts (1)

1-1: Top-level no-restricted-imports disable is consistent with the rest of the PR

Matches the pattern in other common files. When you eventually refactor away modules/orders here, consider also tightening this to an inline // eslint-disable-next-line no-restricted-imports on that import (or removing it entirely) to restore full lint coverage.

apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx (1)

1-1: Same scoped-disable consideration for CoWAmmBanner

Given the multiple modules/* imports here, the file-wide disable is understandable; just keep in mind it also disables other no-restricted-imports checks. Once these imports are moved out of common, you can drop or narrow this directive.

🧹 Nitpick comments (9)
apps/cowswap-frontend/src/common/utils/doesOrderHavePermit.ts (2)

1-1: Improve the TODO comment for clarity and actionability.

The ESLint disable approach aligns with the PR's enforcement strategy, but the TODO could be more specific to guide the refactoring effort.

Consider updating the TODO to be more actionable:

-/* eslint-disable no-restricted-imports */ // TODO: Don't use 'modules' import
+/* eslint-disable no-restricted-imports */ // TODO: Refactor to pass hooks as parameter or move getAppDataHooks to common/

4-4: Verify that the modules/appData dependency cannot be restructured.

This file violates the documented architectural rule that common/ must not import from modules/. While this PR intentionally suppresses existing violations, you should evaluate if the dependency can be eliminated or moved to the common/ directory.

Possible refactoring approaches:

  1. Pass hooks or appData as parameters to these functions instead of computing them internally.
  2. Move the getAppDataHooks logic into common/ if it is general-purpose utility code.
  3. Create an abstraction in common/ that these functions depend on, with modules/ providing the implementation separately.
apps/cowswap-frontend/src/common/pure/ExecutionPrice/hooks/useExecutionPriceFiat.ts (1)

1-1: Temporary suppression acknowledged — offer to help refactor.

This eslint-disable comment aligns with the PR's objective to temporarily suppress architectural violations. However, this file imports useUsdAmount from modules/usdAmount (line 5), violating the documented rule that common/ must not depend on modules/.

Would you like me to help refactor this file to remove the modules dependency? I can propose a solution that moves the USD amount conversion logic to avoid the architectural violation.

apps/cowswap-frontend/src/common/pure/ReceiveAmount/index.tsx (1)

1-1: Scope no-restricted-imports disable more narrowly if you want stricter enforcement

Disabling no-restricted-imports for the whole file means any new modules/* imports added here later will also be silently allowed. If you want the new rule to catch regressions even in legacy files, consider switching to // eslint-disable-next-line no-restricted-imports just on the specific modules/* import lines when you next touch this file, and keep the TODO as a reminder to refactor them away.

apps/cowswap-frontend/src/common/pure/ConfirmationPendingContent/ConfirmationPendingContentShell.tsx (1)

27-45: Remove redundant {modalMode} child for clarity

Inside the JSX, {modalMode} (Line 29) doesn’t render anything (booleans are ignored by React), so it’s effectively a no-op and a bit confusing to readers. You can safely remove that expression.

apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts (1)

1-1: Scope the no-restricted-imports disable to the offending import instead of the whole file

The file-wide disable is understandable for now, but it also turns off all other no-restricted-imports protections here. Consider narrowing it to just the modules/* import (e.g., // eslint-disable-next-line no-restricted-imports on that line) so future restricted imports in this file still get caught.

apps/cowswap-frontend/src/common/hooks/useGetExecutedBridgeSummary.ts (1)

1-12: Lint suppression plus executed summary selection both look reasonable

  • The added getExecutedSummaryDataWithSurplusToken usage inside the useMemo looks consistent: it’s only called when intermediateToken exists and dependencies [order, intermediateToken] are correct.
  • Same as other common files, the file-level /* eslint-disable no-restricted-imports */ is fine as a temporary workaround, but longer term you may want to restrict it to just the modules/trade import so other restricted imports still get caught.
apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts (1)

1-1: File-wide no-restricted-imports disable is acceptable as a temporary escape hatch

This aligns with the PR goal of unblocking existing modules imports from common. As follow‑up, consider narrowing the scope later (e.g., eslint-disable-next-line on the specific modules import) so new violations in this file don’t slip through unnoticed.

Please double‑check that this file is listed among the known temporary exceptions you plan to refactor away from modules imports.

apps/cowswap-frontend/src/common/hooks/useCancelOrder/onChainCancellation.ts (1)

1-1: Temporary no-restricted-imports disable is consistent with the migration strategy

Using a file-level disable here matches the PR’s approach to existing modules imports from common. As with other files, it would be good to eventually either:

  • remove this directive once the modules import is eliminated, or
  • narrow it to an inline eslint-disable-next-line on that specific import to avoid hiding new violations.

Confirm that this file is tracked in whatever list/issue you’re using for cleaning up modules imports from common.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd90c98 and 7fd90e5.

📒 Files selected for processing (36)
  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/types.ts (1 hunks)
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/onChainCancellation.ts (4 hunks)
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useGetOnChainCancellation.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useSendOnChainCancellation.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useGetExecutedBridgeSummary.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useGetMarketDimension.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useGetSurplusFiatValue.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts (3 hunks)
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts (1 hunks)
  • apps/cowswap-frontend/src/common/pure/CoWAmmBannerContent/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/pure/ConfirmationPendingContent/ConfirmationPendingContentShell.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/types.ts (1 hunks)
  • apps/cowswap-frontend/src/common/pure/ExecutionPrice/hooks/useExecutionPriceFiat.ts (2 hunks)
  • apps/cowswap-frontend/src/common/pure/ReceiveAmount/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/SentryUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/CancelledOrdersUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/OrdersFromApiUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/SpotPricesUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/hooks/useUpdateIsUnfillableFlag.ts (1 hunks)
  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/updaters/UnfillableOrderUpdater.ts (1 hunks)
  • apps/cowswap-frontend/src/common/utils/doesOrderHavePermit.ts (1 hunks)
  • eslint.config.js (1 hunks)
  • libs/wallet-provider/.eslintrc.json (1 hunks)
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 6234
File: libs/tokens/src/index.ts:1-4
Timestamp: 2025-09-11T08:25:51.460Z
Learning: In the cowprotocol/cowswap project, there is currently no SSR (Server-Side Rendering) support, so localStorage access at module import time does not cause SSR-related issues.
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useGetOnChainCancellation.ts
  • apps/cowswap-frontend/src/common/hooks/useGetMarketDimension.ts
  • apps/cowswap-frontend/src/common/updaters/orders/CancelledOrdersUpdater.ts
  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts
  • apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useSendOnChainCancellation.ts
  • apps/cowswap-frontend/src/common/pure/ConfirmationPendingContent/ConfirmationPendingContentShell.tsx
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx
📚 Learning: 2025-06-16T15:58:00.268Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5830
File: apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/index.tsx:1-2
Timestamp: 2025-06-16T15:58:00.268Z
Learning: JSX can be imported as a named export from React in modern React versions (React 17+). The import `import { JSX } from 'react'` is valid and does not cause compilation errors.

Applied to files:

  • apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx
📚 Learning: 2025-07-24T16:42:53.154Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx:23-33
Timestamp: 2025-07-24T16:42:53.154Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx, the use of toFixed(2) for percentage formatting in tooltip content is intentional and differs from the banner message formatting that uses toSignificant(2, undefined, Rounding.ROUND_DOWN). This formatting difference serves different UX purposes and should not be flagged as inconsistent.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx
  • apps/cowswap-frontend/src/common/pure/ExecutionPrice/hooks/useExecutionPriceFiat.ts
  • apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts
📚 Learning: 2025-09-11T08:25:51.460Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 6234
File: libs/tokens/src/index.ts:1-4
Timestamp: 2025-09-11T08:25:51.460Z
Learning: In the cowprotocol/cowswap project, there is currently no SSR (Server-Side Rendering) support, so localStorage access at module import time does not cause SSR-related issues.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useGetOnChainCancellation.ts
  • apps/cowswap-frontend/src/common/hooks/useGetMarketDimension.ts
  • apps/cowswap-frontend/src/common/updaters/SentryUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/CancelledOrdersUpdater.ts
  • apps/cowswap-frontend/src/common/pure/CoWAmmBannerContent/index.tsx
  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx
  • apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx
  • apps/cowswap-frontend/src/common/hooks/useGetSurplusFiatValue.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts
  • apps/cowswap-frontend/src/common/pure/ReceiveAmount/index.tsx
  • apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts
  • apps/cowswap-frontend/src/common/utils/doesOrderHavePermit.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useCancelOrder/useSendOnChainCancellation.ts
  • apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/CurrencyInputPanel.tsx
📚 Learning: 2025-09-19T11:38:59.206Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6232
File: apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx:199-200
Timestamp: 2025-09-19T11:38:59.206Z
Learning: The makeBuildClickEvent function in apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx takes five parameters: defaultChainId, contextLabel, mode, isSwapMode, and chainsCount. The chainsCount parameter is used to determine the CrossChain flag in analytics events.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts
  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts
  • apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts
📚 Learning: 2025-08-05T14:27:05.023Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts
  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx
  • apps/cowswap-frontend/src/common/hooks/useEnhancedActivityDerivedState.ts
📚 Learning: 2025-08-08T13:56:18.009Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/updaters/TokensListsUpdater/index.tsx:29-31
Timestamp: 2025-08-08T13:56:18.009Z
Learning: In libs/tokens/src/updaters/TokensListsUpdater/index.tsx, the project’s current Jotai version requires using `unstable_getOnInit` (not `getOnInit`) in atomWithStorage options; keep `{ unstable_getOnInit: true }` until Jotai is upgraded.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/updaters/UnfillableOrderUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/hooks/useUpdateIsUnfillableFlag.ts
  • apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx
  • apps/cowswap-frontend/src/common/updaters/orders/OrdersFromApiUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/SpotPricesUpdater.ts
📚 Learning: 2025-08-08T13:55:17.528Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/state/tokens/allTokensAtom.ts:78-78
Timestamp: 2025-08-08T13:55:17.528Z
Learning: In libs/tokens/src/state/tokens/allTokensAtom.ts (TypeScript/Jotai), the team prefers to wait for token lists to initialize (listsStatesListAtom non-empty) before returning tokens. No fallback to favorites/user-added/native tokens should be used when listsStatesList is empty.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/updaters/UnfillableOrderUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/hooks/useUpdateIsUnfillableFlag.ts
  • apps/cowswap-frontend/src/common/updaters/orders/OrdersFromApiUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts
  • apps/cowswap-frontend/src/common/updaters/orders/SpotPricesUpdater.ts
📚 Learning: 2025-03-25T10:03:35.157Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5532
File: libs/common-hooks/src/useOnScroll.tsx:22-38
Timestamp: 2025-03-25T10:03:35.157Z
Learning: In React useEffect hooks, refs (RefObjects) should generally be included in dependency arrays even though changes to ref.current don't trigger effects. This is because the ref object itself could change between renders (especially in custom hooks where refs are passed as parameters), and it follows React's best practice of including all external values used in the effect.

Applied to files:

  • apps/cowswap-frontend/src/common/pure/CoWAmmBannerContent/index.tsx
📚 Learning: 2025-08-12T05:57:08.021Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6138
File: libs/hook-dapp-lib/src/hookDappsRegistry.ts:1-1
Timestamp: 2025-08-12T05:57:08.021Z
Learning: The matchHooksToDapps function in libs/hook-dapp-lib/src/utils.ts provides backward compatibility for permit hooks through function selector detection (EIP_2612_PERMIT_SELECTOR and DAI_PERMIT_SELECTOR) rather than dappId matching, making it robust against dappId changes.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx
  • apps/cowswap-frontend/src/common/utils/doesOrderHavePermit.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx
📚 Learning: 2025-02-20T15:59:33.749Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx
  • apps/cowswap-frontend/src/common/hooks/useGetSurplusFiatValue.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts
📚 Learning: 2025-08-12T06:33:19.348Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6137
File: libs/tokens/src/state/tokens/allTokensAtom.ts:34-65
Timestamp: 2025-08-12T06:33:19.348Z
Learning: In libs/tokens/src/utils/parseTokenInfo.ts, the parseTokenInfo() function returns a new instance of TokenInfo using object spread syntax ({ ...token, ... }), making it safe to mutate properties like lpTokenProvider on the returned object without side effects.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/WidgetTokensUpdater.tsx
  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/types.ts
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useGetSurplusFiatValue.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts
  • apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts
  • apps/cowswap-frontend/src/common/hooks/useSwapResultsContext.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useGetExecutedBridgeSummary.ts
📚 Learning: 2025-06-05T08:31:01.284Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 5782
File: apps/cow-fi/app/(learn)/learn/topics/page.tsx:1-1
Timestamp: 2025-06-05T08:31:01.284Z
Learning: Next.js App Router official documentation states that Client Components marked with 'use client' should NOT be declared as async functions, as this can lead to infinite loops or application hangs. The recommended pattern for async operations in Client Components is to use useEffect hooks. Server Components (without 'use client') can be async, which might be a source of confusion.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/BridgingEnabledUpdater.ts
📚 Learning: 2025-09-24T14:51:43.087Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6285
File: apps/cowswap-frontend/src/modules/swap/updaters/index.tsx:37-39
Timestamp: 2025-09-24T14:51:43.087Z
Learning: SwapUpdaters component doesn't have pagination functionality - it processes a fixed number (10) of the most recent pending orders, not paginated results.

Applied to files:

  • apps/cowswap-frontend/src/common/updaters/orders/PendingOrdersUpdater.ts
📚 Learning: 2025-09-25T08:48:53.495Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:58-60
Timestamp: 2025-09-25T08:48:53.495Z
Learning: In the cowswap-frontend codebase, when writing SWR tests, the team prefers maximum test isolation by using `provider: () => new Map()` in SWRConfig wrappers, even if it recreates cache on every render, to ensure tests don't share any state.

Applied to files:

  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/index.tsx
  • apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx
📚 Learning: 2025-08-12T06:33:19.348Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6137
File: libs/tokens/src/state/tokens/allTokensAtom.ts:34-65
Timestamp: 2025-08-12T06:33:19.348Z
Learning: In libs/tokens/src/state/tokens/allTokensAtom.ts, the parseTokenInfo() function returns a new instance of TokenInfo each time, making it safe to mutate properties like lpTokenProvider on the returned object without side effects.

Applied to files:

  • apps/cowswap-frontend/src/common/containers/CoWAmmBanner/types.ts
🔇 Additional comments (24)
apps/cowswap-frontend/src/common/updaters/orders/OrdersFromApiUpdater.ts (1)

1-1: ESLint disable directive correctly placed to suppress existing violations.

The file-wide eslint-disable comment is appropriately positioned and will suppress the new no-restricted-imports rule for this file, which currently imports from modules/ (lines 14–15)—a violation of the documented architectural constraint that common/ must be leaf-only. The TODO comment clearly flags this as technical debt for future refactoring.

This aligns with the PR's pragmatic approach to enforce the rule prospectively while deferring fixes for the ~33 existing violations across the codebase.

apps/cowswap-frontend/src/common/pure/ReceiveAmountInfo/index.tsx (1)

1-1: ESLint suppression matches new import restriction policy

The file‑level no-restricted-imports disable with a TODO is consistent with the new rule and safely preserves existing modules/trade imports until this component can be refactored off them.

apps/cowswap-frontend/src/common/updaters/orders/UnfillableOrdersUpdater/updaters/UnfillableOrderUpdater.ts (1)

1-1: Lint-only change to grandfather existing modules import

The added no-restricted-imports disable cleanly exempts this updater from the new rule while it still depends on modules/orders, with no runtime impact.

apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts (1)

1-1: File-level exception for existing modules-based hook is fine

This suppression correctly isolates the new no-restricted-imports rule from the current modules/usdAmount dependency until it can be relocated.

apps/cowswap-frontend/src/common/hooks/useGetMarketDimension.ts (1)

1-1: Temporary opt-out for trade-related modules imports

Given the current reliance on modules/trade hooks/types, this top-of-file no-restricted-imports disable is a reasonable intermediate step toward enforcing the common/ isolation rule.

apps/cowswap-frontend/src/common/hooks/useCancelOrder/useGetOnChainCancellation.ts (1)

1-1: Grandfathering modules/twap usage under new lint rule

The added no-restricted-imports disable correctly prevents new lint errors while preserving the existing on-chain cancellation flow.

apps/cowswap-frontend/src/common/containers/CoWAmmBanner/types.ts (1)

1-1: Lint suppression for yield modules type import

The file-level no-restricted-imports disable is appropriate here to keep PoolInfo usable from modules/yield until the CoWAmm banner types can be decoupled.

apps/cowswap-frontend/src/common/hooks/useOnSelectNetwork.tsx (1)

1-1: Accepting file-wide exception for wallet modules import

This no-restricted-imports disable safely preserves modules/wallet usage in useOnSelectNetwork under the new ESLint policy, with no behavioral impact.

apps/cowswap-frontend/src/common/hooks/useCancelOrder/useSendOnChainCancellation.ts (1)

1-1: ESLint opt-out for TWAP modules dependency

The new no-restricted-imports disable is an appropriate temporary workaround so useSendOnChainCancellation can keep using modules/twap while the architectural cleanup is pending.

apps/cowswap-frontend/src/common/updaters/SentryUpdater.ts (1)

1-1: Appropriate lint suppression for existing violation.

The file-wide suppression correctly covers the modules/trade/hooks/useTradeState import on line 10. The TODO comment tracks this as technical debt to be addressed later.

apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/types.ts (1)

1-1: Appropriate lint suppression for existing violation.

The suppression correctly covers the modules/trade/types import on line 8. This type-only import is a good candidate for future refactoring—consider moving ReceiveAmountInfo to a shared location to break the dependency.

apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.tsx (1)

1-1: Appropriate lint suppression for existing violation.

The suppression correctly covers the modules/tenderly/hooks/useSimulationData import on line 10. This component's dependency on the Tenderly module hook is the architectural violation to address in a future refactor.

apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeOverview.ts (1)

1-1: Appropriate lint suppression for existing violation.

The suppression correctly covers the modules/bridge/types import on line 11. The return type SwapAndBridgeOverview comes from the bridge module, which is the architectural violation to address.

apps/cowswap-frontend/src/common/pure/CoWAmmBannerContent/index.tsx (1)

1-1: Appropriate lint suppression for existing violation.

The suppression correctly covers the modules/yield/types import on line 13. The VampireAttackContext type dependency is the architectural violation to address in future work.

apps/cowswap-frontend/src/common/hooks/useSwapAndBridgeContext.ts (1)

1-1: Appropriate lint suppression for existing violations.

The suppression correctly covers the multiple modules/bridge/types imports (lines 18-25). This hook has significant coupling to the bridge module—six type imports in one block—making it a higher-priority candidate for refactoring when addressing this architectural debt.

apps/cowswap-frontend/src/common/updaters/orders/SpotPricesUpdater.ts (1)

1-1: Appropriate lint suppression for existing violations.

The suppression correctly covers the three module imports on lines 13-15 (modules/orders/state/spotPricesAtom, modules/usdAmount, and modules/usdAmount/hooks/useUsdPrice). This updater's coupling to multiple modules makes it a good candidate for future refactoring.

libs/wallet-provider/.eslintrc.json (1)

2-2: Confirm that extending ../../eslint.config.js from .eslintrc.json behaves as expected

Pointing "extends" at ../../eslint.config.js makes sense given the repo-wide move, but depending on your ESLint version and whether eslint.config.js is using the new flat-config format, .eslintrc files may be ignored or may not be able to extend it. Please double-check that libs/wallet-provider is actually picking up the intended rules (e.g., by running ESLint with --print-config on a file in this package).

eslint.config.js (1)

229-249: Verify ESLint rule override impact on common/** directory restrictions

The technical claim about ESLint flat config rule overrides is correct: later matching configs override earlier ones rather than merge rule options. However, I cannot verify whether this new no-restricted-imports block actually overrides earlier restrictions, as I cannot access the full config file to confirm whether earlier no-restricted-imports rules apply to apps/cowswap-frontend/src/common/** files.

To complete this review:

  1. Check if earlier no-restricted-imports rules exist (e.g., for apps/cowswap-frontend/**/* or **/*.{ts,tsx,js,jsx}) that should also apply to common/** files.
  2. If they do, verify the intent: Is narrowing common/** to only the modules restriction intentional, or should all prior restrictions (ethers, styled-components, etc.) still apply?
  3. Confirm whether 'cowswap-frontend/modules' imports are actually used in the codebase or if patterns: ['modules/*'] alone suffices.
apps/cowswap-frontend/src/common/hooks/useRateInfoParams.ts (3)

16-19: Signature trailing comma is fine

Adding a trailing comma to the second parameter is purely stylistic and keeps diffs cleaner; no behavioral change or typing issue here.


24-31: useCallback dependencies remain correct

The callback only uses activeRate, and the dependency array still includes just activeRate. The added trailing comma is formatting only and does not affect memoization behavior.


33-39: Formatting-only change around useTradeUsdAmounts

The added trailing comma on the second argument is consistent with the rest of the file and doesn’t affect the call semantics. No issues spotted with the tryParseCurrencyAmount usage in either argument.

apps/cowswap-frontend/src/common/hooks/useCancelOrder/onChainCancellation.ts (3)

27-30: Trailing comma in getEthFlowCancellation signature is harmless

The added comma after order: Order is a style-only change and does not alter the function type or its usage.


43-48: Trailing comma in logTradeFlowError call (ETH flow path)

Only a formatting tweak: passing error as the last argument remains unchanged; the extra comma is syntactically valid and has no runtime impact.


72-77: Trailing comma in logTradeFlowError call (GPv2 path)

Same as above: this is strictly a formatting change, and the error logging behavior is preserved.

Copy link
Collaborator

@shoom3301 shoom3301 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing! Thank you!

Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alfetopito alfetopito merged commit 7b65233 into cowprotocol:develop Dec 10, 2025
8 of 15 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants