arguments
Reports using the arguments object instead of rest parameters.
✅ This rule is included in the ts logical presets.
The arguments object is an array-like object available in non-arrow functions that contains the values of the arguments passed to the function.
However, it lacks Array methods like map, filter, and forEach, making it inconvenient to work with.
Rest parameters provide a real Array, which is more versatile and easier to use.
Examples
Section titled “Examples”function sum() { let total = 0; for (let i = 0; i < arguments.length; i++) { total += arguments[i]; } return total;}
function logAll() { console.log(arguments);}function sum(...values: number[]) { return values.reduce((total, value) => total + value, 0);}
function logAll(...items: unknown[]) { console.log(items);}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you need to support environments that don’t have rest parameter syntax, such as ES5 or earlier, you may need to disable this rule. However, most modern JavaScript environments support rest parameters.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noArguments - ESLint:
prefer-rest-params - Oxlint:
eslint/prefer-rest-params
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.