menu

manual-fill

Prefer fill over an index loop assigning one repeated value

An index loop from zero to an array or slice length that assigns one repeated value spells the fill operation manually. Instead, you SHOULD call fill with that value.

Reported

1function clear(values: int32[]): void {2    for (let index: isize = 0; index < values.length; index++) {3        values[index] = 0;4    }5}

Accepted

1function clear(values: int32[]): void {2    values.fill(0);3}