Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mdevils
Copy link
Contributor

@mdevils mdevils commented Dec 20, 2025

Summary

Fixes #8499: useExhaustiveDependencies properly handles aliased destructured object keys when using stableResult configuration.

Test Plan

Test is included.

Docs

Changeset is included.

@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2025

🦋 Changeset detected

Latest commit: 5884c44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Dec 20, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 20, 2025

Walkthrough

This pull request fixes the useExhaustiveDependencies rule to correctly handle aliased destructured object keys when stableResult configuration is used. The fix updates the key extraction logic in is_binding_react_stable to traverse destructuring patterns and resolve binding names, whilst maintaining fallback support for non-destructuring bindings. A changelog entry and test cases are included to validate the correction.

Suggested labels

A-Diagnostic

Suggested reviewers

  • ematipico
  • siketyan

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarises the main fix: handling aliased destructured object keys in useExhaustiveDependencies with stableResult configuration.
Description check ✅ Passed Description references issue #8499 and explains the fix, test inclusion, and changeset inclusion, all related to the actual changes.
Linked Issues check ✅ Passed PR addresses issue #8499 by fixing the linter rule to properly handle aliased destructured keys when stableResult is configured, with tests and changelog included.
Out of Scope Changes check ✅ Passed All changes (hook logic enhancement, test file, test options, and changelog) are directly scoped to fixing the reported false positive issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52aa3a4 and 5884c44.

⛔ Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/rich-parrots-learn.md (1 hunks)
  • crates/biome_js_analyze/src/react/hooks.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/rich-parrots-learn.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
  • crates/biome_js_analyze/src/react/hooks.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `language` to `jsx`, `ts`, or `tsx` for rules that only apply to specific JavaScript dialects

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Documentation
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: autofix
🔇 Additional comments (1)
crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts (1)

1-24: Test coverage looks spot on.

Both scenarios are cleanly demonstrated: the working non-aliased destructuring (SuccessComp) and the previously-failing aliased destructuring (FailedComp). The comment on line 18 helpfully documents the false positive scenario this fix addresses.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.changeset/rich-parrots-learn.md (1)

1-5: Consider adding a code example to illustrate the fix.

The changeset is concise and correctly formatted, but the coding guidelines recommend including code examples for rule changes. A brief before/after snippet would help users understand the impact.

💡 Suggested enhancement
 ---
 "@biomejs/biome": patch
 ---
 
-Fixed #8499: `useExhaustiveDependencies` properly handles aliased destructured object keys when using `stableResult` configuration.
+Fixed #8499: `useExhaustiveDependencies` properly handles aliased destructured object keys when using `stableResult` configuration.
+
+```ts
+const { stable: alias } = useStable();
+useEffect(() => {
+  console.log(alias); // No longer incorrectly flagged as missing dependency
+}, []);
+```

Based on coding guidelines for changeset files.

crates/biome_js_analyze/src/react/hooks.rs (1)

274-286: Consider using text_trimmed() for consistency.

The fix correctly resolves the aliased destructuring issue. However, there's a minor inconsistency: line 279 uses .to_string() whilst the fallback path (line 285) uses .text_trimmed().to_string(). For consistency and robustness, consider using text_trimmed() in both paths.

🔎 Suggested change
     let key = binding
         // Handle cases like const { foo: bar } = useSomething();
         .parent::<JsObjectBindingPatternProperty>()
         .and_then(|pattern_property| pattern_property.member().ok())
         .and_then(|member| member.name())
-        .map(|name_token| name_token.to_string())
+        .map(|name_token| name_token.text_trimmed().to_string())
         .or_else(|| {
             // Handle the rest of the cases, i.e., var foo = useSomething();
             binding
                 .name_token()
                 .ok()
                 .map(|token| token.text_trimmed().to_string())
         });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a704be9 and 52aa3a4.

📒 Files selected for processing (5)
  • .changeset/rich-parrots-learn.md (1 hunks)
  • crates/biome_js_analyze/src/react/hooks.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts (1 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts.snap.new (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Write changesets that are concise (1-3 sentences), user-focused, use past tense for actions taken and present tense for Biome behavior, include code examples for rules, and end sentences with periods

Files:

  • .changeset/rich-parrots-learn.md
crates/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update inline rustdoc documentation for rules, assists, and their options when adding new features or changing existing features in Rust crates

Files:

  • crates/biome_js_analyze/src/react/hooks.rs
🧠 Learnings (22)
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/tests/specs/**/*.jsonc : Use `.jsonc` files to contain arrays of code snippet strings for snapshot tests

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts.snap.new
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `options` code block property for rule-specific configuration snippets in documentation

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `full_options` code block property for complete biome.json configuration snippets in documentation

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Add `sources` field with `RuleSource` to cite ESLint or other rules that inspired the implementation

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/tests/specs/**/*invalid* : Create test files prefixed with `invalid` for code that should trigger the rule

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/tests/specs/**/*valid* : Create test files prefixed with `valid` for code that should not trigger the rule

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `language` to `jsx`, `ts`, or `tsx` for rules that only apply to specific JavaScript dialects

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
  • crates/biome_js_analyze/src/react/hooks.rs
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Add `issue_number` field to `declare_lint_rule!` macro for work-in-progress rules

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-11-21T01:10:53.059Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8171
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:125-137
Timestamp: 2025-11-21T01:10:53.059Z
Learning: In the Biome codebase, each lint rule has its own options type declaration (e.g., `type Options = RuleNameOptions`) as part of the codegen process, even if the options struct is empty or unused. This is standard practice and should not be flagged as an issue.

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-09-25T12:32:59.003Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7593
File: crates/biome_service/src/workspace/server.rs:1306-1306
Timestamp: 2025-09-25T12:32:59.003Z
Learning: In the biomejs/biome project, do not flag compilation errors during code review as they are handled by the existing test infrastructure and CI. Focus on other code quality aspects instead.

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules should check syntax according to language specification and emit error diagnostics

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules should perform static analysis of source code to detect invalid or error-prone patterns and emit diagnostics with proposed fixes

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Run `just l` to lint analyzer rule code

Applied to files:

  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json
📚 Learning: 2025-12-12T10:11:05.564Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-12T10:11:05.564Z
Learning: Create a changeset for user-facing bug fixes and features using `just new-changeset`, selecting appropriate packages and change type (`major`, `minor`, or `patch`)

Applied to files:

  • .changeset/rich-parrots-learn.md
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Assist rules should detect refactoring opportunities and emit code action signals

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Check if a variable is global using the semantic model to avoid false positives

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts.snap.new
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/react/hooks.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (4)
crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.options.json (1)

1-22: LGTM!

The test configuration correctly sets up the scenario to verify the fix for aliased destructured stable values.

crates/biome_js_analyze/src/react/hooks.rs (1)

6-7: LGTM!

The import additions correctly support the enhanced destructuring pattern handling.

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts.snap.new (1)

1-33: LGTM!

The snapshot correctly captures the test scenario demonstrating both successful and previously-failing cases.

crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8499.ts (1)

1-24: Excellent test coverage!

The test file clearly demonstrates both the working case and the previously-failing aliased destructuring case, making it easy to verify the fix addresses the issue.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 20, 2025

CodSpeed Performance Report

Merging #8529 will not alter performance

Comparing mdevils:fix/issue-8499-use-exhaustive-dependencies-aliased-key (5884c44) with main (c89cfe2)

Summary

✅ 58 untouched
⏩ 95 skipped1

Footnotes

  1. 95 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

…tructured object keys when using `stableResult` configuration.
@mdevils mdevils force-pushed the fix/issue-8499-use-exhaustive-dependencies-aliased-key branch from 52aa3a4 to 5884c44 Compare December 21, 2025 00:02
@mdevils mdevils merged commit 8794883 into biomejs:main Dec 21, 2025
18 checks passed
@github-actions github-actions bot mentioned this pull request Dec 20, 2025
dibashthapa pushed a commit to dibashthapa/biome that referenced this pull request Dec 21, 2025
…tructured object keys when using `stableResult` configuration (biomejs#8529)
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.

💅 useExhaustiveDependencies false positive on aliased keys

2 participants