Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Latest commit

 

History

History
18 lines (10 loc) · 438 Bytes

no-empty-array.md

File metadata and controls

18 lines (10 loc) · 438 Bytes

no-empty-array

When a collection is empty it makes no sense to access or iterate it. Doing so anyway is surely an error; either population was accidentally omitted or the developer doesn't understand the situation.

Noncompliant Code Example

let strings = [];

if (strings.includes("foo")) {}  // Noncompliant

for (str of strings) {}  // Noncompliant

strings.forEach(str => doSomething(str)); // Noncompliant