📎 useExhaustiveDependencies - Implement Configurable Stable Hooks in biome.json #1128
Labels
A-Linter
Area: linter
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
Description
I'm proposing an enhancement for the Biome linter, inspired by ESLint's handling of similar issues (Issue #16873). The key idea is to enable the specification of stable custom hooks in
biome.json
, akin to how React'suseState
is treated in dependency arrays. This feature aims to improve consistency and developer experience when working with various state management libraries like Recoil. For further background and discussion, you can refer to this discussion.Background
The current
use_exhaustive_dependencies
rule in Biome does not differentiate between hooks that require their setter functions to be included in dependency arrays and those that do not. For example, with React's useState, we don't need to include the setter function in dependency arrays:However, with similar hooks from other libraries, like useRecoilState from Recoil, the setter must be included:
This inconsistency can lead to confusion and potential issues in dependency management.
Proposed Feature
The idea is to introduce a new configuration option in biome.json to designate specific hooks as stable. For example:
In this configuration,
useRecoilState
would be treated as entirely stable, whileuseResetRecoilState
would have its first index marked as stable and the second as not.Technical Challenges and Request for Contribution
While I have made a preliminary attempt at this (Commit f0433f18), I must confess that my experience with Rust is quite limited. As a result, I am not in a position to commit these changes to the project myself. Therefore, I am seeking assistance from more experienced Rust developers in our community to help implement this feature.
The text was updated successfully, but these errors were encountered: