eslint-plugin-jsdoc 48.9.3 → 48.10.0
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 +15 -3
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +28 -8
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/package.json +1 -1
- package/src/rules/checkTemplateNames.js +15 -3
- package/src/rules/requireTemplate.js +27 -7
|
@@ -20,7 +20,10 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
20
20
|
const templateTags = utils.getTags('template');
|
|
21
21
|
const usedNames = new Set();
|
|
22
22
|
/**
|
|
23
|
-
* @param {import('@typescript-eslint/types').TSESTree.
|
|
23
|
+
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
24
|
+
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
25
|
+
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
26
|
+
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
24
27
|
*/
|
|
25
28
|
const checkParameters = aliasDeclaration => {
|
|
26
29
|
/* c8 ignore next -- Guard */
|
|
@@ -56,12 +59,21 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
switch (nde.type) {
|
|
62
|
+
case 'ExportDefaultDeclaration':
|
|
59
63
|
case 'ExportNamedDeclaration':
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
switch ((_nde$declaration = nde.declaration) === null || _nde$declaration === void 0 ? void 0 : _nde$declaration.type) {
|
|
65
|
+
case 'ClassDeclaration':
|
|
66
|
+
case 'FunctionDeclaration':
|
|
67
|
+
case 'TSTypeAliasDeclaration':
|
|
68
|
+
case 'TSInterfaceDeclaration':
|
|
69
|
+
checkParameters(nde.declaration);
|
|
70
|
+
break;
|
|
62
71
|
}
|
|
63
72
|
break;
|
|
73
|
+
case 'ClassDeclaration':
|
|
74
|
+
case 'FunctionDeclaration':
|
|
64
75
|
case 'TSTypeAliasDeclaration':
|
|
76
|
+
case 'TSInterfaceDeclaration':
|
|
65
77
|
checkParameters(nde);
|
|
66
78
|
break;
|
|
67
79
|
}
|
|
@@ -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","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
|
|
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.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * 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 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSInterfaceDeclaration':\n checkParameters(nde.declaration);\n break;\n }\n break;\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSInterfaceDeclaration':\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,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAA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AAmB,CAAC;IAC/DD,OAAO,EAAE;EACX,CAAC,CAAE;EACH,MAAME,YAAY,GAAGrC,KAAK,CAACM,OAAO,CAAC6B,OAAO,CAAC;EAC3C,KAAK,MAAMG,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":[]}
|
|
@@ -38,9 +38,12 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* @param {import('@typescript-eslint/types').TSESTree.
|
|
41
|
+
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
42
|
+
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
43
|
+
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
44
|
+
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
42
45
|
*/
|
|
43
|
-
const
|
|
46
|
+
const checkTypeParams = aliasDeclaration => {
|
|
44
47
|
/* c8 ignore next -- Guard */
|
|
45
48
|
const {
|
|
46
49
|
params
|
|
@@ -60,27 +63,44 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
};
|
|
63
|
-
const
|
|
64
|
-
var _nde$declaration;
|
|
66
|
+
const handleTypes = () => {
|
|
67
|
+
var _nde$declaration, _nde$declaration2;
|
|
65
68
|
const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */
|
|
66
69
|
node;
|
|
67
70
|
if (!nde) {
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
73
|
switch (nde.type) {
|
|
74
|
+
case 'ExportDefaultDeclaration':
|
|
75
|
+
switch ((_nde$declaration = nde.declaration) === null || _nde$declaration === void 0 ? void 0 : _nde$declaration.type) {
|
|
76
|
+
case 'ClassDeclaration':
|
|
77
|
+
case 'FunctionDeclaration':
|
|
78
|
+
case 'TSInterfaceDeclaration':
|
|
79
|
+
checkTypeParams(nde.declaration);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
71
83
|
case 'ExportNamedDeclaration':
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
switch ((_nde$declaration2 = nde.declaration) === null || _nde$declaration2 === void 0 ? void 0 : _nde$declaration2.type) {
|
|
85
|
+
case 'ClassDeclaration':
|
|
86
|
+
case 'FunctionDeclaration':
|
|
87
|
+
case 'TSTypeAliasDeclaration':
|
|
88
|
+
case 'TSInterfaceDeclaration':
|
|
89
|
+
checkTypeParams(nde.declaration);
|
|
90
|
+
break;
|
|
74
91
|
}
|
|
75
92
|
break;
|
|
93
|
+
case 'ClassDeclaration':
|
|
94
|
+
case 'FunctionDeclaration':
|
|
76
95
|
case 'TSTypeAliasDeclaration':
|
|
77
|
-
|
|
96
|
+
case 'TSInterfaceDeclaration':
|
|
97
|
+
checkTypeParams(nde);
|
|
78
98
|
break;
|
|
79
99
|
}
|
|
80
100
|
};
|
|
81
101
|
const typedefTags = utils.getTags('typedef');
|
|
82
102
|
if (!typedefTags.length || typedefTags.length >= 2) {
|
|
83
|
-
|
|
103
|
+
handleTypes();
|
|
84
104
|
return;
|
|
85
105
|
}
|
|
86
106
|
const usedNameToTag = new Map();
|
|
@@ -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","
|
|
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","checkTypeParams","aliasDeclaration","params","typeParameters","add","usedName","includes","handleTypes","_nde$declaration","_nde$declaration2","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.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkTypeParams = (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 handleTypes = () => {\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 'ExportDefaultDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n break;\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n break;\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypes();\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',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8C,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,IAAI;EACJC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,wBAAwB,GAAG;EAC7B,CAAC,GAAGL,OAAO,CAACM,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC;EACF,CAAC,GAAGJ,QAAQ;EAEZ,MAAMK,SAAS,GAAG,IAAIC,GAAG,CAAC,CAA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AAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -20,7 +20,10 @@ export default iterateJsdoc(({
|
|
|
20
20
|
|
|
21
21
|
const usedNames = new Set();
|
|
22
22
|
/**
|
|
23
|
-
* @param {import('@typescript-eslint/types').TSESTree.
|
|
23
|
+
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
24
|
+
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
25
|
+
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
26
|
+
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
24
27
|
*/
|
|
25
28
|
const checkParameters = (aliasDeclaration) => {
|
|
26
29
|
/* c8 ignore next -- Guard */
|
|
@@ -47,12 +50,21 @@ export default iterateJsdoc(({
|
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
52
|
switch (nde.type) {
|
|
53
|
+
case 'ExportDefaultDeclaration':
|
|
50
54
|
case 'ExportNamedDeclaration':
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
switch (nde.declaration?.type) {
|
|
56
|
+
case 'ClassDeclaration':
|
|
57
|
+
case 'FunctionDeclaration':
|
|
58
|
+
case 'TSTypeAliasDeclaration':
|
|
59
|
+
case 'TSInterfaceDeclaration':
|
|
60
|
+
checkParameters(nde.declaration);
|
|
61
|
+
break;
|
|
53
62
|
}
|
|
54
63
|
break;
|
|
64
|
+
case 'ClassDeclaration':
|
|
65
|
+
case 'FunctionDeclaration':
|
|
55
66
|
case 'TSTypeAliasDeclaration':
|
|
67
|
+
case 'TSInterfaceDeclaration':
|
|
56
68
|
checkParameters(nde);
|
|
57
69
|
break;
|
|
58
70
|
}
|
|
@@ -35,9 +35,12 @@ export default iterateJsdoc(({
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* @param {import('@typescript-eslint/types').TSESTree.
|
|
38
|
+
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
39
|
+
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
40
|
+
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
41
|
+
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
39
42
|
*/
|
|
40
|
-
const
|
|
43
|
+
const checkTypeParams = (aliasDeclaration) => {
|
|
41
44
|
/* c8 ignore next -- Guard */
|
|
42
45
|
const {params} = aliasDeclaration.typeParameters ?? {params: []};
|
|
43
46
|
for (const {name: {name}} of params) {
|
|
@@ -50,7 +53,7 @@ export default iterateJsdoc(({
|
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
const
|
|
56
|
+
const handleTypes = () => {
|
|
54
57
|
const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (
|
|
55
58
|
node
|
|
56
59
|
);
|
|
@@ -58,20 +61,37 @@ export default iterateJsdoc(({
|
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
63
|
switch (nde.type) {
|
|
64
|
+
case 'ExportDefaultDeclaration':
|
|
65
|
+
switch (nde.declaration?.type) {
|
|
66
|
+
case 'ClassDeclaration':
|
|
67
|
+
case 'FunctionDeclaration':
|
|
68
|
+
case 'TSInterfaceDeclaration':
|
|
69
|
+
checkTypeParams(nde.declaration);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
61
73
|
case 'ExportNamedDeclaration':
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
switch (nde.declaration?.type) {
|
|
75
|
+
case 'ClassDeclaration':
|
|
76
|
+
case 'FunctionDeclaration':
|
|
77
|
+
case 'TSTypeAliasDeclaration':
|
|
78
|
+
case 'TSInterfaceDeclaration':
|
|
79
|
+
checkTypeParams(nde.declaration);
|
|
80
|
+
break;
|
|
64
81
|
}
|
|
65
82
|
break;
|
|
83
|
+
case 'ClassDeclaration':
|
|
84
|
+
case 'FunctionDeclaration':
|
|
66
85
|
case 'TSTypeAliasDeclaration':
|
|
67
|
-
|
|
86
|
+
case 'TSInterfaceDeclaration':
|
|
87
|
+
checkTypeParams(nde);
|
|
68
88
|
break;
|
|
69
89
|
}
|
|
70
90
|
};
|
|
71
91
|
|
|
72
92
|
const typedefTags = utils.getTags('typedef');
|
|
73
93
|
if (!typedefTags.length || typedefTags.length >= 2) {
|
|
74
|
-
|
|
94
|
+
handleTypes();
|
|
75
95
|
return;
|
|
76
96
|
}
|
|
77
97
|
|