Skip to content

refactor: remove 'hooks-extra/prefer-use-state-lazy-initialization' from recommended presets #1001

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

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

Rel1cx
Copy link
Owner

@Rel1cx Rel1cx commented Mar 20, 2025

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • Test
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • I have added a convincing reason for adding this feature, if necessary

Other information

Based on feedback of this rule, the current implementation produces more false positives than expected, so to ensure the overall quality of the rules in the recommended presets we provide, I'm removing it from the presets for now, and should add it back to the recommended presets after we implement a better heuristic for deciding which function calls should be allowed.

Copy link

vercel bot commented Mar 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eslint-react 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 20, 2025 6:37am

@Rel1cx Rel1cx merged commit 41a4d7c into main Mar 20, 2025
7 of 8 checks passed
@Rel1cx Rel1cx deleted the hooks-extra/prefer-use-state-lazy-initialization-2 branch March 20, 2025 06:49
@michaelfaith
Copy link

I'm curious why this was removed from recommended?

@Rel1cx
Copy link
Owner Author

Rel1cx commented Mar 20, 2025

I'm curious why this was removed from recommended?

Sorry for not providing this information in the first place, I added it to the “Other information” above.

Based on feedback of this rule, the current implementation produces more false positives than expected, so to ensure the overall quality of the rules in the recommended presets we provide, I'm removing it from the presets for now, and should add it back after we implement a better heuristic for deciding which function calls should be allowed.

@Rel1cx
Copy link
Owner Author

Rel1cx commented Mar 20, 2025

Related to this, the React Compiler is working on optimizations to ensure that useState initializers only run once. However, it may still take a considerable amount of time to be stable. Until then, we still need this rule. Therefore, after I gather more practical data and make the necessary improvements to the rule (if needed), I will reintegrate it into the recommended presets.

@michaelfaith
Copy link

Thanks for the additional details

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