> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-rest-params

[Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strict                 | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |
| ✅ ts.configs.stylistic              | `"error"`        |
| ✅ ts.configs.stylisticTypeChecked   | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'prefer-rest-params': 'error',
    },
  },
]);
```

## Rule Details

Requires rest parameters instead of `arguments`.

There are rest parameters in ES2015. We can use that feature for variadic functions instead of the `arguments` variable. `arguments` does not have methods of `Array.prototype`, so it's a bit inconvenient.

Examples of **incorrect** code for this rule:

```javascript
function foo() {
  console.log(arguments);
}

function foo(action) {
  var args = Array.prototype.slice.call(arguments, 1);
  action.apply(null, args);
}

function foo(action) {
  var args = [].slice.call(arguments, 1);
  action.apply(null, args);
}
```

Examples of **correct** code for this rule:

```javascript
function foo(...args) {
  console.log(args);
}

function foo(action, ...args) {
  action.apply(null, args);
}

// This is not a use of `arguments` itself
function foo() {
  arguments.length;
  arguments.callee;
}
```

## Original Documentation

- [ESLint: prefer-rest-params](https://eslint.org/docs/latest/rules/prefer-rest-params)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-rest-params.js)
