File tree Expand file tree Collapse file tree 3 files changed +107
-1
lines changed Expand file tree Collapse file tree 3 files changed +107
-1
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,24 @@ function foo () {
283
283
const a = new Todo ();
284
284
// Settings: {"jsdoc":{"mode":"jsdoc"}}
285
285
// Message: The type 'Omit' is undefined.
286
+
287
+ /**
288
+ * Message with {@link NotKnown }
289
+ */
290
+ // Message: The type 'NotKnown' is undefined.
291
+
292
+ /**
293
+ * Message with
294
+ * a link that is {@link NotKnown }
295
+ */
296
+ // Message: The type 'NotKnown' is undefined.
297
+
298
+ /**
299
+ * @abc
300
+ * @someTag Message with
301
+ * a link that is {@link NotKnown }
302
+ */
303
+ // Message: The type 'NotKnown' is undefined.
286
304
````
287
305
288
306
Original file line number Diff line number Diff line change @@ -533,8 +533,54 @@ const hasTag = (jsdoc, targetTagName) => {
533
533
const getAllTags = ( jsdoc , includeInlineTags ) => {
534
534
return includeInlineTags ? [
535
535
...jsdoc . tags ,
536
- ...jsdoc . inlineTags ,
536
+ ...jsdoc . inlineTags . map ( ( inlineTag ) => {
537
+ // Tags don't have source or line numbers, so add before returning
538
+ let line = - 1 ;
539
+ for ( const {
540
+ tokens : {
541
+ description,
542
+ } ,
543
+ } of jsdoc . source ) {
544
+ line ++ ;
545
+ if ( description && description . includes ( `{@${ inlineTag . tag } ` ) ) {
546
+ break ;
547
+ }
548
+ }
549
+
550
+ inlineTag . line = line ;
551
+
552
+ return inlineTag ;
553
+ } ) ,
537
554
...jsdoc . tags . flatMap ( ( tag ) => {
555
+ let tagBegins = - 1 ;
556
+ for ( const {
557
+ tokens : {
558
+ tag : tg ,
559
+ } ,
560
+ } of jsdoc . source ) {
561
+ tagBegins ++ ;
562
+ if ( tg ) {
563
+ break ;
564
+ }
565
+ }
566
+
567
+ for ( const inlineTag of tag . inlineTags ) {
568
+ let line ;
569
+ for ( const {
570
+ number,
571
+ tokens : {
572
+ description,
573
+ } ,
574
+ } of tag . source ) {
575
+ if ( description && description . includes ( `{@${ inlineTag . tag } ` ) ) {
576
+ line = number ;
577
+ break ;
578
+ }
579
+ }
580
+
581
+ inlineTag . line = tagBegins + line - 1 ;
582
+ }
583
+
538
584
return (
539
585
/**
540
586
* @type {import('comment-parser').Spec & {
Original file line number Diff line number Diff line change @@ -490,6 +490,48 @@ export default {
490
490
} ,
491
491
} ,
492
492
} ,
493
+ {
494
+ code : `
495
+ /**
496
+ * Message with {@link NotKnown}
497
+ */
498
+ ` ,
499
+ errors : [
500
+ {
501
+ line : 3 ,
502
+ message : 'The type \'NotKnown\' is undefined.' ,
503
+ } ,
504
+ ] ,
505
+ } ,
506
+ {
507
+ code : `
508
+ /**
509
+ * Message with
510
+ * a link that is {@link NotKnown}
511
+ */
512
+ ` ,
513
+ errors : [
514
+ {
515
+ line : 4 ,
516
+ message : 'The type \'NotKnown\' is undefined.' ,
517
+ } ,
518
+ ] ,
519
+ } ,
520
+ {
521
+ code : `
522
+ /**
523
+ * @abc
524
+ * @someTag Message with
525
+ * a link that is {@link NotKnown}
526
+ */
527
+ ` ,
528
+ errors : [
529
+ {
530
+ line : 5 ,
531
+ message : 'The type \'NotKnown\' is undefined.' ,
532
+ } ,
533
+ ] ,
534
+ } ,
493
535
] ,
494
536
valid : [
495
537
{
You can’t perform that action at this time.
0 commit comments