# no-map-spread

Rule `oxc/no-map-spread`. Disallow the use of object or array spreads in `Array.prototype.map` and `Array.prototype.flatMap` to add properties/elements to array items.

- Source: oxc
- Technologies: JavaScript
- Kind: performance
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1736 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Oxlint | `oxc/no-map-spread` | no | suggestion | plugin `oxc`, category perf | [docs](https://oxc.rs/docs/guide/usage/linter/rules/oxc/no-map-spread.html) |
| Biome | `nursery/noMapSpread` | no | unsafe | group nursery, since 2.6.5 | [docs](https://biomejs.dev/linter/rules/no-map-spread/) |

## Code examples

### Incorrect: the rule reports this

```ts
// each object in scores gets shallow-copied. Since `scores` is never
// reused, spreading is inefficient.
function getDisplayData() {
    const scores: Array<{ username: string, score: number }> = getScores();
    const displayData = scores.map(score => ({ ...score, rank: getRank(score) }));
    return displayData
}
```

```ts
// `score` is mutated in place and is more performant.
function getDisplayData() {
    const scores: Array<{ username: string, score: number }> = getScores();
    const displayData = scores.map(score => Object.assign(score, { rank: getRank(score) }));
    return displayData
}
```

```js
const arr = [{ a: 1 }, { a: 2 }, { a: 3 }];
const arr2 = arr.map(obj => ({ ...obj, b: obj.a * 2 }));
```

### Correct: the rule accepts this

```ts
const arr = [{ a: 1 }, { a: 2 }, { a: 3 }];
arr.map(obj => Object.assign(obj, { b: obj.a * 2 }));

// instance properties are ignored
class UsersDb {
  #users = [];
  public get users() {
    // clone users, providing caller with their own deep(ish) copy.
    return this.#users.map(user => ({ ...user }));
  }
}
```

```tsx
function UsersTable({ users }) {
  const usersWithRoles = users.map(user => ({ ...user, role: getRole(user) }));

  return (
    <table>
      {usersWithRoles.map(user => (
        <tr>
        <td>{user.name}</td>
        <td>{user.role}</td>
        </tr>
      ))}
      <tfoot>
        <tr>
          {/* re-read of users */}
          <td>Total users: {users.length}</td>
        </tr>
      </tfoot>
    </table>
  )
}
```

Examples from the Oxlint documentation.

## Enable it

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "oxc/no-map-spread": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noMapSpread": "error"
      }
    }
  }
}
```

## Related rules

- [oxc/no-async-await](https://lintradar.dev/rules/oxc/no-async-await.md): Disallows the use of `async`/`await`.
- [oxc/no-optional-chaining](https://lintradar.dev/rules/oxc/no-optional-chaining.md): Disallow optional chaining.
- [oxc/no-rest-spread-properties](https://lintradar.dev/rules/oxc/no-rest-spread-properties.md): Disallow Object Rest/Spread Properties.
- [oxc/no-this-in-exported-function](https://lintradar.dev/rules/oxc/no-this-in-exported-function.md): Disallows the use of `this` in exported functions.
- [oxc/no-const-enum](https://lintradar.dev/rules/oxc/no-const-enum.md): Disallow TypeScript `const enum`
- [oxc/no-barrel-file](https://lintradar.dev/rules/oxc/no-barrel-file.md): Disallow the use of barrel files where the file contains `export *` statements, and the total number of modules exceeds a threshold.

---

Web page: https://lintradar.dev/rules/oxc/no-map-spread. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
