Skip to content

omnidoc checks for non-existing but documented props#6582

Merged
PavelVanecek merged 3 commits intomainfrom
omnidoc-props
Nov 8, 2025
Merged

omnidoc checks for non-existing but documented props#6582
PavelVanecek merged 3 commits intomainfrom
omnidoc-props

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Nov 8, 2025

Description

Extend omnidoc to detect props that are documented but not actually used in the source.

Related Issue

#6069

Summary by CodeRabbit

  • New Features

    • Enhanced documentation API to list public components and expose both library-specific and inherited SVG props.
  • Tests

    • Added validation tests to ensure documented props (API and Storybook) match project exports.
  • Improvements

    • Several chart component exports now include explicit type annotations for clearer public typings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Walkthrough

Refactors omnidoc APIs: renames getPropsOfgetRechartsPropsOf, adds getPublicComponentNames and getAllPropsOf, and expands type-resolution for props. Updates omnidoc tests to use new APIs and adds cross-check tests. Adds explicit ComponentType<Props> annotations to several cartesian exports.

Changes

Cohort / File(s) Summary
omnidoc Interface
omnidoc/DocReader.ts
Added getPublicComponentNames(): ReadonlyArray<string> and getAllPropsOf(component: string): ReadonlyArray<string>; renamed getPropsOf()getRechartsPropsOf().
omnidoc API readers
omnidoc/readApiDoc.ts, omnidoc/readStorybookDoc.ts
Implemented getPublicComponentNames() (filters out hooks/utility) and getRechartsPropsOf(); removed public getPropsOf() surface.
omnidoc Project reader
omnidoc/readProject.ts
Added getPublicComponentNames(), getRechartsPropsOf(), getAllPropsOf() and private helpers (getPropsType(), getTypeArgumentsOfComponentType(), getTypeArgumentOfFunctionCallSignature()); refactored prop discovery to better resolve ComponentType/aliases/SVGProps/Omit patterns.
omnidoc tests
omnidoc/omnidoc.spec.ts, omnidoc/readApiDoc.spec.ts, omnidoc/readProject.spec.ts, omnidoc/readStorybookDoc.spec.ts
Replaced getPropsOf() calls with getRechartsPropsOf(); added two tests asserting API/Storybook-documented props exist in project exports; added/adjusted component-specific prop tests (Bar, ReferenceLine).
Cartesian exports typing
src/cartesian/Area.tsx, src/cartesian/Line.tsx, src/cartesian/Scatter.tsx, src/cartesian/XAxis.tsx, src/cartesian/YAxis.tsx
Added explicit ComponentType<Props> annotations to exported components while preserving React.memo(...) wrappers and runtime behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Tests
  participant Doc as DocReader (interface)
  participant API as ApiDocReader
  participant SB as StorybookDocReader
  participant PJ as ProjectReader

  Note over Test,Doc: Tests call DocReader's public API
  Test->>Doc: getPublicComponentNames()
  Doc->>API: (if API reader) getPublicComponentNames()
  Doc->>SB: (if Storybook reader) getPublicComponentNames()
  Doc->>PJ: (if Project reader) getPublicComponentNames()
  Note right of API: filters out hooks / utilities
  Test->>Doc: getRechartsPropsOf(component)
  Doc->>API: getRechartsPropsOf(component)
  Doc->>SB: getRechartsPropsOf(component)
  Doc->>PJ: getRechartsPropsOf(component)
  Note right of PJ: uses getPropsType → resolves ComponentType / aliases / SVGProps / Omit
  Doc->>PJ: getAllPropsOf(component)
  Note right of PJ: aggregates Recharts props + inherited SVG props
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Pay extra attention to:
    • omnidoc/readProject.ts — new type-resolution helpers and their coverage of alias/ComponentType/constructor/function patterns.
    • getAllPropsOf logic — correctness when combining Recharts props with inherited SVG props and Omit<> cases.
    • Type annotation changes in src/cartesian/* — ensure declared ComponentType<Props> matches actual component signatures and exported generics.

Possibly related PRs

  • OmniDoc #6552 — Directly related: renames getPropsOfgetRechartsPropsOf and adds getPublicComponentNames/getAllPropsOf in omnidoc readers.
  • zIndex #6479 — Related: modifies the same cartesian component exports (Area, Line, Scatter, XAxis, YAxis) and their public signatures.
  • Put back Area event handlers #6507 — Related: touches src/cartesian/Area.tsx and other cartesian exports (overlapping edits to component exports).

Suggested labels

enhancement

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides a clear summary and links to the related issue, but lacks details on testing, motivation, and problem context as specified in the template. Add sections for Motivation and Context, How Has This Been Tested, and clarify the Types of changes and Checklist items to match the template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective of the PR: extending omnidoc to detect and check for props that are documented but don't exist in source code.
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
  • Commit unit tests in branch omnidoc-props

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
Collaborator Author

On my local this reports 38 props on the website, and 42 props in the storybook, that are documented but don't exist. Let's see that it fails with the same on CI and then decide what to do with them @ckifer ?

@PavelVanecek
Copy link
Collaborator Author

🥳

@PavelVanecek PavelVanecek requested a review from ckifer November 8, 2025 04:56
@ckifer
Copy link
Member

ckifer commented Nov 8, 2025

Hm it looks mostly right. Would like to take a look at a few of them like Funnel - shape and Sunburst - margin though.

@PavelVanecek
Copy link
Collaborator Author

Area.baseLine is also sus

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 d893dd2 and f7014fa.

📒 Files selected for processing (13)
  • omnidoc/DocReader.ts (1 hunks)
  • omnidoc/omnidoc.spec.ts (1 hunks)
  • omnidoc/readApiDoc.spec.ts (2 hunks)
  • omnidoc/readApiDoc.ts (1 hunks)
  • omnidoc/readProject.spec.ts (1 hunks)
  • omnidoc/readProject.ts (4 hunks)
  • omnidoc/readStorybookDoc.spec.ts (5 hunks)
  • omnidoc/readStorybookDoc.ts (1 hunks)
  • src/cartesian/Area.tsx (2 hunks)
  • src/cartesian/Line.tsx (2 hunks)
  • src/cartesian/Scatter.tsx (2 hunks)
  • src/cartesian/XAxis.tsx (2 hunks)
  • src/cartesian/YAxis.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/cartesian/Area.tsx
  • src/cartesian/YAxis.tsx
  • omnidoc/readProject.spec.ts
  • src/cartesian/Line.tsx
  • src/cartesian/XAxis.tsx
  • omnidoc/readStorybookDoc.ts
  • omnidoc/readApiDoc.spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any user-facing strings or formatting choices in the library code; leave internationalization to library users

Files:

  • src/cartesian/Scatter.tsx
🧠 Learnings (3)
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : Mock getBoundingClientRect using test/helper/MockGetBoundingClientRect.ts when rendering Recharts components (e.g., Tooltip, Legend, charts)

Applied to files:

  • omnidoc/readStorybookDoc.spec.ts
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : When testing selectors, verify render counts using the spy and rerenderSameComponent from createSelectorTestCase

Applied to files:

  • omnidoc/readStorybookDoc.spec.ts
📚 Learning: 2025-10-25T07:36:02.229Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-25T07:36:02.229Z
Learning: Recharts aims for simple, declarative, and composable charts; prioritize consistency, usability, performance, and accessibility

Applied to files:

  • omnidoc/readStorybookDoc.spec.ts
🧬 Code graph analysis (1)
src/cartesian/Scatter.tsx (2)
src/cartesian/Area.tsx (1)
  • Props (158-158)
src/cartesian/Line.tsx (1)
  • Props (160-160)
⏰ 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: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
src/cartesian/Scatter.tsx (2)

2-11: LGTM!

The ComponentType import is necessary for the explicit type annotation on the export. The import reorganization is clean and doesn't affect functionality.


749-749: Explicit type annotation compiles cleanly.

The ComponentType<Props> annotation successfully compiles without TypeScript errors, confirming the change is valid. This explicit annotation aids omnidoc's ability to extract documented props, and the runtime behavior remains unchanged.

omnidoc/readStorybookDoc.spec.ts (1)

64-64: LGTM! Method rename applied consistently.

All occurrences of getPropsOf have been correctly renamed to getRechartsPropsOf, maintaining test logic and assertions.

Also applies to: 92-92, 96-96, 113-116, 119-119, 156-156, 186-186, 192-192

omnidoc/omnidoc.spec.ts (2)

55-237: Excellent addition: cross-check test for API documentation consistency.

This test validates that props documented in API docs actually exist in the source code. The inline snapshot captures the current mismatches, providing a baseline to track documentation debt.


239-437: Excellent addition: cross-check test for Storybook documentation consistency.

This test validates that props documented in Storybook actually exist in the source code. The inline snapshot captures the current mismatches, aligning with the PR objective to detect documented but non-existent props.

omnidoc/DocReader.ts (1)

7-10: LGTM! Clear and well-documented interface expansion.

The new methods provide better granularity:

  • getPublicComponentNames() filters out hooks and utilities
  • getRechartsPropsOf() makes it explicit that SVG props are excluded
  • getAllPropsOf() includes inherited SVG props for documentation checks

The JSDoc comments clearly explain the differences.

Also applies to: 16-16, 18-22

omnidoc/readApiDoc.ts (1)

12-24: LGTM! Clean implementation of the new interface.

The filtering logic in getPublicComponentNames() appropriately excludes hooks and utilities. The delegation from getAllPropsOf() to getRechartsPropsOf() is correct since API docs don't track SVG inheritance.

Also applies to: 26-36

omnidoc/readProject.ts (6)

48-63: LGTM! Filtering logic is appropriate.

The conservative approach of only filtering by 'use' prefix and specific utilities is sensible, avoiding false exclusions of components.


107-114: LGTM! Handles Partial wrapper types.

The FQN check for 'Partial' correctly unwraps the type to extract props. This handles the common case where types use Partial<Props>.


197-248: Comprehensive type resolution with good fallback strategies.

The multi-strategy approach (call signatures → construct signatures → type arguments → props property) handles various component declaration patterns. Error messages appropriately reference declarations rather than components.


250-261: LGTM! Orchestrates type resolution effectively.

The method correctly prioritizes alias symbol resolution (for ComponentType<Props> patterns) before falling back to call signature inspection.


263-266: LGTM! Clean refactor using new type resolution.

The method correctly uses getPropsType() for improved type resolution before collecting properties.


290-293: LGTM! Updated to use new type resolution.

Correctly uses getPropsType() for consistent type resolution across the class.

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6582   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files         491      491           
  Lines       41031    41031           
  Branches     4748     4749    +1     
=======================================
  Hits        38803    38803           
  Misses       2223     2223           
  Partials        5        5           

☔ 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.

@codecov
Copy link

codecov bot commented Nov 8, 2025

Bundle Report

Bundle size has no change ✅

@PavelVanecek PavelVanecek merged commit e2d594c into main Nov 8, 2025
29 checks passed
@PavelVanecek PavelVanecek deleted the omnidoc-props branch November 8, 2025 12:55
PavelVanecek added a commit that referenced this pull request Nov 9, 2025
## Description

Some of these we removed in 3.0 and some I don't know.

## Related Issue

#6069

#6582



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Removed internal, deprecated, and unused props from component API docs
and clarified several descriptions to simplify public-facing docs.
* **Chores**
* Streamlined Storybook stories to expose only public props by removing
internal/deprecated story args and prop entries.
* **Tests**
* Updated snapshot expectations to align with the reduced public prop
surface across docs and stories.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@PavelVanecek
Copy link
Collaborator Author

Funnel - shape and Sunburst - margin though.

Funnel has shape prop, FunnelChart has not

Sunburst does not have margin prop and I tried adding it - the renderer ignores it.

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.

2 participants