[Wip] fix(useComponentExportOnlyModules): Proper evaluation of the hook #4429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
orforwardRef
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 tomemo
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:
useReactRefresh
to align closely with its function, though concerns remain about rule bloat and potential instability.noDefaultExport
rule.Test Plan