# unicorn/consistent-empty-array-spread

> Require both branches of a spread ternary in an array to have the same type

Spreading `[]` and spreading `""` both add nothing to an array, so either works as the "nothing" branch of `...(condition ? items : fallback)`. But when one branch is an array and the other is a string, the reader needs to stop and work out that the mismatch is harmless.

The rule reports an array followed by `""`, and a string followed by `[]`. It only looks at the fallback after the `:`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/consistent-empty-array-spread" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const args = ["build", ...(watch ? ["--watch", "--hot"] : "")];
```

{/* bad */}
```js
const letters = ["a", ...(more ? "bc" : [])];
```

Not reported:

{/* good */}
```js
const args = ["build", ...(watch ? ["--watch", "--hot"] : [])];

const letters = ["a", ...(more ? "bc" : "")];
```
