Skip to content

fix(linter): useExhaustiveDependencies revert object method call behavior change, fixes #8958#9017

Merged
ematipico merged 1 commit intobiomejs:mainfrom
mdevils:fix/use-exhaustive-dependencies-revert-behavior-change
Feb 10, 2026
Merged

fix(linter): useExhaustiveDependencies revert object method call behavior change, fixes #8958#9017
ematipico merged 1 commit intobiomejs:mainfrom
mdevils:fix/use-exhaustive-dependencies-revert-behavior-change

Conversation

@mdevils
Copy link
Contributor

@mdevils mdevils commented Feb 9, 2026

Summary

Reverted a behavior change in useExhaustiveDependencies that was accidentally included as part of the #8802 fix. The change made method calls on objects (e.g., props.data.forEach(...)) report only the object (props.data) as a missing dependency instead of the full member expression. This behavior change will be reconsidered separately.

Closes #8958

Test Plan

Test was updated.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 9, 2026

🦋 Changeset detected

Latest commit: c2fa48f

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 Feb 9, 2026
@mdevils mdevils changed the title fix(linter): useExhaustiveDependencies revert object method call be… fix(linter): useExhaustiveDependencies revert object method call behavior change, fixes #8958 Feb 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Walkthrough

This PR reverts a recent behaviour change in the useExhaustiveDependencies linter rule. It removes a conditional block that previously skipped reporting method calls on objects, restoring the original logic where expressions like props.data.forEach(...) report the full member expression as a missing dependency rather than just the base object. The changeset entry accompanies the revert as a patch for @biomejs/biome, with test simplifications reflecting the single-component scenario.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses #8958 by reverting the unintended behaviour change that caused incorrect dependency reporting, restoring previous functionality.
Out of Scope Changes check ✅ Passed All changes are within scope: the revert of the method call behaviour in the linter rule, the changeset entry, and the test file update directly address the linked issue.
Title check ✅ Passed The title accurately describes the main change: reverting a behaviour change in useExhaustiveDependencies and fixing the associated issue.
Description check ✅ Passed The description clearly explains the revert, the unintended behaviour change being fixed, and references the related issues appropriately.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts`:
- Around line 16-19: Reintroduce a test that covers the props.data.forEach call
pattern by adding back a Component2 (or equivalent) that calls
props.data.forEach(...) inside a hook callback (e.g., useMemo or useEffect) with
an empty dependency array so the analyzer must detect the dependency;
specifically, create a Component2 function that accepts props.data and invokes
props.data.forEach(item => { /* access item or mutate local */ }) inside the
hook body (mirroring the original regression case) to ensure the forEach pattern
is exercised by the test suite.

Comment on lines +16 to 19
function Component(props: { value: Days }) {
useMemo(() => {
return WeekdayValues.filter((day) => props.value[day]);
}, []);
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

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the actual test file to see what was there
cat crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts

Repository: biomejs/biome

Length of output: 611


🏁 Script executed:

# Search for forEach patterns in the useExhaustiveDependencies test directory
rg -rn 'forEach' crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/ --type=ts

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Also search for issue `#8958` references in the codebase
rg -rn '8958' crates/biome_js_analyze/tests/ --type=ts

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Search more broadly for `#8958` or issue8958 references
rg -rn '8958' crates/biome_js_analyze/

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Search for forEach in all useExhaustiveDependencies related files
fd 'useExhaustiveDependencies' crates/biome_js_analyze/ --type f

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Check git history to see what Component2 contained before removal
cd crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies && git log --oneline -n 20 issue8802.ts

Repository: biomejs/biome

Length of output: 161


🏁 Script executed:

# Check the specific commit to see what Component2 was and why it was removed
git show c2fa48f1:crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts

Repository: biomejs/biome

Length of output: 611


🏁 Script executed:

# Check the current commit to see if there are multiple components or just one
git log --oneline -n 5 crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts

Repository: biomejs/biome

Length of output: 161


🏁 Script executed:

# Check what the file looked like before the fixing commit
git show c2fa48f1^:crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts 2>/dev/null || echo "File may not have existed before"

Repository: biomejs/biome

Length of output: 89


🏁 Script executed:

# Get more detailed git log to see if there were previous versions
git log --all --oneline -- crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts | head -20

Repository: biomejs/biome

Length of output: 270


🏁 Script executed:

# Check the previous commit f788cff2 to see what Component2 contained
git show f788cff2:crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts

Repository: biomejs/biome

Length of output: 955


🏁 Script executed:

# Check the diff between the two commits to see exactly what was removed
git diff f788cff2 c2fa48f1 -- crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts

Repository: biomejs/biome

Length of output: 1294


🏁 Script executed:

# Search more broadly for forEach patterns in the entire useExhaustiveDependencies test suite
find crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies -name "*.ts" -exec grep -l "forEach" {} \;

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Check if there's a dedicated test for issue `#8958`
find crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies -name "*8958*"

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Look at the commit message more carefully to understand the intent
git show c2fa48f1 --stat | head -30

Repository: biomejs/biome

Length of output: 1780


🏁 Script executed:

# Check if there are any other tests for forEach or method calls in the useExhaustiveDependencies directory
find crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies -name "*.ts" | xargs ls -la

Repository: biomejs/biome

Length of output: 1141


🏁 Script executed:

# Look at the linter code change to understand what was reverted
git show c2fa48f1 -- crates/biome_js_analyze/src/correctness/use_exhaustive_dependencies.rs | head -100

Repository: biomejs/biome

Length of output: 39


🏁 Script executed:

# Let's check the actual linter implementation to understand what behavior was reverted
git show c2fa48f1 crates/biome_js_analyze/src/correctness/use_exhaustive_dependencies.rs 2>&1 | head -150

Repository: biomejs/biome

Length of output: 307


🏁 Script executed:

# Look at the expected test output files to understand what the test validates
cat crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts.snap

Repository: biomejs/biome

Length of output: 1987


Add a test for the forEach method call pattern from issue #8958.

The removed Component2 tested the specific props.data.forEach(...) pattern that triggered the original regression. Without it, that scenario no longer has regression test coverage. Worth re-adding to prevent re-introducing the same issue.

🤖 Prompt for AI Agents
In
`@crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/issue8802.ts`
around lines 16 - 19, Reintroduce a test that covers the props.data.forEach call
pattern by adding back a Component2 (or equivalent) that calls
props.data.forEach(...) inside a hook callback (e.g., useMemo or useEffect) with
an empty dependency array so the analyzer must detect the dependency;
specifically, create a Component2 function that accepts props.data and invokes
props.data.forEach(item => { /* access item or mutate local */ }) inside the
hook body (mirroring the original regression case) to ensure the forEach pattern
is exercised by the test suite.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 9, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1


Comparing mdevils:fix/use-exhaustive-dependencies-revert-behavior-change (c2fa48f) with main (9d4cfa3)

Open in CodSpeed

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 requested a review from ematipico February 10, 2026 09:21
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.

Thank you @mdevils

@ematipico ematipico merged commit 8bac2da into biomejs:main Feb 10, 2026
21 checks passed
@github-actions github-actions bot mentioned this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 2.3.14 introduces incorrect behavior to useExhaustiveDeps

2 participants