prefer-rest-params
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"prefer-rest-params": "error",
},
},
];function foo() {
console.log(arguments);
}
function foo(action) {
const args = Array.prototype.slice.call(arguments, 1);
action.apply(null, args);
}
function foo(action) {
const args = [].slice.call(arguments, 1);
action.apply(null, args);
}function foo(...args) {
console.log(args);
}
function foo(action, ...args) {
action.apply(null, args); // or `action(...args)`, related to the `prefer-spread` rule.
}
// Note: the implicit arguments can be overwritten.
function foo(arguments) {
console.log(arguments); // This is the first argument.
}
function foo() {
const arguments = 0;
console.log(arguments); // This is a local variable.
}Examples from the ESLint documentation.
prefer-rest-params
eslint
export default [
{
rules: {
"prefer-rest-params": "error",
},
},
];prefer-rest-params
eslint plugin · style
{
"rules": {
"prefer-rest-params": "error"
}
}complexity/noArguments
complexity · since 1.0.0
{
"linter": {
"rules": {
"complexity": {
"noArguments": "error"
}
}
}
}Disallow variable assignments when the value is not used
Require const declarations for variables that are never reassigned after declared
Disallow calling some Object.prototype methods directly on objects
Disallow lexical declarations in case clauses
Disallow duplicate arguments in function definitions