# consistent-conditional-object-spread πŸ“ Enforce consistent conditional object spread style. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). When conditionally spreading properties into an object literal, pick one style consistently. By default, this rule prefers `&&` because it avoids an unnecessary empty object branch. ## Examples ```js // ❌ const object = {...(condition ? {property} : {})}; // βœ… const object = {...(condition && {property})}; ``` An `undefined` or `null` fallback branch spreads nothing, so it is treated the same as an empty object: ```js // ❌ const object = {...(condition ? {property} : undefined)}; // βœ… const object = {...(condition && {property})}; ``` With the `'ternary'` option: ```js // eslint unicorn/consistent-conditional-object-spread: ["error", "ternary"] // ❌ const object = {...(condition && {property})}; // βœ… const object = {...(condition ? {property} : {})}; ``` ## Options Type: `string`\ Default: `'logical'` Available options: - `'logical'` - Prefer `...(condition && object)`. - `'ternary'` - Prefer `...(condition ? object : {})`.