---
title: "lint/arrays/prefer-array-spread"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/arrays/prefer-array-spread" />

In the [`modernize`](/docs/rules/sets/modernize) set. Unsafe fix: it can change behaviour.

## What it does

Detects calls to `array_merge()` and suggests using the array spread operator (`...`) in an array literal instead.

## Configuration

```toml title="pun.toml"
[lint.rules]
"arrays/prefer-array-spread" = "error"
```

To skip it in some files or lines, add an [override](/docs/configuration/pun-toml#lint) or an [ignore comment](/docs/configuration/ignore-comments).

## Replaces

- [`Pun/prefer_array_spread`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/) (pun)
- [`prefer-array-spread`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-array-spread) (mago-linter)

[More lint/arrays rules](/docs/rules/lint/arrays) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
