Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wip] fix(useComponentExportOnlyModules): Proper evaluation of the hook #4429

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

GunseiKPaseri
Copy link
Contributor

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 useReactRefresh to 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 noDefaultExport rule.
  • 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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 29, 2024
Copy link

codspeed-hq bot commented Oct 29, 2024

CodSpeed Performance Report

Merging #4429 will improve performances by 6.97%

Comparing GunseiKPaseri:4424-allow-memo (bac6c02) with main (fe792ed)

Summary

⚡ 1 improvements
✅ 96 untouched benchmarks

Benchmarks breakdown

Benchmark main GunseiKPaseri:4424-allow-memo Change
pure_9395922602181450299.css[cached] 3.6 ms 3.4 ms +6.97%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 useComponentExportOnlyModules does not allow wrapping with forwardRef or memo
1 participant