Description
Description
Follow-up to #9232.
The ignoreBooleanCoercion option currently suppresses diagnostics for any || expression inside a call to a function named Boolean, without verifying that the callee resolves to the global Boolean constructor. If a user shadows Boolean with a local function, the option incorrectly suppresses the diagnostic.
Current behavior (incorrect):
function Boolean(x: unknown): boolean { return !!x; }
declare const a: string | null;
const r = Boolean(a || 'default'); // no diagnostic when ignoreBooleanCoercion is true
The diagnostic should still fire here because Boolean is not the global built-in.
Expected behavior:
Only suppress the diagnostic when Boolean resolves to the global built-in, not a locally defined function.
The ESLint rule handles this by checking the scope chain to confirm the identifier has no local definitions. The current Biome implementation uses call.has_callee("Boolean"), which is a name-only check.
Fixing this likely requires either switching the rule's query type from Typed<T> to Semantic<T> for scope/binding resolution, or finding an alternative way to check whether Boolean is shadowed using the available infrastructure.
References:
- ESLint implementation:
isBuiltInBooleanCall checks scope.set.get("Boolean") for local definitions
- Biome implementation:
is_in_boolean_call_context in crates/biome_js_analyze/src/lint/nursery/use_nullish_coalescing.rs
Description
Description
Follow-up to #9232.
The
ignoreBooleanCoercionoption currently suppresses diagnostics for any||expression inside a call to a function namedBoolean, without verifying that the callee resolves to the globalBooleanconstructor. If a user shadowsBooleanwith a local function, the option incorrectly suppresses the diagnostic.Current behavior (incorrect):
The diagnostic should still fire here because
Booleanis not the global built-in.Expected behavior:
Only suppress the diagnostic when
Booleanresolves to the global built-in, not a locally defined function.The ESLint rule handles this by checking the scope chain to confirm the identifier has no local definitions. The current Biome implementation uses
call.has_callee("Boolean"), which is a name-only check.Fixing this likely requires either switching the rule's query type from
Typed<T>toSemantic<T>for scope/binding resolution, or finding an alternative way to check whetherBooleanis shadowed using the available infrastructure.References:
isBuiltInBooleanCallchecksscope.set.get("Boolean")for local definitionsis_in_boolean_call_contextincrates/biome_js_analyze/src/lint/nursery/use_nullish_coalescing.rs