# oxc/no-rest-spread-properties

> Disallow `...` in object literals and object destructuring

Engines older than ES2018 can't parse `{ ...user }` or `const { id, ...rest } = user`, so a file that uses them fails to load there. If a compiler lowers them for a target like that, it adds helper code to the output.

Only objects are checked. `...` is allowed in arrays, call arguments, rest parameters such as `(...args)`, and JSX attributes.

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"oxc/no-rest-spread-properties" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"oxc/no-rest-spread-properties" = ["error", {
  objectSpreadMessage = "", # string
  objectRestMessage = "", # string
}]
```

## Examples

Reported:

```js
const updated = { ...user, name: "Ada" };
```

```js
const { password, ...profile } = user;
```

Not reported:

```js
const updated = Object.assign({}, user, { name: "Ada" });

const profile = { id: user.id, name: user.name };
```

```jsx
const all = [...admins, ...members];

function log(...messages) {
  console.log(...messages);
}

const row = <Row {...props} />;
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `objectSpreadMessage` | `""` | Text to add to the message for a spread, such as `{ ...user }`. |
| `objectRestMessage` | `""` | Text to add to the message for a rest property, such as `{ id, ...rest } = user`. |

```js
const updated = { ...user, name: "Ada" };
```

## When not to use it

Every current browser and runtime supports both. Only use this rule if your code has to run on older ones.
