Skip to main content

js/noSparseArray

disallow sparse arrays

ESLint Equivalent: no-sparse-arrays

Examples

Invalid

[1,,2]

 file.ts:1:3 lint/js/noSparseArray  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  This array contains an empty slot.

    [1,,2]
       ^

  Sparse arrays without values for some items can lead to confusion.

  Safe fix

  -
  + undefined