[Wip] fix(useComponentExportOnlyModules): Proper evaluation of the hook
Summary
Close #4424
This rule is designed to determine whether an exported item is a component or not and to enforce exporting according to specific guidelines. Exceptionally, components wrapped with standard React hooks like memo or forwardRef are also recognized as components. However, until now, only variables specified as arguments were permitted, which led to an issue where declaring a function directly as an argument to memo resulted in it being misclassified as a non-component. This update aligns with the original rule by prioritizing variable names and ensuring that no hook-related errors occur outside of default exports.
Concerns:
The modification now allows functions specified as arguments to be treated as components. However, for strict evaluation, it may also be necessary to check whether the export is anonymous. This addition, however, would deviate from the rule's original purpose.
Options:
- During the nursery phase, rename to
useReactRefreshto align closely with its function, though concerns remain about rule bloat and potential instability. - Develop a separate rule specifically for anonymous exports in default exports, although it’s unclear how to handle this alongside the
noDefaultExportrule. - Create a plugin. However, I am uncertain of GritQL’s potential, as replicating the conditional logic of the current rule in a query language seems challenging.
Test Plan
CodSpeed Performance Report
Merging #4429 will not alter performance
Comparing GunseiKPaseri:4424-allow-memo (bac6c02) with main (fe792ed)
Summary
✅ 92 untouched benchmarks
@GunseiKPaseri are you still interested in this PR?