]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-dupe-args.md
import 8.41.0 source
[pve-eslint.git] / eslint / docs / src / rules / no-dupe-args.md
1 ---
2 title: no-dupe-args
3 rule_type: problem
4 ---
5
6
7
8 If more than one parameter has the same name in a function definition, the last occurrence "shadows" the preceding occurrences. A duplicated name might be a typing error.
9
10 ## Rule Details
11
12 This rule disallows duplicate parameter names in function declarations or expressions. It does not apply to arrow functions or class methods, because the parser reports the error.
13
14 If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.
15
16 Examples of **incorrect** code for this rule:
17
18 ::: incorrect
19
20 ```js
21 /*eslint no-dupe-args: "error"*/
22
23 function foo(a, b, a) {
24 console.log("value of the second a:", a);
25 }
26
27 var bar = function (a, b, a) {
28 console.log("value of the second a:", a);
29 };
30 ```
31
32 :::
33
34 Examples of **correct** code for this rule:
35
36 ::: correct
37
38 ```js
39 /*eslint no-dupe-args: "error"*/
40
41 function foo(a, b, c) {
42 console.log(a, b, c);
43 }
44
45 var bar = function (a, b, c) {
46 console.log(a, b, c);
47 };
48 ```
49
50 :::