@@ -2,6 +2,7 @@ import _ from 'lodash';
2
2
import { parse as parseType , traverse } from 'jsdoctypeparser' ;
3
3
import iterateJsdoc , { parseComment } from '../iterateJsdoc' ;
4
4
import jsdocUtils from '../jsdocUtils' ;
5
+ import { getJSDocComment } from '../eslint/getJSDocComment' ;
5
6
6
7
const extraTypes = [
7
8
'null' , 'undefined' , 'void' , 'string' , 'boolean' , 'object' ,
@@ -17,11 +18,13 @@ const stripPseudoTypes = (str) => {
17
18
18
19
export default iterateJsdoc ( ( {
19
20
context,
21
+ node,
20
22
report,
21
23
settings,
22
- sourceCode : { scopeManager } ,
24
+ sourceCode,
23
25
utils,
24
26
} ) => {
27
+ const { scopeManager} = sourceCode ;
25
28
const { globalScope} = scopeManager ;
26
29
27
30
const { definedTypes = [ ] } = context . options [ 0 ] || { } ;
@@ -54,7 +57,9 @@ export default iterateJsdoc(({
54
57
. filter ( ( comment ) => {
55
58
return comment . value . startsWith ( '*' ) ;
56
59
} )
57
- . map ( parseComment )
60
+ . map ( ( commentNode ) => {
61
+ return parseComment ( commentNode , '' ) ;
62
+ } )
58
63
. flatMap ( ( doc ) => {
59
64
return ( doc . tags || [ ] ) . filter ( ( { tag} ) => {
60
65
return utils . isNamepathDefiningTag ( tag ) ;
@@ -65,7 +70,23 @@ export default iterateJsdoc(({
65
70
} )
66
71
. value ( ) ;
67
72
68
- let templateTags = utils . getPresentTags ( 'template' ) ;
73
+ const ancestorNodes = [ ] ;
74
+ let currentScope = scopeManager . acquire ( node ) ;
75
+ while ( currentScope && currentScope . block . type !== 'Program' ) {
76
+ ancestorNodes . push ( currentScope . block ) ;
77
+ currentScope = currentScope . upper ;
78
+ }
79
+
80
+ let templateTags = ancestorNodes . flatMap ( ( ancestorNode ) => {
81
+ const commentNode = getJSDocComment ( sourceCode , ancestorNode , settings ) ;
82
+
83
+ const jsdoc = parseComment ( commentNode , '' ) ;
84
+
85
+ return jsdocUtils . filterTags ( jsdoc . tags , ( tag ) => {
86
+ return 'template' === tag . tag ;
87
+ } ) ;
88
+ } ) ;
89
+
69
90
const classJsdoc = utils . getClassJsdoc ( ) ;
70
91
if ( classJsdoc ?. tags ) {
71
92
templateTags = templateTags . concat (
0 commit comments