Skip to content

fix(useOptionalChain): regression#9430

Merged
ematipico merged 1 commit intomainfrom
fix/rule-regression
Mar 10, 2026
Merged

fix(useOptionalChain): regression#9430
ematipico merged 1 commit intomainfrom
fix/rule-regression

Conversation

@ematipico
Copy link
Member

Summary

Closes #9428

No changeset needed. The bug was introduced in a preview release (not yet published).

Test Plan

Added new tests

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

⚠️ No Changeset found

Latest commit: e655dca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@ematipico ematipico requested review from a team March 10, 2026 08:24
@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 10, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0d1ebeaf-9c63-4f7e-a5ff-fd49c34a21a8

📥 Commits

Reviewing files that changed from the base of the PR and between 1555948 and e655dca.

⛔ Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/complexity/useOptionalChain/validLogicalAndUnrelatedOperands.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/lint/complexity/use_optional_chain.rs
  • crates/biome_js_analyze/tests/specs/complexity/useOptionalChain/validLogicalAndUnrelatedOperands.js

Walkthrough

Addresses a false positive in the useOptionalChain rule by adding an early guard condition to the LogicalAndChain::cmp_chain method that immediately returns Different when the comparison chain's buffer is empty. Additionally, introduces a test file containing logical AND expressions with unrelated operands to prevent future regressions of this scenario.

Possibly related PRs

  • #7387: Modifies the same useOptionalChain linter file and updates methods on the LogicalAndChain type for optional chain expression handling.

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • denbezrukov
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the fix: a regression in the useOptionalChain rule.
Description check ✅ Passed The description clearly references issue #9428 and explains the regression fix with added tests.
Linked Issues check ✅ Passed The code changes address the false positives reported in #9428 by fixing the comparison logic for unrelated operands in logical AND chains.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the useOptionalChain rule regression and adding corresponding validation tests.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rule-regression

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

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 10, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing fix/rule-regression (e655dca) with main (61e2a02)

Open in CodSpeed

Footnotes

  1. 156 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.

@ematipico ematipico merged commit f98dee2 into main Mar 10, 2026
17 checks passed
@ematipico ematipico deleted the fix/rule-regression branch March 10, 2026 08:54
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.

💅 useOptionalChain in preview start having false positive

2 participants