Skip to content

combinedPushes

Reports consecutive array.push() calls that could be combined into a single call.

✅ This rule is included in the ts stylistic and stylisticStrict presets.

Multiple consecutive .push() calls on the same array can be combined into a single call. Using .push(a, b, c) is more concise than separate .push(a), .push(b), .push(c) calls.

const
const items: string[]
items
: string[] = [];
const items: string[]
items
.
Array<string>.push(...items: string[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
("a");
const items: string[]
items
.
Array<string>.push(...items: string[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
("b");
const items: string[]
items
.
Array<string>.push(...items: string[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
("c");

This rule is not configurable.

If you prefer the visual separation of individual .push() calls, or if you’re intentionally pushing items one at a time for debugging or other purposes, you can disable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.