Reports empty object fallbacks in object spread expressions that have no effect.
✅ This rule is included in the ts logical and logicalStrict presets.
When spreading a value into an object literal, JavaScript handles undefined and null by skipping them without throwing an error.
This means that fallback patterns like { ...value || {} } or { ...value ?? {} } are unnecessary.
This rule reports when an object spread fallback is an empty object.
AEconsB0mergAE = <{ sp ansty="le--0:#7FDBCA;--1:#096E">72.{ sp><..sp ansty="le--0:#D6DEEB;--1:#403F">53(optioAE || <{}sp ansty="le--0:#D6DEEB;--1:#403F">5{}sp><3)sp ansty="le--0:#C792EA;--1:#8844">AE3)sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">5 }sp><3;d ivclassNa="meco"><};d>};d>3;d>AEconsB0confAE = <{ sp ansty="le--0:#7FDBCA;--1:#096E">72.{ sp><..sp ansty="le--0:#D6DEEB;--1:#403F">53(settinAE ?? <{}sp ansty="le--0:#D6DEEB;--1:#403F">5{}sp><3)sp ansty="le--0:#C792EA;--1:#8844">AE3)sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">5 }sp><3;d ivclassNa="meco"><};d>};d>3;d>AEconsB0resuAE = <{ sp ansty="le--0:#7FDBCA;--1:#096E">72.{ sp><..sp ansty="le--0:#D6DEEB;--1:#403F">5<3(sp ansty="le--0:#82AAFF;--1:#3B61">B0getVal3(sp>53<()sp ansty="le--0:#C792EA;--1:#8844">AE || ()sp><{}sp ansty="le--0:#D6DEEB;--1:#403F">5{}sp><3)sp ansty="le--0:#C792EA;--1:#8844">AE3)sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">5 }sp><3;d ivclassNa="meco"><};d>};d>3;d>AEconsB0daAE = <{ sp ansty="le--0:#7FDBCA;--1:#096E">72.{ sp><..sp ansty="le--0:#D6DEEB;--1:#403F">53(nestA72properAE ?? <{}sp ansty="le--0:#D6DEEB;--1:#403F">5{}sp><3)sp ansty="le--0:#C792EA;--1:#8844">AE3)sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">5 }sp><3;d ivclassNa="meco"><};d>};d>3;d> 44AEco61B0me44AE <= { spans="tyle--0:#7FDBCA;--1:#09">6E7= { ><2... spans="tyle--0:#D6DEEB;--1:#40">3F53opt2...>443<;di vdivclass="Nameexpressive-">44AEco61B0co44AE <= { spans="tyle--0:#7FDBCA;--1:#09">6E7= { ><2... spans="tyle--0:#D6DEEB;--1:#40">3F53sett2...>443;di><;di vdivclass="Nameexpressive-">44AEco61B0re44AE <= { spans="tyle--0:#7FDBCA;--1:#09">6E7= { ><2... spans="tyle--0:#82AAFF;--1:#3B">61B0getV2...>3F<53() spans="tyle--0:#C792EA;--1:#88">4453()>3<) }>) }>;di><;di vdivclass="Nameexpressive-">44AEco61B044AE <= { spans="tyle--0:#7FDBCA;--1:#09">6E7= { ><2... spans="tyle--0:#D6DEEB;--1:#40">3F53ne2...>4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72prop4AE.>443;di><;di vdivclass="Nameexpressive-">44AEco61B0me44AE <= { spans="tyle--0:#7FDBCA;--1:#09">6E7= { ><2... spans="tyle--0:#D6DEEB;--1:#40">3F53(opt2...>44AE || { defaultVal4848443443<) }>) }>;di>
This rule is not configurable.
If you prefer the explicit fallback pattern for clarity, even when it’s not strictly necessary, you might want to disable this rule.
Some developers find { ...value || {} } more readable as it explicitly signals the intent to handle potentially nullish values, even though the behavior is identical without the fallback.