@codemod/mine-react-components
Read-only React component inventory for Insights dashboards.
Installation
bash
Usage
This package scans .js, .jsx, .ts, and .tsx source files and emits metrics for React component definitions. It does not rewrite source files.
Default workflow step: detect-react-components
Included files:
**/*.{js,jsx,ts,tsx}
Default exclusions:
**/node_modules/****/dist/****/build/****/coverage/****/.next/****/out/****/storybook-static/****/__generated__/****/generated/****/*.generated.*
Detection heuristics:
- PascalCase function declarations that return JSX
- PascalCase arrow functions assigned to identifiers that return JSX
- PascalCase function expressions assigned to identifiers that return JSX
- Class components extending
React.Component,Component,React.PureComponent, orPureComponentwith arender()method that returns JSX - Wrapped component declarations such as
memo(...),forwardRef(...),React.memo(...),React.forwardRef(...), and other wrapper calls when the wrapped value resolves to a JSX-returning component
Preserve and no-op cases:
- Lowercase helpers without a wrapped component shape are ignored
- Hooks such as
useThingare ignored unless they are defined through a wrapped component declaration likememo(...) - Utilities and classes without React inheritance are ignored
Metrics
Workflow step name: detect-react-components
Metric: react-component-definition
Cardinality keys:
componentName: Component identifier, oranonymouswhen no safe name is availablecomponentKind:function,arrow-function,function-expression,class,memo,forwardRef, orwrappedexported:trueorfalsedefaultExport:trueorfalsefileExtension:js,jsx,ts, ortsx
Insights Queries
Example package-source query:
json
Example widgets:
- Total React components
json
- Components by kind
json
- Components by repository
json
- Components by directory depth 2
json
- Exported vs non-exported components
json
- Components by file extension
json
Development
bash
License
MIT