noDuplicateParameters
Summary
Section titled “Summary”- Rule available since:
v1.0.0
- Diagnostic Category:
lint/suspicious/noDuplicateParameters
- This rule is recommended, which means is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Same as
no-dupe-args
- Same as
Description
Section titled “Description”Disallow duplicate function parameter name.
If more than one parameter has the same name in a function definition, the last occurrence overrides the preceding occurrences. A duplicated name might be a typing error.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”var f = function(a, b, b) {}
code-block.js:1:24 lint/suspicious/noDuplicateParameters ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate parameter name.
> 1 │ var f = function(a, b, b) {}
│ ^
2 │
ℹ The parameter overrides a preceding parameter by using the same name.
function b(a, b, b) {}
code-block.js:1:18 lint/suspicious/noDuplicateParameters ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate parameter name.
> 1 │ function b(a, b, b) {}
│ ^
2 │
ℹ The parameter overrides a preceding parameter by using the same name.
function i(i, b, c) {}var j = function (j, b, c) {};function k({ k, b }, { c, d }) {}function l([, l]) {}function foo([[a, b], [c, d]]) {}
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noDuplicateParameters": "error" } } }}