-
-
Notifications
You must be signed in to change notification settings - Fork 875
Open
Description
Description
Follow-up to #8043 / PR #8952.
Extend useNullishCoalescing to detect ||= assignment expressions where the left-hand side is possibly nullish and suggest rewriting them as ??=.
Pattern to detect:
a ||= b->a ??= b
The existing type-eligibility and safety logic from the || -> ?? check applies directly here. The main work is adding a new query target for JsAssignmentExpression with the ||= operator, reusing is_possibly_nullish and is_safe_type_for_replacement to gate the diagnostic and fix.
The fix itself is a straightforward token replacement of ||= with ??=, same approach as the existing || -> ?? fix.
References:
- ESLint rule:
AssignmentExpression[operator = "||="]visitor in prefer-nullish-coalescing
Reactions are currently unavailable