@@ -367,4 +367,100 @@ describe('lib/rules/validate-jsdoc/check-param-names', function() {
367
367
368
368
} ) ;
369
369
370
+ describe ( 'with destructurings' , function ( ) {
371
+ var checker = global . checker ( {
372
+ plugins : [ './lib/index' ] ,
373
+ esnext : true
374
+ } ) ;
375
+ checker . rules ( { checkParamNames : true } ) ;
376
+
377
+ checker . cases ( [
378
+ /* jshint ignore:start */
379
+ // jscs:disable
380
+ {
381
+ it : 'should not report missing parameter name for object destructurings' ,
382
+ code : [
383
+ '/**' ,
384
+ ' * @param {object}' ,
385
+ ' */' ,
386
+ 'function obj({param}) {' ,
387
+ '}'
388
+ ] . join ( '\n' )
389
+ } , {
390
+ it : 'should not report missing parameter name for object destructurings' ,
391
+ code : [
392
+ '/**' ,
393
+ ' * @param {object}' ,
394
+ ' */' ,
395
+ 'function obj({param: newName}) {' ,
396
+ '}'
397
+ ] . join ( '\n' )
398
+ } , {
399
+ it : 'should not fail if a fake parameter name is provided' ,
400
+ code : [
401
+ '/**' ,
402
+ ' * @param {object} fakeName - description' ,
403
+ ' */' ,
404
+ 'function obj({param}) {' ,
405
+ '}'
406
+ ] . join ( '\n' )
407
+ } , {
408
+ it : 'should not fail if a fake parameter name and property description is provided' ,
409
+ code : [
410
+ '/**' ,
411
+ ' * @param {object} fakeName - description' ,
412
+ ' * @param {object} fakeName.param - description' ,
413
+ ' */' ,
414
+ 'function obj({param}) {' ,
415
+ '}'
416
+ ] . join ( '\n' )
417
+ } , {
418
+ it : 'should report different fake parameter name' ,
419
+ code : [
420
+ '/**' ,
421
+ ' * @param {object} fakeName - description' ,
422
+ ' * @param {object} notFakeName.param - description' ,
423
+ ' */' ,
424
+ 'function obj({param}) {' ,
425
+ '}'
426
+ ] . join ( '\n' ) ,
427
+ errors : [
428
+ {
429
+ column : 19 ,
430
+ filename : 'input' ,
431
+ line : 3 ,
432
+ message : 'Expected `fakeName` but got `notFakeName`' ,
433
+ rule : 'jsDoc' ,
434
+ fixed : undefined
435
+ }
436
+ ]
437
+ } , {
438
+ it : 'should not report an error when used next to parameters with properties' ,
439
+ code : [
440
+ '/**' ,
441
+ ' * @param {object} obj1' ,
442
+ ' * @param {string} obj1.property' ,
443
+ ' * @param {object}' ,
444
+ ' * @param {object} obj2' ,
445
+ ' * @param {string} obj2.property' ,
446
+ ' */' ,
447
+ 'function obj(obj1, {param}, obj2) {' ,
448
+ '}'
449
+ ] . join ( '\n' )
450
+ } , {
451
+ it : 'should not report missing parameter name for array destructurings' ,
452
+ code : [
453
+ '/**' ,
454
+ ' * @param {array}' ,
455
+ ' */' ,
456
+ 'function arr([param]) {' ,
457
+ '}'
458
+ ] . join ( '\n' )
459
+ }
460
+ // jscs:enable
461
+ /* jshint ignore:end */
462
+ ] ) ;
463
+
464
+ } ) ;
465
+
370
466
} ) ;
0 commit comments