diff --git a/README.md b/README.md index f2f88bd03..4da7531c1 100644 --- a/README.md +++ b/README.md @@ -3280,6 +3280,12 @@ function quux (foo) { } // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}] // Message: Duplicate @param "foo" + +/** + * @param barr This is the description of bar. Oops, we misspelled "bar" as "barr". + */ +declare function foo(bar: number) {} +// Message: Expected @param names to be "bar". Got "barr". ```` The following patterns are not considered problems: diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index ef00d5d41..23a921023 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -1353,6 +1353,7 @@ export default function iterateJsdoc (iterator, ruleConfig) { 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', + 'TSDeclareFunction', ]) { contextObject[prop] = checkJsdoc.bind(null, { selector: prop, diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index ba9e5aec2..3c0daa026 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -973,6 +973,7 @@ const enforcedContexts = (context, defaultContexts) => { 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', + 'TSDeclareFunction', ] : defaultContexts, } = context.options[0] || {}; diff --git a/test/rules/assertions/checkParamNames.js b/test/rules/assertions/checkParamNames.js index 0a6bc80e6..d4ddc7deb 100644 --- a/test/rules/assertions/checkParamNames.js +++ b/test/rules/assertions/checkParamNames.js @@ -1162,6 +1162,21 @@ export default { } `, }, + { + code: ` + /** + * @param barr This is the description of bar. Oops, we misspelled "bar" as "barr". + */ + declare function foo(bar: number) {} + `, + errors: [ + { + line: 3, + message: 'Expected @param names to be "bar". Got "barr".', + }, + ], + parser: require.resolve('@typescript-eslint/parser'), + }, ], valid: [ {