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

📎 Implement Quick Fix for useExhaustiveDependencies #5309

Open
arendjr opened this issue Mar 9, 2025 · 5 comments · May be fixed by #5326
Open

📎 Implement Quick Fix for useExhaustiveDependencies #5309

arendjr opened this issue Mar 9, 2025 · 5 comments · May be fixed by #5326
Assignees
Labels
A-Linter Area: linter D-React Domain: React L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@arendjr
Copy link
Contributor

arendjr commented Mar 9, 2025

Description

useExhaustiveDependencies can detect when dependencies are incorrect, but it currently lacks an autofix to apply the expected dependencies.

We should implement a fixer for this rule.

Note this fixer would always be unsafe, since users may have intentional reasons for diverging from the suggested dependencies.

@arendjr arendjr added A-Linter Area: linter D-React Domain: React L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project labels Mar 9, 2025
@schang124
Copy link

@arendjr
Thank you for this task to be aligned.
I would like to respectfully request consideration for implementing this capability in an upcoming release.

As React developers, we understand the safety concerns you've highlighted regarding dependencies.
However, our standard workflow typically involves automatically fixing dependencies and adding specific exceptions when necessary. This approach has proven to significantly enhance our development productivity.

I believe that supporting this feature would make Biome a compelling option for many React developers, potentially expanding Biome user base considerably.

@arendjr
Copy link
Contributor Author

arendjr commented Mar 10, 2025

@schang124 You would still be able to configure it according to your workflow: https://biomejs.dev/linter/#configure-the-rule-fix
It just wouldn't be the default setting.

@schang124
Copy link

@arendjr
From this issue thread, you told that it is not supported yet.

  1. When having a useEffect with incorrect dependencies, the only QuickFix available in vscode is "Suppress rule lint/correctness/useExhaustiveDependencies", when what I want is an option to calculate what the dependencies should be, and set it. Is that not possible? It is unreasonable to hand code the dependency lists. I have many hundreds of useEffects

Are you sure it is working now with the configuration?
If not, I guess I wrote too ambiguously. 🙏🏼

@arendjr
Copy link
Contributor Author

arendjr commented Mar 10, 2025

@schang124 No worries! You're right, the rule currently doesn't offer a fix at all. That's what this task is intended to address.

My comment about the configuration was regarding the safety setting. When we implement the fixer, I think it should be an unsafe fix for the reasons I mentioned in the task. But even if we mark it unsafe, you'll be able to configure it so that it will be treated as a safe fix, which will allow for the workflow you mentioned.

@schang124
Copy link

@arendjr
Thank you for your responses.
The auto quick fix function is essential for React developers. I see your team is already working on this, as @siketyan linked the relevant PR.

I greatly appreciate your team's efforts and look forward to its implementation soon!

@siketyan siketyan self-assigned this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter D-React Domain: React L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants