-
-
Notifications
You must be signed in to change notification settings - Fork 783
docs: update documentation for useExhaustiveDependencies
#8401
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c04f662 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
useExhaustiveDependenciesuseExhaustiveDependencies
WalkthroughReworks the Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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 headingNice concise changeset, but you’ve got a tiny typo and a chance to align more closely with the local CONTRIBUTING guidance.
- Fix spelling:
undesireable→undesirable.- Add a short
####heading to describe the change, as recommended for.changesetfiles.- 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 nitTwo small nits to keep the docs fully consistent with the lint-doc guidelines:
- In the options examples, put
expect_diagnosticdirectly 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 redundantBased 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 arraysFor the
MissingDependenciesArrayvariant 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
📒 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 usingjust 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 adiffcode block
Files:
.changeset/old-seas-drum.md
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust 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.mdcrates/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.mdcrates/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-friendlyThis 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” pillarsThe 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 Performance ReportMerging #8401 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this 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 nitsThe 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
useStateanduseReduceras stable at index 1,useTransitionas stable at index 1, anduseRef/useEffectEventas having a stable identity.- The docs currently say
useRef (index 1)and leaveuseTransitionwithout 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 haveuse_optionsbeforeexpect_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
⛔ Files ignored due to path filters (17)
crates/biome_cli/tests/snapshots/main_cases_rules_via_dependencies/enables_react_rules_via_dependencies.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/duplicateDependencies.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/invalidSuppressions.jsx.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue1931.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue4567.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue4568.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6278.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue6893.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.jsx.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/preactHooks.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/reportMissingDependenciesArray.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/stableResultInvalidKeysIndices.js.snapis excluded by!**/*.snapand 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 thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust 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 copyThe reworded
Fix::AddDependencymessage (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 additionaldetailentries 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 goodThe updated
Fix::RemoveDependencytext reads well: it explains that the list is over-specified, calls out performance/re-render behaviour, and then the per-dependencydetaildistinguishes 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:DependencyTooDeepwording is understandable and nicely localisedThe new phrasing (“dependency more specific than its captures”) plus the paired
detailcalls on the capture and dependency ranges make it clear what the rule has spotted.No further suggestions from me.
There was a problem hiding this 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
⛔ Files ignored due to path filters (3)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand 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 thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust 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
reportUnnecessaryDependenciesandreportMissingDependenciesArrayare 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` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| /// // 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_optionsApply this diff to line 363:
-/// ```jsx,use_options,expect_diagnostic
+/// ```jsx,expect_diagnostic,use_optionsBased 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`.
|
Thank you for addressing the docs. It seems the CI is failing:
|
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/useDeferredvaluedue 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