Skip to content

oxc/no-rest-spread-properties Restriction

What it does

Disallow Object Rest/Spread Properties.

Why is this bad?

Object rest/spread properties are a relatively new JavaScript feature that may not be supported in all target environments. If you need to support older browsers or JavaScript engines that don't support these features, using them can cause runtime errors. This rule helps maintain compatibility with older environments by preventing the use of these modern syntax features.

Examples

Examples of incorrect code for this rule:

javascript
let { x, ...y } = z;
let z = { x, ...y };

Options

json
{
  "rules": {
    "no-rest-spread-properties": [
      "error",
      {
        "objectSpreadMessage": "Object spread properties are not allowed.",
        "objectRestMessage": "Object rest properties are not allowed."
      }
    ]
  }
}
  • objectSpreadMessage: A message to display when object spread properties are found.
  • objectRestMessage: A message to display when object rest properties are found.

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny oxc/no-rest-spread-properties
json
{
  "rules": {
    "oxc/no-rest-spread-properties": "error"
  }
}

References

Released under the MIT License.