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 preset.

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 items: string[] = [];
items.push("a");
items.push("b");
items.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 ❤️‍🔥 in Boston by Josh Goldberg and contributors.