Skip to content

fix(linter): useExhaustiveDependencies regressions, fixes #8802, fixes #8883, fixes #8885#8900

Merged
mdevils merged 5 commits intobiomejs:mainfrom
mdevils:fixes/use-exhaustive-dependencies-regressions
Jan 29, 2026
Merged

fix(linter): useExhaustiveDependencies regressions, fixes #8802, fixes #8883, fixes #8885#8900
mdevils merged 5 commits intobiomejs:mainfrom
mdevils:fixes/use-exhaustive-dependencies-regressions

Conversation

@mdevils
Copy link
Contributor

@mdevils mdevils commented Jan 28, 2026

Summary

Several bug-fixes:

Fixed #8802: useExhaustiveDependencies now correctly suggests dependencies without including callback-scoped variables or method names.

When accessing object properties with a callback-scoped variable, only the object path is suggested:

// Now correctly suggests `props.value` instead of `props.value[day]`
useMemo(() => {
    return WeekdayValues.filter((day) => props.value[day]);
}, [props.value]);

When calling methods on objects, only the object is suggested as a dependency:

// Now correctly suggests `props.data` instead of `props.data.forEach`
useMemo(() => {
    props.data.forEach((item) => console.log(item));
}, [props.data]);

Fixed #8883: useExhaustiveDependencies no longer produces false positives when props are destructured in the function body of arrow function components without parentheses around the parameter.

type Props = { msg: string };

// Arrow function without parentheses around `props`
const Component: React.FC<Props> = props => {
    const { msg } = props;
    // Previously, this incorrectly reported `msg` as unnecessary
    useEffect(() => console.log(msg), [msg]);
};

Fixed #8885: useExhaustiveDependencies no longer incorrectly reports variables as unnecessary dependencies when they are derived from expressions containing post/pre-increment operators (++/--) or compound assignment operators (+=, -=, etc.).

let renderCount = 0;

export const MyComponent = () => {
    // `count` is now correctly recognized as a required dependency
    // because `renderCount++` can produce different values between renders
    const count = renderCount++;

    useEffect(() => {
        console.log(count);
    }, [count]); // no longer reports `count` as unnecessary
};

Test Plan

Tests are included.

Docs

Changesets are included.

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: a7d697e

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

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

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

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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jan 28, 2026
@mdevils mdevils changed the title Fixes/use exhaustive dependencies regressions fix(linter) useExhaustiveDependencies regressions, fixes #8802, fixes #8883, fixes #8885 Jan 28, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

Updates the useExhaustiveDependencies analysis to: avoid suggesting callback‑scoped variables or method names as dependencies; stop reporting false positives when props are destructured in the function body; and treat values derived from pre/post‑increment or compound assignments as required dependencies. Adds constant‑aware checks via is_constant, refines declaration resolution for arrow‑function parameters and identifier bindings, and introduces early returns/guards for computed/member/call expression patterns. New tests exercise these cases.

Possibly related PRs

Suggested labels

A-Parser

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references the main changes: fixes to useExhaustiveDependencies rule for issues #8802, #8883, and #8885, which aligns with the changeset.
Description check ✅ Passed The description is well-detailed and related to the changeset. It explains three specific fixes with code examples and references the linked issues.
Linked Issues check ✅ Passed All three linked issues have corresponding fixes: #8802 (callback-scoped variables), #8883 (destructuring in function body), and #8885 (increment/compound operators). The code changes address the primary objectives of each issue.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the three linked issues. The modifications to use_exhaustive_dependencies.rs, is_constant.rs, and test files are all related to the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

❤️ Share

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 28, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing mdevils:fixes/use-exhaustive-dependencies-regressions (a7d697e) with main (d78e01d)

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1

Footnotes

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

@mdevils mdevils changed the title fix(linter) useExhaustiveDependencies regressions, fixes #8802, fixes #8883, fixes #8885 fix(linter): useExhaustiveDependencies regressions, fixes #8802, fixes #8883, fixes #8885 Jan 29, 2026
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Great work as usual, thank you @mdevils

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

Labels

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

Projects

None yet

3 participants