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

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## 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
}]
```

{/* End of the generated section. */}

## Examples

Reported:

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

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

Not reported:

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

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

{/* good */}
```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`. |

{/* bad {"options": [{"objectSpreadMessage": "Use Object.assign(), we ship ES2017."}]} */}
```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.
