Skip to content

Commit 49400e1

Browse files
committed
feat(check-param-names): check TSMethodSignature (as on interface methods); fixes #1249
1 parent 1aa3313 commit 49400e1

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

docs/rules/check-param-names.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,14 @@ function quux (foo) {
657657
}
658658
// "jsdoc/check-param-names": ["error"|"warn", {"disableMissingParamChecks":true}]
659659
// Message: @param "bar" does not match an existing function parameter.
660+
661+
export interface B {
662+
/**
663+
* @param paramA Something something
664+
*/
665+
methodB(paramB: string): void
666+
};
667+
// Message: Expected @param names to be "paramB". Got "paramA".
660668
````
661669

662670

src/rules/checkParamNames.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ export default iterateJsdoc(({
378378
targetTagName, allowExtraTrailingParamDocs, jsdocParameterNamesDeep, jsdoc, report,
379379
);
380380
}, {
381+
contextDefaults: [
382+
'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
383+
// Add this to above defaults
384+
'TSMethodSignature'
385+
],
381386
meta: {
382387
docs: {
383388
description: 'Ensures that parameter names in JSDoc match those in the function declaration.',

test/rules/assertions/checkParamNames.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,26 @@ export default {
12571257
},
12581258
],
12591259
},
1260+
{
1261+
code: `
1262+
export interface B {
1263+
/**
1264+
* @param paramA Something something
1265+
*/
1266+
methodB(paramB: string): void
1267+
};
1268+
`,
1269+
errors: [
1270+
{
1271+
line: 4,
1272+
message: 'Expected @param names to be "paramB". Got "paramA".',
1273+
},
1274+
],
1275+
languageOptions: {
1276+
parser: typescriptEslintParser,
1277+
sourceType: 'module',
1278+
},
1279+
}
12601280
],
12611281
valid: [
12621282
{

0 commit comments

Comments
 (0)