@@ -354,11 +354,18 @@ const validateParameterNamesDeep = (
354
354
} ) ;
355
355
} ;
356
356
357
+ const allowedNodes = [
358
+ 'ArrowFunctionExpression' , 'FunctionDeclaration' , 'FunctionExpression' , 'TSDeclareFunction' ,
359
+ // Add this to above defaults
360
+ 'TSMethodSignature'
361
+ ] ;
362
+
357
363
export default iterateJsdoc ( ( {
358
364
context,
359
365
jsdoc,
360
366
report,
361
367
utils,
368
+ node,
362
369
} ) => {
363
370
const {
364
371
allowExtraTrailingParamDocs,
@@ -371,6 +378,15 @@ export default iterateJsdoc(({
371
378
disableMissingParamChecks = false ,
372
379
} = context . options [ 0 ] || { } ;
373
380
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
+
374
390
const checkTypesRegex = utils . getRegexFromString ( checkTypesPattern ) ;
375
391
376
392
const jsdocParameterNamesDeep = utils . getJsdocTagsDeep ( 'param' ) ;
@@ -406,11 +422,7 @@ export default iterateJsdoc(({
406
422
targetTagName , allowExtraTrailingParamDocs , jsdocParameterNamesDeep , jsdoc , report ,
407
423
) ;
408
424
} , {
409
- contextDefaults : [
410
- 'ArrowFunctionExpression' , 'FunctionDeclaration' , 'FunctionExpression' , 'TSDeclareFunction' ,
411
- // Add this to above defaults
412
- 'TSMethodSignature'
413
- ] ,
425
+ contextDefaults : allowedNodes ,
414
426
meta : {
415
427
docs : {
416
428
description : 'Ensures that parameter names in JSDoc match those in the function declaration.' ,
0 commit comments