Skip to content

fix circular dependency#6777

Merged
ckifer merged 1 commit into
recharts:mainfrom
jkr2255:jkr2255-patch-1
Dec 15, 2025
Merged

fix circular dependency#6777
ckifer merged 1 commit into
recharts:mainfrom
jkr2255:jkr2255-patch-1

Conversation

@jkr2255

@jkr2255 jkr2255 commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Description

removed import of index.ts from BarStack.

Related Issue

fixes #6776.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

Summary by CodeRabbit

  • Refactor
    • Internal module structure reorganized to improve code organization. No changes to user-facing functionality or component behavior.

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

@coderabbitai

coderabbitai Bot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change fixes a circular dependency warning in BarStack by updating import sources. LayerProps is now imported from ../container/Layer instead of ../index, and Rectangle types are sourced from their specific modules. Public component signatures remain unchanged.

Changes

Cohort / File(s) Summary
Import path refactoring to resolve circular dependency
src/cartesian/BarStack.tsx
Updated LayerProps import from ../index to ../container/Layer and Rectangle-related type imports from their specific module (../shape/Rectangle). Public API signatures preserved.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Verify that the new import paths (../container/Layer, ../shape/Rectangle) exist and export the expected types
  • Confirm type compatibility and that no type shape has changed
  • Check that circular dependency warning is resolved

Suggested labels

typescript

Suggested reviewers

  • PavelVanecek
  • ckifer

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix circular dependency' directly addresses the main objective of resolving a circular dependency issue identified in issue #6776.
Description check ✅ Passed The description includes key sections: description of changes, related issue reference, and types of changes. Motivation/context and testing details are minimal but the core requirements are addressed.
Linked Issues check ✅ Passed The pull request removes the problematic import of index.ts from BarStack.tsx, which directly resolves the circular dependency warning reported in issue #6776.
Out of Scope Changes check ✅ Passed All changes are focused on removing the circular dependency by adjusting import paths in BarStack.tsx, which is within the scope of resolving issue #6776.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 faf83e7 and 3b35767.

📒 Files selected for processing (1)
  • src/cartesian/BarStack.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

Files:

  • src/cartesian/BarStack.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • src/cartesian/BarStack.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any strings or formatting choices in library code; users should provide localized strings as desired

Files:

  • src/cartesian/BarStack.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

All imports from recharts must use the public API entry point; imports from internal paths like recharts/types/* or recharts/src/* are not allowed

Files:

  • src/cartesian/BarStack.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-06T03:36:59.377Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All imports from `recharts` must use the public API entry point; imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.
📚 Learning: 2025-12-06T03:36:59.377Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-06T03:36:59.377Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All imports from `recharts` must use the public API entry point; imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed

Applied to files:

  • src/cartesian/BarStack.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/cartesian/BarStack.tsx
🔇 Additional comments (3)
src/cartesian/BarStack.tsx (3)

9-10: Circular dependency is resolved.

The import changes successfully break the circular dependency loop. BarStack no longer imports from ../index, and its new dependencies (Layer and Rectangle) do not import from the index, eliminating the cycle.


9-9: Good fix to break the circular dependency.

Importing LayerProps directly from ../container/Layer instead of through the barrel export is the correct approach to resolve the circular dependency issue. Layer.tsx properly exports Props which is aliased as LayerProps in this import.


10-10: Import consolidation is correct.

Both Rectangle and RectRadius are properly exported from ../shape/Rectangle, making this direct import valid and avoiding potential circular dependencies through intermediate re-exports.


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.

@PavelVanecek

Copy link
Copy Markdown
Collaborator

Hi @jkr2255 , thank you for the PR. Would you like to add a reproduction to recharts-integ repository to avoid regression?

@codecov

codecov Bot commented Dec 15, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.81%. Comparing base (faf83e7) to head (3b35767).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6777   +/-   ##
=======================================
  Coverage   93.81%   93.81%           
=======================================
  Files         516      516           
  Lines       43979    43979           
  Branches     5005     5005           
=======================================
  Hits        41257    41257           
  Misses       2716     2716           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ckifer
ckifer merged commit 8892d52 into recharts:main Dec 15, 2025
32 of 33 checks passed
@ckifer

ckifer commented Dec 15, 2025

Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Circular dependency detected in BarStack

3 participants