Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 496 Bytes

consistent-empty-array-spread.md

File metadata and controls

21 lines (15 loc) · 496 Bytes

Pattern: Inconsistent empty array spread in ternary

Issue: -

Description

When spreading a ternary expression in an array, use consistent types (either arrays or strings) in both branches for better code clarity.

Examples

Example of incorrect code:

const array = [a, ...(foo ? [b, c] : "")];
const array = [a, ...(foo ? "bc" : [])];

Example of correct code:

const array = [a, ...(foo ? [b, c] : [])];
const array = [a, ...(foo ? "bc" : "")];