Skip to main content

No Rest Params

Ban ...args rest parameters so function signatures list their parameters explicitly because rest parameters hide the expected arity.

Summary

The no-rest-params rule reports any rest element (...args) in a function parameter list, including regular functions, arrow functions, and class methods.

Spread syntax in function calls and array literals is not affected.

Why Use This Rule?

  1. Explicit parameters make the function signature self-documenting — callers see exactly what is expected.
  2. Rest parameters hide arity, making it unclear how many arguments are valid.
  3. Encourages passing arrays as a single typed parameter instead of variadic arguments.

Examples

Configuration

Options

warning

ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.

OptionTypeDefaultDescription
allowstring[][]Function or method names to exempt from the rule. Supports exact match ('Logger.info'), wildcard ('Logger.*'), and standalone function names ('log').
ignoreFilesstring[][]File patterns to skip.

Autofix

Autofix is not available for this rule. Flagged code must be updated manually.

Troubleshooting

  • Spread in function calls is not flagged — The rule only targets rest parameters in function definitions, not spread syntax in calls like Math.max(...values).
  • Wrapper around a variadic API — If wrapping a third-party function that requires variadic arguments, accept an array parameter and spread it at the call site.