eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
Rule proposal: `logical-assignment-operators` replacement
Description
The core rule logical-assignment-operators auto fixes
if (!a) {
a = 1
}
to
a ||= 1
But sometimes, a ??= 1 should be preferred, and ESLint refuses to use suggestions instead, https://github.com/eslint/eslint/issues/19672
How about we make our own one?
Examples
// ❌
if (!a) {
a = 1
}
// ✅
a ||= 1
// ✅
a ??= 1
Proposed rule name
logical-assignment-operators
Additional Info
No response
Accepted