Skip to content

Conversation

@Bertie690
Copy link
Contributor

@Bertie690 Bertie690 commented Dec 8, 2025

Summary

Fixes biomejs/website#2531

Added information for both the rule options and what the rule actually does.

Rules should clearly and overtly explain why a given diagnostic is being triggered and why such behavior can be undesirable.
One should not assume one's audience already knows why you need to specify hook dependencies, especially for a rule designed to catch common errors.

Important

I removed mention of useDebugValue/useDeferredvalue due to them being presumably false alarms - they lack any form of handling in the rule source, don't take dependency arrays at all and don't even return anything.
I'd presume these were a holdover from prior, but idk

Test Plan

Added doc tests for the options to make them work

Docs

Added docs and such

@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: c04f662

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

@Bertie690 Bertie690 changed the title docs: updated documentation for useExhaustiveDependencies docs: update documentation for useExhaustiveDependencies Dec 8, 2025
@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Dec 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Reworks the useExhaustiveDependencies rule documentation and diagnostic messages in the JavaScript analyser. Updates include expanded explanations, new examples, added options (including reportMissingDependenciesArray and reportUnnecessaryDependencies), clearer stability/closure guidance and more granular stable-result configuration, plus refined diagnostic wording about stale closures, missing or unnecessary dependencies and performance. Public exports and signatures remain unchanged.

Suggested reviewers

  • dyc3
  • arendjr
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the primary change—documentation updates for the useExhaustiveDependencies rule, matching the changeset content.
Description check ✅ Passed The description clearly relates to the changeset, explaining documentation enhancements, option additions, and rationale for removing outdated hook references.
Linked Issues check ✅ Passed The PR directly addresses issue #2531 by documenting the missing options reportMissingDependenciesArray and reportUnnecessaryDependencies in the rule documentation.
Out of Scope Changes check ✅ Passed All changes focus on documentation and diagnostic message clarity for useExhaustiveDependencies, with no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 (3)
.changeset/old-seas-drum.md (1)

1-7: Polish wording, fix typo, and add a small heading

Nice concise changeset, but you’ve got a tiny typo and a chance to align more closely with the local CONTRIBUTING guidance.

  • Fix spelling: undesireableundesirable.
  • Add a short #### heading to describe the change, as recommended for .changeset files.
  • Slightly rephrase to separate “what was done” (past tense) from “current behaviour” (present tense).

For example:

 ---
 "@biomejs/biome": patch
 ---
 
-The rule documentation & diagnostic messages for `useExhaustiveDependencies` have been reworked for improved clarity among those not immediately familiar with React idioms.
-
-Among other things, it clearly explains why incorrect dependencies are undesireable.
+#### useExhaustiveDependencies diagnostics were clarified
+
+The rule documentation and diagnostic messages for `useExhaustiveDependencies` were reworked for improved clarity for developers who are less familiar with React hooks.
+
+It now explains why incorrect dependencies are undesirable.

Based on learnings, this keeps the changeset aligned with the documented style for rule changes.

crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (2)

120-161: Align doc-test tags and tidy a small comment nit

Two small nits to keep the docs fully consistent with the lint-doc guidelines:

  • In the options examples, put expect_diagnostic directly after the language tag, before other modifiers:
-    /// ```js,options,expect_diagnostic
+    /// ```js,expect_diagnostic,options-    /// ```jsx,use_options,expect_diagnostic
+    /// ```jsx,expect_diagnostic,use_options
  • In the “const name = "foo"” invalid example, there’s a stray backtick at the end of the comment:
-    ///   // name doesn't change, so specifying it is redundant`
+    ///   // name doesn't change, so specifying it is redundant

Based on learnings, this keeps the code-block metadata order and content in line with the project’s lint documentation conventions.

Also applies to: 264-365


981-987: Optional: add a brief “why/how to fix” note for missing arrays

For the MissingDependenciesArray variant you currently only report:

markup! {"This hook does not have a dependencies array."}

If you want this branch to fully match the three-pillar guidance, consider adding a short note explaining impact and fix, e.g.:

-            Fix::MissingDependenciesArray {
-                function_name_range,
-            } => Some(RuleDiagnostic::new(
-                rule_category!(),
-                function_name_range,
-                markup! {"This hook does not have a dependencies array."},
-            )),
+            Fix::MissingDependenciesArray {
+                function_name_range,
+            } => Some(
+                RuleDiagnostic::new(
+                    rule_category!(),
+                    function_name_range,
+                    markup! {"This hook does not have a dependencies array."},
+                )
+                .note(markup! {
+                    "React relies on hook dependencies to decide when to re-run Effects."
+                })
+                .note(markup! {
+                    "Add a dependencies array (for example, " <Emphasis>"[]"</Emphasis>" or " <Emphasis>"[foo, bar]"</Emphasis>") to make your intent explicit."
+                }),
+            ),

Purely a nicety—what you have is already correct and shippable.

Based on learnings, this would make this last branch as explanatory as the others.

📜 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 2f3d0fc and 51702ce.

📒 Files selected for processing (2)
  • .changeset/old-seas-drum.md (1 hunks)
  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (9 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
.changeset/**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/**/*.md: Create changesets for user-facing changes using just new-changeset; use headers with #### or ##### only; keep descriptions concise (1-3 sentences) and focus on user-facing changes
Use past tense when describing what was done ('Added new feature'), present tense when describing Biome behavior ('Biome now supports'); end sentences with a full stop
For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a diff code block

Files:

  • .changeset/old-seas-drum.md
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to .changeset/**/*.md : For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a `diff` code block
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rule diagnostics must explain to the user what the error is, why it is triggered, and what should be done to fix it following the three pillars: (1) what the error is, (2) why the error is triggered, (3) what the user should do
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)
📚 Learning: 2025-11-28T09:08:10.091Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to .changeset/**/*.md : For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a `diff` code block

Applied to files:

  • .changeset/old-seas-drum.md
📚 Learning: 2025-11-28T09:08:10.091Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to .changeset/**/*.md : Create changesets for user-facing changes using `just new-changeset`; use headers with `####` or `#####` only; keep descriptions concise (1-3 sentences) and focus on user-facing changes

Applied to files:

  • .changeset/old-seas-drum.md
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')

Applied to files:

  • .changeset/old-seas-drum.md
  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rule diagnostics must explain to the user what the error is, why it is triggered, and what should be done to fix it following the three pillars: (1) what the error is, (2) why the error is triggered, (3) what the user should do

Applied to files:

  • .changeset/old-seas-drum.md
  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Document rules with a one-line brief description in the first paragraph of the doc comment, followed by detailed paragraphs, `## Examples` section with `### Invalid` and `### Valid` subsections, and optional `## Options` section

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRedundant` prefix for rules that report redundant code (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (1)
crates/biome_service/src/workspace.rs (1)
  • markup (1178-1180)
⏰ 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: Bench (biome_js_formatter)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: End-to-end tests
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Documentation
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (2)

29-252: Docs rework is clear and very user-friendly

This is a solid upgrade: the intro, stale-closure example, unnecessary-dependency example, and the “Stable results” + caution block all read clearly and match the rule’s actual behaviour. The Examples and Options sections follow the expected structure nicely.


986-1109: Diagnostics now hit all three “what / why / how to fix” pillars

The expanded diagnostics for non-literal arrays, missing dependencies, unnecessary dependencies, unstable deps, and too-deep deps are nicely done: they explain what’s wrong, why it matters (stale closures, unnecessary renders, performance), and what users should do (array literal, add/remove deps, wrap in useCallback/useMemo, etc.). This should make the rule far less mysterious to React newcomers.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #8401 will not alter performance

Comparing Bertie690:exhaustive-docs (c04f662) with main (c96dcf2)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

  1. No successful run was found on main (d71924e) during the generation of this report, so c96dcf2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 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.

@github-actions github-actions bot added the A-CLI Area: CLI label Dec 9, 2025
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)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (2)

29-76: Docs are great; a few tiny accuracy/consistency nits

The expanded narrative/examples read really well and align nicely with the rule’s intent. There are just a couple of small tweaks that would keep the docs strictly in sync with the implementation and house style:

  • In the “Stable results” list, the defaults don’t quite match HookConfigMaps::default:

    • Code treats useState and useReducer as stable at index 1, useTransition as stable at index 1, and useRef/useEffectEvent as having a stable identity.
    • The docs currently say useRef (index 1) and leave useTransition without an index.
    • Suggest aligning the bullets to something like:
  • /// - useState (index 1)

  • /// - useRef (index 1)

  • /// - useReducer (index 1)

  • /// - useTransition

  • /// - useEffectEvent

  • /// - useState (index 1)
  • /// - useRef
  • /// - useReducer (index 1)
  • /// - useTransition (index 1)
  • /// - useEffectEvent

- In the “constant dependency” invalid example, there’s a stray backtick and a missing semicolon that might confuse readers skimming quickly:

```diff
-    ///   const name = "foo"
-    ///   // name doesn't change, so specifying it is redundant`
+    ///   const name = "foo";
+    ///   // name doesn't change, so specifying it is redundant
  • For doctest flags, the contributing guide asks for language,expect_diagnostic,options,…. Two blocks currently have use_options before expect_diagnostic:

  • /// ```js,use_options,expect_diagnostic

  • /// ```js,expect_diagnostic,use_options
  • /// ```jsx,use_options,expect_diagnostic
  • /// ```jsx,expect_diagnostic,use_options

This keeps the ordering consistent with other rules and the documented convention.  

Overall, the new sections for `reportUnnecessaryDependencies` and `reportMissingDependenciesArray` look spot on and match the existing option names and defaults.  

Based on learnings, especially the doc-structure and doctest flag ordering guidelines.



Also applies to: 88-103, 151-161, 253-369

---

`981-996`: **Consider expanding the `MissingDependenciesArray` diagnostic to cover “why” and “how”**

The new messaging for non-literal arrays already follows the “what/why/how” pattern nicely. For the `MissingDependenciesArray` case we still only tell the user *what* is wrong.

To align this diagnostic with the same three-pillar guidance (and with the new docs that explain the `reportMissingDependenciesArray` option), consider adding a short note suggesting how to fix it:

```diff
-            Fix::MissingDependenciesArray {
-                function_name_range,
-            } => Some(RuleDiagnostic::new(
-                rule_category!(),
-                function_name_range,
-                markup! {"This hook does not have a dependencies array."},
-            )),
+            Fix::MissingDependenciesArray {
+                function_name_range,
+            } => Some(
+                RuleDiagnostic::new(
+                    rule_category!(),
+                    function_name_range,
+                    markup! {"This hook does not have a dependencies array."},
+                )
+                .note(markup! {
+                    "React relies on dependencies to decide when to re-run hooks. "
+                    "Add a second argument: either " <Emphasis>"[]"</Emphasis> " for Effects that should not re-run,"
+                    " or a list of the values the hook depends on."
+                }),
+            ),

That keeps the runtime behaviour unchanged while giving users an immediate, concrete next step.

Based on learnings, which ask diagnostics to cover what/why/how.

📜 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 51702ce and 04c8d15.

⛔ Files ignored due to path filters (17)
  • crates/biome_cli/tests/snapshots/main_cases_rules_via_dependencies/enables_react_rules_via_dependencies.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/duplicateDependencies.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/invalidSuppressions.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue4567.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue4568.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/reportMissingDependenciesArray.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to .changeset/**/*.md : For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a `diff` code block
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rule diagnostics must explain to the user what the error is, why it is triggered, and what should be done to fix it following the three pillars: (1) what the error is, (2) why the error is triggered, (3) what the user should do

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Document rules with a one-line brief description in the first paragraph of the doc comment, followed by detailed paragraphs, `## Examples` section with `### Invalid` and `### Valid` subsections, and optional `## Options` section

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRedundant` prefix for rules that report redundant code (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (1)
crates/biome_service/src/workspace.rs (1)
  • markup (1178-1180)
⏰ 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: autofix
  • GitHub Check: End-to-end tests
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (3)

1003-1015: Nice improvement to the “missing dependency” diagnostic copy

The reworded Fix::AddDependency message (and the new note about stale closures) does a good job of explaining the problem, why it’s risky, and what to do, without overwhelming the user. The additional detail entries pointing to each capture are especially helpful when there are multiple uses.

No changes suggested here.

Based on learnings, this now clearly hits all three diagnostic pillars.


1036-1053: Clearer messaging for unnecessary dependencies looks good

The updated Fix::RemoveDependency text reads well: it explains that the list is over-specified, calls out performance/re-render behaviour, and then the per-dependency detail distinguishes outer-scope values from simply redundant deps.

This feels like a solid balance between being helpful and not too wordy.

Based on learnings around actionable diagnostics.


1099-1107: DependencyTooDeep wording is understandable and nicely localised

The new phrasing (“dependency more specific than its captures”) plus the paired detail calls on the capture and dependency ranges make it clear what the rule has spotted.

No further suggestions from me.

@github-actions github-actions bot added the A-Project Area: project label Dec 9, 2025
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: 2

📜 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 04c8d15 and c04f662.

⛔ Files ignored due to path filters (3)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
Learning: Applies to .changeset/**/*.md : For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use a `diff` code block
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rule diagnostics must explain to the user what the error is, why it is triggered, and what should be done to fix it following the three pillars: (1) what the error is, (2) why the error is triggered, (3) what the user should do

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Document rules with a one-line brief description in the first paragraph of the doc comment, followed by detailed paragraphs, `## Examples` section with `### Invalid` and `### Valid` subsections, and optional `## Options` section

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRedundant` prefix for rules that report redundant code (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (1)
crates/biome_service/src/workspace.rs (1)
  • markup (1178-1180)
⏰ 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). (13)
  • GitHub Check: Test Node.js API
  • 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: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Documentation
  • GitHub Check: Check JS Files
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_configuration)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs (3)

29-103: Excellent documentation expansion.

The added context about stale closures and the illustrative examples significantly improve understanding for developers unfamiliar with React hook pitfalls. The default behaviour and stable results sections provide clear guidance.


321-368: Well-documented new options.

Both reportUnnecessaryDependencies and reportMissingDependenciesArray are now properly documented with clear defaults, examples, and usage guidance. This directly addresses the missing documentation noted in issue #2531.


1007-1052: Clearer diagnostic messages.

The updated diagnostics now explicitly explain why incorrect dependencies are problematic (stale closures, performance issues) rather than assuming prior knowledge. This aligns well with the rule's educational purpose.

/// console.log(b);
/// }, []);
/// const name = "foo"
/// // name doesn't change, so specifying it is redundant`
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove stray backtick.

The comment ends with an unmatched backtick.

Apply this diff:

-  // name doesn't change, so specifying it is redundant`
+  // name doesn't change, so specifying it is redundant
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// // name doesn't change, so specifying it is redundant`
/// // name doesn't change, so specifying it is redundant
🤖 Prompt for AI Agents
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
around line 156: the doc/comment line ends with an unmatched backtick ("// name
doesn't change, so specifying it is redundant`"); remove the stray trailing
backtick so the comment reads without the backtick, preserving the rest of the
text and punctuation.

/// This would enable diagnostics on the following code snippet:
///
/// ```js
/// ```js,use_options,expect_diagnostic
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Correct code block property ordering.

Per coding guidelines, expect_diagnostic should come before options modifiers like use_options.

Apply this diff to line 277:

-/// ```js,use_options,expect_diagnostic
+/// ```js,expect_diagnostic,use_options

Apply this diff to line 363:

-/// ```jsx,use_options,expect_diagnostic
+/// ```jsx,expect_diagnostic,use_options

Based on learnings, code block properties should be ordered as: language, then expect_diagnostic, then options modifiers.

Also applies to: 363-363

🤖 Prompt for AI Agents
crates/biome_js_analyze/src/lint/correctness/use_exhaustive_dependencies.rs
around lines 277 and 363: the code block property order is incorrect (options
modifier `use_options` appears before `expect_diagnostic`); update the doc test
fence lines so the property order is language, then `expect_diagnostic`, then
options modifiers — replace the line at 277 `///
```js,use_options,expect_diagnostic` with `///
```js,expect_diagnostic,use_options` and the line at 363 `///
```jsx,use_options,expect_diagnostic` with `///
```jsx,expect_diagnostic,use_options`.

@ematipico
Copy link
Member

Thank you for addressing the docs. It seems the CI is failing:

  • outdated diagnostics
  • it seems like a new code block emits two diagnostics instead of one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📚 Missing options for useExhaustiveDependencies

2 participants