@@ -354,11 +354,18 @@ const validateParameterNamesDeep = (
354354 } ) ;
355355} ;
356356
357+ const allowedNodes = [
358+ 'ArrowFunctionExpression' , 'FunctionDeclaration' , 'FunctionExpression' , 'TSDeclareFunction' ,
359+ // Add this to above defaults
360+ 'TSMethodSignature'
361+ ] ;
362+
357363export default iterateJsdoc ( ( {
358364 context,
359365 jsdoc,
360366 report,
361367 utils,
368+ node,
362369} ) => {
363370 const {
364371 allowExtraTrailingParamDocs,
@@ -371,6 +378,15 @@ export default iterateJsdoc(({
371378 disableMissingParamChecks = false ,
372379 } = context . options [ 0 ] || { } ;
373380
381+ // Although we might just remove global settings contexts from applying to
382+ // this rule (as they can cause problems with `getFunctionParameterNames`
383+ // checks if they are not functions but say variables), the user may
384+ // instead wish to narrow contexts in those settings, so this check
385+ // is still useful
386+ if ( ! allowedNodes . includes ( /** @type {import('estree').Node } */ ( node ) . type ) ) {
387+ return ;
388+ }
389+
374390 const checkTypesRegex = utils . getRegexFromString ( checkTypesPattern ) ;
375391
376392 const jsdocParameterNamesDeep = utils . getJsdocTagsDeep ( 'param' ) ;
@@ -406,11 +422,7 @@ export default iterateJsdoc(({
406422 targetTagName , allowExtraTrailingParamDocs , jsdocParameterNamesDeep , jsdoc , report ,
407423 ) ;
408424} , {
409- contextDefaults : [
410- 'ArrowFunctionExpression' , 'FunctionDeclaration' , 'FunctionExpression' , 'TSDeclareFunction' ,
411- // Add this to above defaults
412- 'TSMethodSignature'
413- ] ,
425+ contextDefaults : allowedNodes ,
414426 meta : {
415427 docs : {
416428 description : 'Ensures that parameter names in JSDoc match those in the function declaration.' ,
0 commit comments