noDuplicateParameters
此内容尚不支持你的语言。
Diagnostic Category: lint/suspicious/noDuplicateParameters
Since: v1.0.0
Sources:
- Same as:
no-dupe-args
Description
Section titled DescriptionDisallow 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 ExamplesInvalid
Section titled Invalidvar 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.
Valid
Section titled Validfunction 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" } } }}