eslint-plugin-jsdoc 48.10.1 → 48.10.2
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.
|
@@ -19,13 +19,35 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
19
19
|
} = settings;
|
|
20
20
|
const templateTags = utils.getTags('template');
|
|
21
21
|
const usedNames = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} potentialType
|
|
24
|
+
*/
|
|
25
|
+
const checkForUsedTypes = potentialType => {
|
|
26
|
+
let parsedType;
|
|
27
|
+
try {
|
|
28
|
+
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode);
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
33
|
+
const {
|
|
34
|
+
type,
|
|
35
|
+
value
|
|
36
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
37
|
+
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
38
|
+
usedNames.add(value);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
22
43
|
/**
|
|
23
44
|
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
24
45
|
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
25
46
|
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
26
47
|
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
48
|
+
* @param {boolean} [checkParamsAndReturns]
|
|
27
49
|
*/
|
|
28
|
-
const checkParameters = aliasDeclaration => {
|
|
50
|
+
const checkParameters = (aliasDeclaration, checkParamsAndReturns) => {
|
|
29
51
|
/* c8 ignore next -- Guard */
|
|
30
52
|
const {
|
|
31
53
|
params
|
|
@@ -39,6 +61,22 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
39
61
|
} of params) {
|
|
40
62
|
usedNames.add(name);
|
|
41
63
|
}
|
|
64
|
+
if (checkParamsAndReturns) {
|
|
65
|
+
const paramName = /** @type {string} */utils.getPreferredTagName({
|
|
66
|
+
tagName: 'param'
|
|
67
|
+
});
|
|
68
|
+
const paramTags = utils.getTags(paramName);
|
|
69
|
+
for (const paramTag of paramTags) {
|
|
70
|
+
checkForUsedTypes(paramTag.type);
|
|
71
|
+
}
|
|
72
|
+
const returnsName = /** @type {string} */utils.getPreferredTagName({
|
|
73
|
+
tagName: 'returns'
|
|
74
|
+
});
|
|
75
|
+
const returnsTags = utils.getTags(returnsName);
|
|
76
|
+
for (const returnsTag of returnsTags) {
|
|
77
|
+
checkForUsedTypes(returnsTag.type);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
42
80
|
for (const tag of templateTags) {
|
|
43
81
|
const {
|
|
44
82
|
name
|
|
@@ -62,16 +100,20 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
62
100
|
case 'ExportDefaultDeclaration':
|
|
63
101
|
case 'ExportNamedDeclaration':
|
|
64
102
|
switch ((_nde$declaration = nde.declaration) === null || _nde$declaration === void 0 ? void 0 : _nde$declaration.type) {
|
|
65
|
-
case 'ClassDeclaration':
|
|
66
103
|
case 'FunctionDeclaration':
|
|
104
|
+
checkParameters(nde.declaration, true);
|
|
105
|
+
break;
|
|
106
|
+
case 'ClassDeclaration':
|
|
67
107
|
case 'TSTypeAliasDeclaration':
|
|
68
108
|
case 'TSInterfaceDeclaration':
|
|
69
109
|
checkParameters(nde.declaration);
|
|
70
110
|
break;
|
|
71
111
|
}
|
|
72
112
|
break;
|
|
73
|
-
case 'ClassDeclaration':
|
|
74
113
|
case 'FunctionDeclaration':
|
|
114
|
+
checkParameters(nde, true);
|
|
115
|
+
break;
|
|
116
|
+
case 'ClassDeclaration':
|
|
75
117
|
case 'TSTypeAliasDeclaration':
|
|
76
118
|
case 'TSInterfaceDeclaration':
|
|
77
119
|
checkParameters(nde);
|
|
@@ -83,33 +125,12 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
83
125
|
handleTypeAliases();
|
|
84
126
|
return;
|
|
85
127
|
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @param {string} potentialType
|
|
89
|
-
*/
|
|
90
|
-
const checkForUsedTypes = potentialType => {
|
|
91
|
-
let parsedType;
|
|
92
|
-
try {
|
|
93
|
-
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode);
|
|
94
|
-
} catch {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
98
|
-
const {
|
|
99
|
-
type,
|
|
100
|
-
value
|
|
101
|
-
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
102
|
-
if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) {
|
|
103
|
-
usedNames.add(value);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
128
|
const potentialTypedefType = typedefTags[0].type;
|
|
108
129
|
checkForUsedTypes(potentialTypedefType);
|
|
109
|
-
const
|
|
130
|
+
const propertyName = /** @type {string} */utils.getPreferredTagName({
|
|
110
131
|
tagName: 'property'
|
|
111
132
|
});
|
|
112
|
-
const propertyTags = utils.getTags(
|
|
133
|
+
const propertyTags = utils.getTags(propertyName);
|
|
113
134
|
for (const propertyTag of propertyTags) {
|
|
114
135
|
checkForUsedTypes(propertyTag.type);
|
|
115
136
|
}
|
|
@@ -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","
|
|
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","checkForUsedTypes","potentialType","parsedType","tryParseType","parseType","traverse","nde","type","value","test","add","checkParameters","aliasDeclaration","checkParamsAndReturns","params","typeParameters","name","paramName","getPreferredTagName","tagName","paramTags","paramTag","returnsName","returnsTags","returnsTag","tag","names","split","has","handleTypeAliases","_nde$declaration","declaration","typedefTags","length","potentialTypedefType","propertyName","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 {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 /**\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 * @param {boolean} [checkParamsAndReturns]\n */\n const checkParameters = (aliasDeclaration, checkParamsAndReturns) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n if (checkParamsAndReturns) {\n const paramName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n const paramTags = utils.getTags(paramName);\n for (const paramTag of paramTags) {\n checkForUsedTypes(paramTag.type);\n }\n\n const returnsName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n const returnsTags = utils.getTags(returnsName);\n for (const returnsTag of returnsTags) {\n checkForUsedTypes(returnsTag.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\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 'FunctionDeclaration':\n checkParameters(nde.declaration, true);\n break;\n case 'ClassDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSInterfaceDeclaration':\n checkParameters(nde.declaration);\n break;\n }\n break;\n case 'FunctionDeclaration':\n checkParameters(nde, true);\n break;\n case 'ClassDeclaration':\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 const potentialTypedefType = typedefTags[0].type;\n checkForUsedTypes(potentialTypedefType);\n\n const propertyName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const propertyTags = utils.getTags(propertyName);\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,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;EACF,CAAC,GAAGF,QAAQ;EAEZ,MAAMG,YAAY,GAAGL,KAAK,CAACM,OAAO,CAAC,UAAU,CAAC;EAE9C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B;AACF;AACA;EACE,MAAMC,iBAAiB,GAAIC,aAAa,IAAK;IAC3C,IAAIC,UAAU;IACd,IAAI;MACFA,UAAU,GAAGP,IAAI,KAAK,YAAY,GAChC,IAAAQ,sBAAY,GAAC,qBAAuBF,aAAc,CAAC,GACnD,IAAAG,mBAAS,GAAC,qBAAuBH,aAAa,EAAGN,IAAI,CAAC;IAC1D,CAAC,CAAC,MAAM;MACN;IACF;IAEA,IAAAU,sBAAQ,EAACH,UAAU,EAAGI,GAAG,IAAK;MAC5B,MAAM;QACJC,IAAI;QACJC;MACF,CAAC,GAAG,2DAA6DF,GAAI;MACrE,IAAIC,IAAI,KAAK,eAAe,IAAK,SAAS,CAAEE,IAAI,CAACD,KAAK,CAAC,EAAE;QACvDV,SAAS,CAACY,GA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KAAK,MAAME,WAAW,IAAID,YAAY,EAAE;IACtCpC,iBAAiB,CAACqC,WAAW,CAAC9B,IAAI,CAAC;EACrC;EAEA,KAAK,MAAMkB,GAAG,IAAI7B,YAAY,EAAE;IAC9B,MAAM;MAACoB;IAAI,CAAC,GAAGS,GAAG;IAClB,MAAMC,KAAK,GAAGV,IAAI,CAACW,KAAK,CAAC,MAAM,CAAC;IAChC,KAAK,MAAMX,IAAI,IAAIU,KAAK,EAAE;MACxB,IAAI,CAAC5B,SAAS,CAAC8B,GAAG,CAACZ,IAAI,CAAC,EAAE;QACxBtB,MAAM,CAAC,aAAasB,IAAI,aAAa,EAAE,IAAI,EAAES,GAAG,CAAC;MACnD;IACF;EACF;AACF,CAAC,EAAE;EACDa,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,gGAAgG;MAC7GC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,EAAE;IACVpC,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAqC,MAAA,CAAAxD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -19,18 +19,60 @@ export default iterateJsdoc(({
|
|
|
19
19
|
const templateTags = utils.getTags('template');
|
|
20
20
|
|
|
21
21
|
const usedNames = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} potentialType
|
|
24
|
+
*/
|
|
25
|
+
const checkForUsedTypes = (potentialType) => {
|
|
26
|
+
let parsedType;
|
|
27
|
+
try {
|
|
28
|
+
parsedType = mode === 'permissive' ?
|
|
29
|
+
tryParseType(/** @type {string} */ (potentialType)) :
|
|
30
|
+
parseType(/** @type {string} */ (potentialType), mode);
|
|
31
|
+
} catch {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
traverse(parsedType, (nde) => {
|
|
36
|
+
const {
|
|
37
|
+
type,
|
|
38
|
+
value,
|
|
39
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
40
|
+
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
41
|
+
usedNames.add(value);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
22
46
|
/**
|
|
23
47
|
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
24
48
|
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
25
49
|
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
26
50
|
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
51
|
+
* @param {boolean} [checkParamsAndReturns]
|
|
27
52
|
*/
|
|
28
|
-
const checkParameters = (aliasDeclaration) => {
|
|
53
|
+
const checkParameters = (aliasDeclaration, checkParamsAndReturns) => {
|
|
29
54
|
/* c8 ignore next -- Guard */
|
|
30
55
|
const {params} = aliasDeclaration.typeParameters ?? {params: []};
|
|
31
56
|
for (const {name: {name}} of params) {
|
|
32
57
|
usedNames.add(name);
|
|
33
58
|
}
|
|
59
|
+
if (checkParamsAndReturns) {
|
|
60
|
+
const paramName = /** @type {string} */ (utils.getPreferredTagName({
|
|
61
|
+
tagName: 'param',
|
|
62
|
+
}));
|
|
63
|
+
const paramTags = utils.getTags(paramName);
|
|
64
|
+
for (const paramTag of paramTags) {
|
|
65
|
+
checkForUsedTypes(paramTag.type);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const returnsName = /** @type {string} */ (utils.getPreferredTagName({
|
|
69
|
+
tagName: 'returns',
|
|
70
|
+
}));
|
|
71
|
+
const returnsTags = utils.getTags(returnsName);
|
|
72
|
+
for (const returnsTag of returnsTags) {
|
|
73
|
+
checkForUsedTypes(returnsTag.type);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
34
76
|
for (const tag of templateTags) {
|
|
35
77
|
const {name} = tag;
|
|
36
78
|
const names = name.split(/,\s*/);
|
|
@@ -53,16 +95,20 @@ export default iterateJsdoc(({
|
|
|
53
95
|
case 'ExportDefaultDeclaration':
|
|
54
96
|
case 'ExportNamedDeclaration':
|
|
55
97
|
switch (nde.declaration?.type) {
|
|
56
|
-
case 'ClassDeclaration':
|
|
57
98
|
case 'FunctionDeclaration':
|
|
99
|
+
checkParameters(nde.declaration, true);
|
|
100
|
+
break;
|
|
101
|
+
case 'ClassDeclaration':
|
|
58
102
|
case 'TSTypeAliasDeclaration':
|
|
59
103
|
case 'TSInterfaceDeclaration':
|
|
60
104
|
checkParameters(nde.declaration);
|
|
61
105
|
break;
|
|
62
106
|
}
|
|
63
107
|
break;
|
|
64
|
-
case 'ClassDeclaration':
|
|
65
108
|
case 'FunctionDeclaration':
|
|
109
|
+
checkParameters(nde, true);
|
|
110
|
+
break;
|
|
111
|
+
case 'ClassDeclaration':
|
|
66
112
|
case 'TSTypeAliasDeclaration':
|
|
67
113
|
case 'TSInterfaceDeclaration':
|
|
68
114
|
checkParameters(nde);
|
|
@@ -76,37 +122,13 @@ export default iterateJsdoc(({
|
|
|
76
122
|
return;
|
|
77
123
|
}
|
|
78
124
|
|
|
79
|
-
/**
|
|
80
|
-
* @param {string} potentialType
|
|
81
|
-
*/
|
|
82
|
-
const checkForUsedTypes = (potentialType) => {
|
|
83
|
-
let parsedType;
|
|
84
|
-
try {
|
|
85
|
-
parsedType = mode === 'permissive' ?
|
|
86
|
-
tryParseType(/** @type {string} */ (potentialType)) :
|
|
87
|
-
parseType(/** @type {string} */ (potentialType), mode);
|
|
88
|
-
} catch {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
traverse(parsedType, (nde) => {
|
|
93
|
-
const {
|
|
94
|
-
type,
|
|
95
|
-
value,
|
|
96
|
-
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
97
|
-
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
98
|
-
usedNames.add(value);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
125
|
const potentialTypedefType = typedefTags[0].type;
|
|
104
126
|
checkForUsedTypes(potentialTypedefType);
|
|
105
127
|
|
|
106
|
-
const
|
|
128
|
+
const propertyName = /** @type {string} */ (utils.getPreferredTagName({
|
|
107
129
|
tagName: 'property',
|
|
108
130
|
}));
|
|
109
|
-
const propertyTags = utils.getTags(
|
|
131
|
+
const propertyTags = utils.getTags(propertyName);
|
|
110
132
|
for (const propertyTag of propertyTags) {
|
|
111
133
|
checkForUsedTypes(propertyTag.type);
|
|
112
134
|
}
|