eslint-plugin-jsdoc 48.8.2 → 48.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rules/checkTemplateNames.cjs +28 -15
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +33 -16
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/package.json +1 -1
- package/src/rules/checkTemplateNames.js +32 -19
- package/src/rules/requireTemplate.js +38 -20
|
@@ -71,23 +71,36 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
71
71
|
handleTypeAliases();
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
type,
|
|
85
|
-
value
|
|
86
|
-
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
87
|
-
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
88
|
-
usedNames.add(value);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {string} potentialType
|
|
77
|
+
*/
|
|
78
|
+
const checkForUsedTypes = potentialType => {
|
|
79
|
+
let parsedType;
|
|
80
|
+
try {
|
|
81
|
+
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode);
|
|
82
|
+
} catch {
|
|
83
|
+
return;
|
|
89
84
|
}
|
|
85
|
+
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
86
|
+
const {
|
|
87
|
+
type,
|
|
88
|
+
value
|
|
89
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
90
|
+
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
91
|
+
usedNames.add(value);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const potentialTypedefType = typedefTags[0].type;
|
|
96
|
+
checkForUsedTypes(potentialTypedefType);
|
|
97
|
+
const tagName = /** @type {string} */utils.getPreferredTagName({
|
|
98
|
+
tagName: 'property'
|
|
90
99
|
});
|
|
100
|
+
const propertyTags = utils.getTags(tagName);
|
|
101
|
+
for (const propertyTag of propertyTags) {
|
|
102
|
+
checkForUsedTypes(propertyTag.type);
|
|
103
|
+
}
|
|
91
104
|
for (const tag of templateTags) {
|
|
92
105
|
const {
|
|
93
106
|
name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTemplateNames.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","mode","templateTags","getTags","usedNames","Set","checkParameters","aliasDeclaration","params","typeParameters","name","add","tag","names","split","has","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","length","potentialType","parsedType","tryParseType","parseType","traverse","value","test","iterateAllJsdocs","meta","docs","description","url","schema","module"],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n mode\n } = settings;\n\n const templateTags = utils.getTags('template');\n\n const usedNames = new Set();\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n
|
|
1
|
+
{"version":3,"file":"checkTemplateNames.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","mode","templateTags","getTags","usedNames","Set","checkParameters","aliasDeclaration","params","typeParameters","name","add","tag","names","split","has","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","length","checkForUsedTypes","potentialType","parsedType","tryParseType","parseType","traverse","value","test","potentialTypedefType","tagName","getPreferredTagName","propertyTags","propertyTag","iterateAllJsdocs","meta","docs","description","url","schema","module"],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n mode\n } = settings;\n\n const templateTags = utils.getTags('template');\n\n const usedNames = new Set();\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n /**\n * @param {string} potentialType\n */\n const checkForUsedTypes = (potentialType) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {\n usedNames.add(value);\n }\n });\n };\n\n const potentialTypedefType = typedefTags[0].type;\n checkForUsedTypes(potentialTypedefType);\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const propertyTags = utils.getTags(tagName);\n for (const propertyTag of propertyTags) {\n checkForUsedTypes(propertyTag.type);\n }\n\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that any `@template` names are actually used in the connected `@typedef` or type alias.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8C,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAA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AMG,WAAW,IAAID,YAAY,EAAE;IACtCX,iBAAiB,CAACY,WAAW,CAAChB,IAAI,CAAC;EACrC;EAEA,KAAK,MAAMP,GAAG,IAAIV,YAAY,EAAE;IAC9B,MAAM;MAACQ;IAAI,CAAC,GAAGE,GAAG;IAClB,MAAMC,KAAK,GAAGH,IAAI,CAACI,KAAK,CAAC,MAAM,CAAC;IAChC,KAAK,MAAMJ,IAAI,IAAIG,KAAK,EAAE;MACxB,IAAI,CAACT,SAAS,CAACW,GAAG,CAACL,IAAI,CAAC,EAAE;QACxBV,MAAM,CAAC,aAAaU,IAAI,aAAa,EAAE,IAAI,EAAEE,GAAG,CAAC;MACnD;IACF;EACF;AACF,CAAC,EAAE;EACDwB,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,gGAAgG;MAC7GC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,EAAE;IACVtB,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAuB,MAAA,CAAAhD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -83,28 +83,45 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
83
83
|
handleTypeAliases();
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
value
|
|
98
|
-
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
99
|
-
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
100
|
-
usedNames.add(value);
|
|
86
|
+
const usedNameToTag = new Map();
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {import('comment-parser').Spec} potentialTag
|
|
90
|
+
*/
|
|
91
|
+
const checkForUsedTypes = potentialTag => {
|
|
92
|
+
let parsedType;
|
|
93
|
+
try {
|
|
94
|
+
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialTag.type) : (0, _jsdoccomment.parse)( /** @type {string} */potentialTag.type, mode);
|
|
95
|
+
} catch {
|
|
96
|
+
return;
|
|
101
97
|
}
|
|
98
|
+
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
99
|
+
const {
|
|
100
|
+
type,
|
|
101
|
+
value
|
|
102
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
103
|
+
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
104
|
+
usedNames.add(value);
|
|
105
|
+
if (!usedNameToTag.has(value)) {
|
|
106
|
+
usedNameToTag.set(value, potentialTag);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const potentialTypedef = typedefTags[0];
|
|
112
|
+
checkForUsedTypes(potentialTypedef);
|
|
113
|
+
const tagName = /** @type {string} */utils.getPreferredTagName({
|
|
114
|
+
tagName: 'property'
|
|
102
115
|
});
|
|
116
|
+
const propertyTags = utils.getTags(tagName);
|
|
117
|
+
for (const propertyTag of propertyTags) {
|
|
118
|
+
checkForUsedTypes(propertyTag);
|
|
119
|
+
}
|
|
103
120
|
|
|
104
121
|
// Could check against whitelist/blacklist
|
|
105
122
|
for (const usedName of usedNames) {
|
|
106
123
|
if (!templateNames.includes(usedName)) {
|
|
107
|
-
report(`Missing @template ${usedName}`, null,
|
|
124
|
+
report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));
|
|
108
125
|
}
|
|
109
126
|
}
|
|
110
127
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireTemplate.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","name","split","tag","names","length","checkParameters","aliasDeclaration","params","typeParameters","add","usedName","includes","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","
|
|
1
|
+
{"version":3,"file":"requireTemplate.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","name","split","tag","names","length","checkParameters","aliasDeclaration","params","typeParameters","add","usedName","includes","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","usedNameToTag","Map","checkForUsedTypes","potentialTag","parsedType","tryParseType","parseType","traverse","value","test","has","set","potentialTypedef","tagName","getPreferredTagName","propertyTags","propertyTag","get","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode\n } = settings;\n\n const usedNames = new Set();\n const templateTags = utils.getTags('template');\n const templateNames = templateTags.flatMap(({name}) => {\n return name.split(/,\\s*/);\n });\n\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n if (requireSeparateTemplates && names.length > 1) {\n report(`Missing separate @template for ${names[1]}`, null, tag);\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`);\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const usedNameToTag = new Map();\n\n /**\n * @param {import('comment-parser').Spec} potentialTag\n */\n const checkForUsedTypes = (potentialTag) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialTag.type)) :\n parseType(/** @type {string} */ (potentialTag.type), mode)\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {\n usedNames.add(value);\n if (!usedNameToTag.has(value)) {\n usedNameToTag.set(value, potentialTag);\n }\n }\n });\n };\n\n const potentialTypedef = typedefTags[0];\n checkForUsedTypes(potentialTypedef);\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const propertyTags = utils.getTags(tagName);\n for (const propertyTag of propertyTags) {\n checkForUsedTypes(propertyTag);\n }\n\n // Could check against whitelist/blacklist\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires template tags for each generic type parameter',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n requireSeparateTemplates: {\n type: 'boolean'\n }\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\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KAAK;MAC3BC,UAAU,EAAE;QACVpD,wBAAwB,EAAE;UACxBwB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA6B,MAAA,CAAA5D,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -64,27 +64,40 @@ export default iterateJsdoc(({
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @param {string} potentialType
|
|
69
|
+
*/
|
|
70
|
+
const checkForUsedTypes = (potentialType) => {
|
|
71
|
+
let parsedType;
|
|
72
|
+
try {
|
|
73
|
+
parsedType = mode === 'permissive' ?
|
|
74
|
+
tryParseType(/** @type {string} */ (potentialType)) :
|
|
75
|
+
parseType(/** @type {string} */ (potentialType), mode);
|
|
76
|
+
} catch {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
traverse(parsedType, (nde) => {
|
|
81
|
+
const {
|
|
82
|
+
type,
|
|
83
|
+
value,
|
|
84
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
85
|
+
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
86
|
+
usedNames.add(value);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
const potentialTypedefType = typedefTags[0].type;
|
|
92
|
+
checkForUsedTypes(potentialTypedefType);
|
|
93
|
+
|
|
94
|
+
const tagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
95
|
+
tagName: 'property',
|
|
96
|
+
}));
|
|
97
|
+
const propertyTags = utils.getTags(tagName);
|
|
98
|
+
for (const propertyTag of propertyTags) {
|
|
99
|
+
checkForUsedTypes(propertyTag.type);
|
|
100
|
+
}
|
|
88
101
|
|
|
89
102
|
for (const tag of templateTags) {
|
|
90
103
|
const {name} = tag;
|
|
@@ -75,32 +75,50 @@ export default iterateJsdoc(({
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const
|
|
78
|
+
const usedNameToTag = new Map();
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const {
|
|
92
|
-
type,
|
|
93
|
-
value,
|
|
94
|
-
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
95
|
-
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
96
|
-
usedNames.add(value);
|
|
80
|
+
/**
|
|
81
|
+
* @param {import('comment-parser').Spec} potentialTag
|
|
82
|
+
*/
|
|
83
|
+
const checkForUsedTypes = (potentialTag) => {
|
|
84
|
+
let parsedType;
|
|
85
|
+
try {
|
|
86
|
+
parsedType = mode === 'permissive' ?
|
|
87
|
+
tryParseType(/** @type {string} */ (potentialTag.type)) :
|
|
88
|
+
parseType(/** @type {string} */ (potentialTag.type), mode)
|
|
89
|
+
} catch {
|
|
90
|
+
return;
|
|
97
91
|
}
|
|
98
|
-
|
|
92
|
+
|
|
93
|
+
traverse(parsedType, (nde) => {
|
|
94
|
+
const {
|
|
95
|
+
type,
|
|
96
|
+
value,
|
|
97
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
98
|
+
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
99
|
+
usedNames.add(value);
|
|
100
|
+
if (!usedNameToTag.has(value)) {
|
|
101
|
+
usedNameToTag.set(value, potentialTag);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const potentialTypedef = typedefTags[0];
|
|
108
|
+
checkForUsedTypes(potentialTypedef);
|
|
109
|
+
|
|
110
|
+
const tagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
111
|
+
tagName: 'property',
|
|
112
|
+
}));
|
|
113
|
+
const propertyTags = utils.getTags(tagName);
|
|
114
|
+
for (const propertyTag of propertyTags) {
|
|
115
|
+
checkForUsedTypes(propertyTag);
|
|
116
|
+
}
|
|
99
117
|
|
|
100
118
|
// Could check against whitelist/blacklist
|
|
101
119
|
for (const usedName of usedNames) {
|
|
102
120
|
if (!templateNames.includes(usedName)) {
|
|
103
|
-
report(`Missing @template ${usedName}`, null,
|
|
121
|
+
report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));
|
|
104
122
|
}
|
|
105
123
|
}
|
|
106
124
|
}, {
|