Skip to content

Conversation

@crutch12
Copy link
Contributor

@crutch12 crutch12 commented Dec 1, 2025

Summary

I believe it is much more convenient to sort imports with prettier (e.g. on file save), so I've added @trivago/prettier-plugin-sort-imports settings to prettier.config.js

These settings are fully compatible with current eslint's import/order rules.
I've tested it with multiple runs:

$ npx eslint . --fix
$ npx prettier . --write
$ npx eslint . --fix
$ npx prettier . --write

And there are no cyclic repetitive changes.

To Test

  1. Setup prettier, enable running prettier on file save
  2. Try to add some imports and save file (or run npx prettier <filename> --write)

Every import should be sorted accordingly to eslint config (you see no eslint import/order errors)

Here is the list of files I've been using to test new prettier settings:

- apps/explorer/src/components/common/TokenDisplay/utils.tsx
- apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx
- apps/cowswap-frontend/src/common/containers/ConfirmationModal/index.tsx
- apps/cowswap-frontend/src/cosmos.decorator.tsx
- apps/explorer/src/components/common/MenuDropdown/MenuDropdownItem.stories.tsx
- apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts
- apps/cowswap-frontend/src/modules/twap/utils/deadlinePartsDisplay.ts
- apps/explorer/src/components/orders/OrderPriceDisplay/OrderPriceDisplay.stories.tsx
- libs/abis/src/index.ts
- libs/common-hooks/src/useParsedQueryString.ts
- libs/core/src/jotaiStore.ts
- jest.setup.ts
- apps/cow-fi/services/tokens/index.ts

Background

  • prettier's plugin and eslint's import/order rules have different alphabetic sorting implementations, thus I have to ignore cowswap/libs/abis/src/index.ts file (prettier uses javascript-natural-sort)
  • apps/cow-fi/eslint.config.js ignores import/order rules, so I've disabled importOrder settings there too (see apps/cow-fi/prettier.config.js)
  • ignore any file with eslint no-restricted-imports
  • ignore some tests files (due to importance of imports order)

Proposals

  • I think it would be better to keep imports order consistency only with prettier, so we could remove eslint's import/order rules
  • I think we should run prettier on commit too
// package.json
"lint-staged": {
  "*.{js,ts,tsx,json,css,md}": "prettier --write"
}

Summary by CodeRabbit

  • Chores
    • Centralized Prettier configuration with automatic import sorting across the project
    • Updated import ordering rules in the linter for consistent code organization
    • Added new development tooling dependency for improved code formatting consistency
    • Streamlined build configuration files for better maintainability

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

@vercel
Copy link

vercel bot commented Dec 1, 2025

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Consolidates Prettier configuration from multiple local files into a centralized root configuration with the @trivago/prettier-plugin-sort-imports plugin. Adds sort-imports-ignore comments to test files, updates ESLint import order rules to align with Prettier settings, removes duplicate Prettier config files, and refactors a script entry point into a function wrapper.

Changes

Cohort / File(s) Summary
Prettier root configuration
.prettierrc, .prettierignore, prettier.config.js
Removes legacy .prettierrc file, updates .prettierignore to exclude /libs/abis/src/generated and CHANGELOG.md, and introduces comprehensive prettier.config.js with sort-imports plugin, import ordering rules with multiple groups, and formatting options (semi: false, singleQuote: true, printWidth: 120).
App-specific Prettier configs
apps/cowswap-frontend/.prettierrc, apps/cowswap-frontend/prettier.config.js, apps/cow-fi/prettier.config.js
Removes cowswap-frontend/.prettierrc, creates cowswap-frontend/prettier.config.js forwarding root config, and creates cow-fi/prettier.config.js that strips Trivago import-order plugin and importOrder-related keys.
Test file sort-imports directives
apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts, apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts, apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts, apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.ts
Adds // sort-imports-ignore // disabled for tests comment to each file with no functional logic changes.
Import order & ESLint configuration
eslint.config.js, libs/abis/src/index.ts
Updates ESLint import/order rule patterns, adds legacy/** and modules/** groups, removes legacy from internal pattern, adds documentation comment, and inserts sort-imports-ignore comment in libs/abis/src/index.ts.
Package dependencies
package.json
Adds @trivago/prettier-plugin-sort-imports@^6.0.0 to both dependencies and devDependencies.
Other configuration & refactoring
apps/cowswap-frontend/vite.config.mts, libs/core/src/jotaiStore.ts, tools/scripts/install-sdk-preview.js
Vite config: adjusts imports for meta and robotsPlugin; jotaiStore: updates localforage import; install-sdk-preview.js: wraps top-level logic into run() function with PACKAGE_READ_AUTH_TOKEN moved into function scope.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Prettier configuration consolidation: Review prettier.config.js importOrder patterns and group definitions to ensure alignment with ESLint rules.
  • App-specific configs: Verify cow-fi/prettier.config.js correctly filters out import-order plugin and that cowswap-frontend/prettier.config.js properly forwards root config.
  • ESLint import/order patterns: Cross-check pattern changes (expanded jotai, removed legacy, added legacy/** and modules/**) are intentional and don't conflict.
  • Script refactoring: Confirm install-sdk-preview.js run() function wrapping preserves original behavior and PACKAGE_READ_AUTH_TOKEN scoping is correct.

Possibly related PRs

  • cowprotocol/cowswap#6331: Introduces animated favicon feature; related test files (FaviconAnimationUpdater.test.ts, controller.test.ts) in this PR add sort-imports-ignore directives and mock the favicon API used by that feature.

Suggested reviewers

  • elena-zh
  • alfetopito
  • shoom3301

Poem

🐰 ✨ Configs grouped and sorted neat,
Root and branches now compete!
Prettier plugins sort the way,
Tests ignore what's out of play—
One true config reigns supreme. 🎀

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 'chore(prettier): import order' is concise and directly references the main change: adding Prettier import order configuration.
Description check ✅ Passed The PR description includes a clear summary of changes, testing instructions with specific steps, and detailed background context. All required template sections are addressed with substantive content.
✨ 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 1f77b8f and 2c51777.

📒 Files selected for processing (9)
  • .prettierignore (1 hunks)
  • apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.ts (1 hunks)
  • apps/cowswap-frontend/vite.config.mts (1 hunks)
  • eslint.config.js (2 hunks)
  • libs/abis/src/index.ts (1 hunks)
  • prettier.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • libs/abis/src/index.ts
  • apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts
  • apps/cowswap-frontend/vite.config.mts
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts
  • apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.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). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (3)
.prettierignore (1)

5-7: Ignore additions are appropriate for Prettier.

Excluding the Cursor metadata directory, generated ABIs, and the changelog from Prettier formatting is reasonable and should reduce noise from non-source changes.

prettier.config.js (1)

1-53: Prettier importOrder and options look consistent with ESLint import/order.

The grouping patterns (react/jotai, scoped @cowprotocol/@uniswap/etc., legacy, modules, internal dirs, relatives, and TS type imports) mirror the import/order pathGroups and group ordering in eslint.config.js, and options like importOrderSeparation + importOrderCaseInsensitive align with ESLint’s newlines-between: 'always' and alphabetize.caseInsensitive: true. This should avoid Prettier/ESLint ping‑pong on import order, assuming the current @trivago/prettier-plugin-sort-imports behavior is retained.

eslint.config.js (1)

144-189: ESLint import/order groups now align with the new Prettier importOrder.

The updated pathGroups for react/jotai, the scoped @cowprotocol/@uniswap/etc. packages, legacy/, modules/, and the internal dirs match the group ordering and patterns defined in prettier.config.js, and the new comment block makes the coupling explicit so future changes stay synchronized.


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.

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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce4d7e3 and f150639.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (20)
  • .prettierignore (1 hunks)
  • .prettierrc (0 hunks)
  • apps/cow-fi/prettier.config.js (1 hunks)
  • apps/cowswap-frontend/.prettierrc (0 hunks)
  • apps/cowswap-frontend/prettier.config.js (1 hunks)
  • apps/cowswap-frontend/src/common/hooks/useNavigate.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.ts (1 hunks)
  • apps/cowswap-frontend/vite.config.mts (1 hunks)
  • apps/explorer/src/storybook/decorators.tsx (1 hunks)
  • apps/widget-configurator/src/app/embedDialog/index.tsx (1 hunks)
  • eslint.config.js (1 hunks)
  • libs/abis/src/index.ts (1 hunks)
  • libs/core/src/gnosisSafe/index.ts (1 hunks)
  • libs/core/src/jotaiStore.ts (1 hunks)
  • package.json (1 hunks)
  • prettier.config.js (1 hunks)
  • tools/scripts/install-sdk-preview.js (2 hunks)
💤 Files with no reviewable changes (2)
  • apps/cowswap-frontend/.prettierrc
  • .prettierrc
🧰 Additional context used
🧠 Learnings (9)
📚 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:

  • libs/core/src/gnosisSafe/index.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:

  • libs/core/src/gnosisSafe/index.ts
  • apps/explorer/src/storybook/decorators.tsx
  • apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts
  • apps/widget-configurator/src/app/embedDialog/index.tsx
  • apps/cowswap-frontend/vite.config.mts
  • apps/cowswap-frontend/src/common/hooks/useNavigate.ts
📚 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:

  • libs/core/src/gnosisSafe/index.ts
📚 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/explorer/src/storybook/decorators.tsx
  • apps/widget-configurator/src/app/embedDialog/index.tsx
  • apps/cowswap-frontend/src/common/hooks/useNavigate.ts
📚 Learning: 2025-07-28T16:26:08.051Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6034
File: apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts:44-47
Timestamp: 2025-07-28T16:26:08.051Z
Learning: In the cowswap codebase, using trivial placeholder tests like `it('should be true', () => { expect(true).to.be.true })` in e2e test files is an intentional pattern when disabling broken tests to keep CI green while maintaining build efficiency.

Applied to files:

  • apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts
  • apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.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/modules/sounds/utils/sound.test.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/modules/sounds/utils/sound.test.ts
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts
📚 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/vite.config.mts
📚 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:

  • libs/core/src/jotaiStore.ts
🧬 Code graph analysis (2)
apps/cow-fi/prettier.config.js (1)
apps/cowswap-frontend/prettier.config.js (1)
  • config (1-1)
apps/cowswap-frontend/prettier.config.js (2)
apps/cow-fi/prettier.config.js (1)
  • config (1-3)
eslint.config.js (1)
  • require (1-1)
🔇 Additional comments (18)
apps/explorer/src/storybook/decorators.tsx (1)

1-1: LGTM!

The // sort-imports-ignore directive correctly excludes this Storybook decorators file from automatic import sorting, which is appropriate given the specific import ordering requirements for test/story files.

apps/cowswap-frontend/src/modules/application/containers/App/FaviconAnimationUpdater.test.ts (1)

1-2: LGTM!

The directive appropriately excludes this test file from import sorting. Test files with jest.mock() declarations often require specific import ordering for clarity and to ensure mocks are set up before the mocked modules are imported.

apps/cowswap-frontend/src/modules/sounds/utils/sound.test.ts (1)

1-2: LGTM!

Consistent with the pattern established for test files—the directive prevents import sorting that would disrupt the intentional placement of imports after jest.mock() declarations.

libs/core/src/jotaiStore.ts (1)

3-5: LGTM!

The blank line between the jotai imports and the localforage import correctly groups related imports according to the new Prettier import ordering configuration.

apps/cowswap-frontend/vite.config.mts (1)

1-1: LGTM!

The directive correctly excludes this Vite configuration file from import sorting. Configuration files often have intentionally structured imports, and this file already contains ESLint overrides (line 19-20) for restricted imports, making it a suitable candidate for exclusion.

.prettierignore (1)

5-7: LGTM!

The additions to .prettierignore are appropriate:

  • Ignoring /libs/abis/src/generated prevents Prettier from reformatting auto-generated code.
  • Ignoring CHANGELOG.md preserves its specific formatting.

These align with the PR's objectives regarding handling files with special import ordering requirements.

libs/core/src/gnosisSafe/index.ts (1)

1-1: LGTM!

The // sort-imports-ignore directive is appropriately placed to prevent the Prettier import sorting plugin from reordering imports in this file. The comment clarifies that this is due to the no-restricted-imports ESLint rule on line 9, which requires the ethers import to be positioned after the disable comment.

apps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.ts (1)

1-1: LGTM!

The // sort-imports-ignore directive is correctly applied. Test files with jest.mock() calls that precede imports (lines 5-30) require this specific ordering to ensure mocks are properly set up before the actual modules are imported. Automatic import sorting would break the mock setup.

libs/abis/src/index.ts (1)

1-1: LGTM!

The // sort-imports-ignore directive correctly addresses the incompatibility between ESLint's import/order rule and the Prettier plugin's alphabetic sorting implementation. As noted in the PR description, this file was specifically identified as having sorting conflicts that would cause cyclic changes between eslint --fix and prettier --write.

apps/widget-configurator/src/app/embedDialog/index.tsx (1)

1-1: LGTM!

The // sort-imports-ignore directive is correctly applied. Lines 24-25 contain an eslint-disable-next-line comment for the no-restricted-imports rule on the nightOwl import. Without this directive, the Prettier plugin could reorder imports and separate the disable comment from its target import, breaking the ESLint override.

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

1-1: LGTM!

The sort-imports-ignore directive is appropriately placed to prevent the Prettier plugin from reordering imports in this file, which needs to bypass the no-restricted-imports rule for useNavigate.

eslint.config.js (2)

144-150: Good documentation addition.

The comment linking ESLint's import/order rules to prettier.config.js improves maintainability by making the connection explicit.


156-164: LGTM!

The jotai/** pattern correctly matches nested subpaths (e.g., jotai/vanilla/utils), and removing the duplicate @cowprotocol entry cleans up the configuration.

apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (1)

1-2: LGTM!

The sort-imports-ignore directive is necessary here because jest.mock() must be hoisted before the imports that depend on the mocked module. Automatic import sorting would break this test.

tools/scripts/install-sdk-preview.js (1)

16-45: LGTM!

The refactoring into a run() function maintains identical behavior while improving code organization. Moving PACKAGE_READ_AUTH_TOKEN into the function scope is appropriate since it's only used there.

apps/cowswap-frontend/prettier.config.js (1)

1-5: LGTM!

Clean wrapper that forwards the root Prettier configuration to this app. The spread syntax allows for potential future app-specific overrides if needed.

apps/cow-fi/prettier.config.js (1)

1-15: LGTM!

The configuration correctly disables import sorting for the cow-fi app by removing the plugin and all importOrder keys. This aligns with the PR description noting that cow-fi's ESLint config ignores import/order rules.

prettier.config.js (1)

14-52: Import order configuration looks well-structured.

The importOrder patterns appropriately mirror the ESLint import/order rules, with importOrderSeparation: true matching ESLint's newlines-between: 'always' and importOrderCaseInsensitive: true aligning with ESLint's case-insensitive sorting.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f150639 and 1b9e1b7.

📒 Files selected for processing (1)
  • prettier.config.js (1 hunks)
🔇 Additional comments (4)
prettier.config.js (4)

1-4: LGTM: Standard Prettier configuration.

The basic Prettier settings are appropriate and commonly used.


49-52: LGTM: Plugin options configured appropriately.

The import order options are set correctly. Note that importOrderSortSpecifiers: false means named imports within braces won't be alphabetically sorted (e.g., import { b, a } remains as-is), which preserves developer intent.


5-5: Verify the plugin dependency is installed.

Ensure that @trivago/prettier-plugin-sort-imports is listed in package.json dependencies or devDependencies.


28-28: Verify that built-in modules placement matches ESLint rules.

The <BUILTIN_MODULES> placeholder appears after third-party modules and legacy imports, which is unconventional. Typically, built-in Node modules are sorted early in import order. Confirm this ordering aligns with your ESLint import/order configuration.

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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b9e1b7 and 4529ff8.

📒 Files selected for processing (2)
  • eslint.config.js (2 hunks)
  • prettier.config.js (1 hunks)
🔇 Additional comments (3)
prettier.config.js (2)

1-5: LGTM! Basic Prettier configuration is well-structured.

The core formatting options (semi, singleQuote, printWidth) and plugin declaration are appropriate for the project.


49-52: Verify importOrderSideEffects: false behavior.

Setting importOrderSideEffects: false excludes side-effect imports (e.g., import './styles.css') from sorting. Ensure this is intentional, as side-effect imports will remain in their original positions rather than being grouped.

eslint.config.js (1)

154-179: LGTM! Import order pathGroups are well-organized.

The changes appropriately:

  • Expand jotai/* to jotai/** for matching nested subpaths
  • Remove the duplicate @cowprotocol entry
  • Remove legacy from the internal paths group (since it has its own dedicated group at lines 166-169)

These adjustments ensure consistency with the Prettier importOrder configuration.

@crutch12 crutch12 force-pushed the chore/prettier-import-order branch from 4529ff8 to 1f77b8f Compare December 1, 2025 12:17
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

🧹 Nitpick comments (1)
prettier.config.js (1)

45-47: Consider documenting the TS type placeholders usage for future maintainers

Using <THIRD_PARTY_TS_TYPES> and <TS_TYPES>^[./] is a nice touch to keep import type blocks grouped, but since these placeholders are not obvious from the plugin README, future readers may not realize they exist or which plugin/version they rely on. Consider adding a brief inline comment with a link to the upstream issue/comment you referenced (prettier-plugin-sort-imports #202) so others understand why these entries are here and don’t “simplify” them away.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4529ff8 and 1f77b8f.

📒 Files selected for processing (2)
  • eslint.config.js (2 hunks)
  • prettier.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eslint.config.js
🔇 Additional comments (1)
prettier.config.js (1)

1-5: Centralized Prettier/import-order config looks consistent and well-scoped

The overall Prettier setup (core options + @trivago/prettier-plugin-sort-imports with importOrder* flags) is coherent, and the grouping patterns line up with the described ESLint import/order rules. The structure should be easy to maintain as long as changes to import rules continue to be mirrored here.

Also applies to: 14-44, 49-52

// cow-fi eslint config ignores import/order rules, so we disable prettier import order rules
config.plugins = [...config.plugins].filter((p) => !p.includes('@trivago/prettier-plugin-sort-imports'))

Object.keys(config)
Copy link
Contributor Author

@crutch12 crutch12 Dec 2, 2025

Choose a reason for hiding this comment

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

if you don't like this solution, I could extract base config into prettier.base.js file and use it in both configs

just didn't want to produce extra files...

@elena-zh elena-zh requested a review from a team December 3, 2025 10:49
@kernelwhisperer
Copy link
Contributor

Hey @crutch12 thank you very much for this PR.

I was planning to integrate prettier into eslint using eslint-plugin-prettier, this way we can use eslint extension to format on file save and not rely on the prettier plugin.

I think this where the convenience of using prettier's import sort coming from? Are there some other reason to use it?

@crutch12
Copy link
Contributor Author

crutch12 commented Dec 10, 2025

Hi @kernelwhisperer

The main reason for me is to fix as much problems as possible during prettier format call. I use vscode prettier extension + format on save feature and it's really convenient, that prettier formats every saved changes immediately.
But when I get eslint's import/order error on every new import, I have to fix it manually, or run eslint fix which is very slow.

So

Step 1. I want to offload import/order from eslint to prettier, preserving original eslint's import/order rules.
Step 2. To keep configs consistent: remove eslint import/order and run prettier format on every new commit (see the next PR: #6596)

I'm not sure if it's possible to do with eslint-plugin-prettier, I've always thought this plugin just generates prettier/prettier eslint rules to keep both configs consistent.

@kernelwhisperer
Copy link
Contributor

kernelwhisperer commented Dec 10, 2025

Yes, makes sense, that's exactly what eslint-plugin-prettier does, not to be confused with eslint-config-prettier:

image

Unfortunately, I think we will stick with eslint import sorting, it's already setup, heavily configured, etc.

Please take a look at #6637, as soon as it's merged prettier and eslint will run on file save and you can forget about it.

Could you migrate your other changes and base them on that PR? 🙏

I like what you did with #6596 in particular to ignore patterns, --concurrency auto and stuff like that!
(If possible don't run eslint --fix, or do it in a separate commit, thank you)

@crutch12
Copy link
Contributor Author

crutch12 commented Dec 10, 2025

Unfortunately, I think we will stick with eslint import sorting, it's already setup, heavily configured, etc.

Just want to clarify: new prettier config setup completely repeats current eslint import/order rules, that's why I wanted to remove eslint's definition at all.

--

Thanks for explanation, I'll check your pr and eslint prettier plugin. I hope it runs as fast as original prettier does.
Then will migrate non-config changes in new branch, basing on your branch

@kernelwhisperer
Copy link
Contributor

Unfortunately, I think we will stick with eslint import sorting, it's already setup, heavily configured, etc.

Just want to clarify: new prettier config setup completely repeats current eslint import/order rules, that's why I wanted to remove eslint's definition at all.

--

Thanks for explanation, I'll check your pr and eslint prettier plugin. I hope it runs as fast as original prettier does. Then will migrate non-config changes in new branch, basing on your branch

Got it, #6637 was merged into develop, please try that out and base your changes on the new develop version.

Copy link
Contributor

@kernelwhisperer kernelwhisperer left a comment

Choose a reason for hiding this comment

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

As discussed above

@crutch12
Copy link
Contributor Author

Closed in favor of #6716

@crutch12 crutch12 closed this Dec 17, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 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