Skip to content

Commit 716d396

Browse files
committed
- Report duplicate param names as such
1 parent c47ede3 commit 716d396

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/rules/checkParamNames.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ const validateParameterNames = (targetTagName : string, functionParameterNames :
1010
});
1111

1212
return paramTags.some((tag, index) => {
13+
if (paramTags.some((tg, idx) => {
14+
return tg.name === tag.name && idx !== index;
15+
})) {
16+
report('Duplicate @' + targetTagName + ' "' + tag.name + '"');
17+
18+
return true;
19+
}
1320
const functionParameterName = functionParameterNames[index];
1421

1522
if (!functionParameterName) {

test/rules/assertions/checkParamNames.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,54 @@ export default {
117117
message: '@param "bar" does not match an existing function parameter.'
118118
}
119119
]
120+
},
121+
{
122+
code: `
123+
/**
124+
* @param foo
125+
* @param foo
126+
*/
127+
function quux (foo) {
128+
129+
}
130+
`,
131+
errors: [
132+
{
133+
message: 'Duplicate @param "foo"'
134+
}
135+
]
136+
},
137+
{
138+
code: `
139+
/**
140+
* @param foo
141+
* @param foo
142+
*/
143+
function quux (foo, bar) {
144+
145+
}
146+
`,
147+
errors: [
148+
{
149+
message: 'Duplicate @param "foo"'
150+
}
151+
]
152+
},
153+
{
154+
code: `
155+
/**
156+
* @param foo
157+
* @param foo
158+
*/
159+
function quux (foo, foo) {
160+
161+
}
162+
`,
163+
errors: [
164+
{
165+
message: 'Duplicate @param "foo"'
166+
}
167+
]
120168
}
121169
],
122170
valid: [

0 commit comments

Comments
 (0)