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.
Examples
Section titled “Examples”const items: string[] = [];
items.push("a");items.push("b");items.push("c");const items: string[] = [];
items.push("a", "b", "c");Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
unicorn/prefer-single-call
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.