Skip to content

fix(lint): add ignoreBooleanCoercion with scope resolution to useNullishCoalescing#9936

Closed
SAY-5 wants to merge 1 commit intobiomejs:mainfrom
SAY-5:fix/nullish-coalescing-boolean-check
Closed

fix(lint): add ignoreBooleanCoercion with scope resolution to useNullishCoalescing#9936
SAY-5 wants to merge 1 commit intobiomejs:mainfrom
SAY-5:fix/nullish-coalescing-boolean-check

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 12, 2026

Fixes #9842.
Added ignoreBooleanCoercion option (default false) to useNullishCoalescing. When enabled, suppresses || diagnostics inside Boolean() calls only when Boolean refers to the global built-in. If Boolean is shadowed locally, the diagnostic still fires.

…useNullishCoalescing

The new option suppresses diagnostics for || expressions inside Boolean()
calls, but only when Boolean resolves to the global built-in constructor.
If Boolean is shadowed by a local binding, the diagnostic still fires.

Closes #9842
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 12, 2026

🦋 Changeset detected

Latest commit: 9effd69

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 Apr 12, 2026
@ematipico ematipico closed this Apr 12, 2026
@ematipico ematipico added the M-Likely Agent Meta: this was likely an automated PR without a human in the loop label Apr 12, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4fc3c99f-3237-4c77-b05b-399686436a24

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa85f5 and 9effd69.

📒 Files selected for processing (5)
  • .changeset/fix-nullish-coalescing-boolean-scope.md
  • crates/biome_js_analyze/src/lint/nursery/use_nullish_coalescing.rs
  • crates/biome_js_analyze/tests/specs/nursery/useNullishCoalescing/ignoreBooleanCoercionEnabled.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useNullishCoalescing/ignoreBooleanCoercionEnabled.ts
  • crates/biome_rule_options/src/use_nullish_coalescing.rs

Walkthrough

This PR introduces a new ignoreBooleanCoercion option to the useNullishCoalescing linter rule that suppresses diagnostics for || expressions appearing as arguments to the global Boolean() constructor. The implementation includes scope-aware validation to verify that Boolean resolves to the global built-in rather than a locally shadowed function. When shadowing is detected, the diagnostic continues to fire. Changes span the rule definition, options configuration, helper logic, and comprehensive test coverage.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript, A-Diagnostic

Suggested reviewers

  • ematipico
  • dyc3
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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 M-Likely Agent Meta: this was likely an automated PR without a human in the loop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📎 useNullishCoalescing: ignoreBooleanCoercion should verify Boolean is the global built-in

2 participants