Skip to main content

js/noDupeArgs

disallow duplicate arguments in function definitions

ESLint Equivalent: no-dupe-args

Examples

Invalid

function hello(a, a) {
	//
}

 file.js:1:18 lint/js/noDupeArgs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid duplicate function arguments. Check the a argument.

  > 1function hello(a, a) {
                       ^
    2  //
    3}


const hello = (a, a) => {
	//
}

 file.js:1:18 parse(js) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Argument a name clash in strict mode

  Defined already here

  > 1const hello = (a, a) => {
                       ^
    2  //
    3}


const hello = function (a, a) {
	//
}

 file.js:1:27 lint/js/noDupeArgs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid duplicate function arguments. Check the a argument.

  > 1const hello = function (a, a) {
                                ^
    2  //
    3}

Valid

function foo(foo) {
	console.log(foo)
}
const foo = 'test'
function bar(foo) {
	console.log(foo)
}