eslint-plugin-jsdoc 50.6.17 → 50.7.1
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/alignTransform.cjs +10 -10
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/exportParser.cjs +141 -135
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +10 -12
- package/dist/generateRule.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.cjs +73 -73
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +121 -110
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/index.cjs +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/iterateJsdoc.cjs +87 -66
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +144 -142
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +2 -2
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +22 -28
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +2 -2
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +14 -14
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +21 -15
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +2 -2
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +11 -11
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +21 -22
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +10 -10
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +11 -14
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +26 -27
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +6 -6
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +12 -12
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +12 -12
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +1 -1
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +4 -4
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +10 -10
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +3 -3
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +6 -6
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +2 -2
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +17 -20
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +4 -4
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +2 -2
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +8 -8
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +6 -6
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -4
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +19 -19
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +12 -12
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +1 -1
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +3 -3
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +1 -1
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +1 -1
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +16 -15
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +4 -4
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +6 -6
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +13 -13
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +11 -11
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +2 -2
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +15 -15
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +1 -1
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +176 -176
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/eslint.config.js +36 -32
- package/package.json +29 -29
- package/pnpm-workspace.yaml +1 -0
- package/src/alignTransform.js +15 -15
- package/src/exportParser.js +386 -373
- package/src/getDefaultTagStructureForMode.js +45 -45
- package/src/getJsdocProcessorPlugin.js +175 -128
- package/src/index.js +66 -37
- package/src/iterateJsdoc.js +61 -28
- package/src/jsdocUtils.js +354 -338
- package/src/rules/checkAlignment.js +2 -2
- package/src/rules/checkExamples.js +16 -20
- package/src/rules/checkIndentation.js +2 -2
- package/src/rules/checkLineAlignment.js +10 -10
- package/src/rules/checkParamNames.js +22 -14
- package/src/rules/checkPropertyNames.js +1 -1
- package/src/rules/checkTagNames.js +7 -7
- package/src/rules/checkTemplateNames.js +52 -38
- package/src/rules/checkTypes.js +7 -7
- package/src/rules/checkValues.js +16 -17
- package/src/rules/convertToJsdocComments.js +47 -37
- package/src/rules/emptyTags.js +14 -7
- package/src/rules/importsAsDependencies.js +3 -1
- package/src/rules/informativeDocs.js +58 -58
- package/src/rules/linesBeforeBlock.js +25 -17
- package/src/rules/matchDescription.js +1 -1
- package/src/rules/matchName.js +2 -2
- package/src/rules/multilineBlocks.js +10 -10
- package/src/rules/noBadBlocks.js +3 -3
- package/src/rules/noMultiAsterisks.js +4 -4
- package/src/rules/noRestrictedSyntax.js +1 -1
- package/src/rules/noTypes.js +1 -1
- package/src/rules/noUndefinedTypes.js +29 -23
- package/src/rules/requireAsteriskPrefix.js +3 -3
- package/src/rules/requireDescription.js +1 -1
- package/src/rules/requireDescriptionCompleteSentence.js +6 -6
- package/src/rules/requireFileOverview.js +3 -3
- package/src/rules/requireHyphenBeforeParamDescription.js +2 -5
- package/src/rules/requireJsdoc.js +14 -14
- package/src/rules/requireParam.js +9 -9
- package/src/rules/requireProperty.js +1 -1
- package/src/rules/requireReturns.js +1 -1
- package/src/rules/requireReturnsCheck.js +1 -1
- package/src/rules/requireReturnsDescription.js +1 -1
- package/src/rules/requireTemplate.js +59 -38
- package/src/rules/requireYields.js +3 -3
- package/src/rules/requireYieldsCheck.js +1 -1
- package/src/rules/sortTags.js +7 -7
- package/src/rules/tagLines.js +8 -8
- package/src/rules/textEscaping.js +2 -0
- package/src/rules/validTypes.js +29 -29
- package/src/tagNames.js +2 -2
- package/src/utils/hasReturnValue.js +298 -283
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {parseImportsExports} from 'parse-imports-exports';
|
|
1
|
+
import iterateJsdoc, {
|
|
2
|
+
parseComment,
|
|
3
|
+
} from '../iterateJsdoc.js';
|
|
5
4
|
import {
|
|
6
5
|
getJSDocComment,
|
|
7
6
|
parse as parseType,
|
|
8
7
|
traverse,
|
|
9
8
|
tryParse as tryParseType,
|
|
10
9
|
} from '@es-joy/jsdoccomment';
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
} from '
|
|
14
|
-
|
|
15
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
import {
|
|
11
|
+
parseImportsExports,
|
|
12
|
+
} from 'parse-imports-exports';
|
|
16
13
|
|
|
17
14
|
const extraTypes = [
|
|
18
15
|
'null', 'undefined', 'void', 'string', 'boolean', 'object',
|
|
@@ -89,9 +86,9 @@ export default iterateJsdoc(({
|
|
|
89
86
|
/** @type {(string|undefined)[]} */
|
|
90
87
|
let definedPreferredTypes = [];
|
|
91
88
|
const {
|
|
89
|
+
mode,
|
|
92
90
|
preferredTypes,
|
|
93
91
|
structuredTags,
|
|
94
|
-
mode,
|
|
95
92
|
} = settings;
|
|
96
93
|
if (Object.keys(preferredTypes).length) {
|
|
97
94
|
definedPreferredTypes = /** @type {string[]} */ (Object.values(preferredTypes).map((preferredType) => {
|
|
@@ -135,7 +132,6 @@ export default iterateJsdoc(({
|
|
|
135
132
|
return tag.name;
|
|
136
133
|
});
|
|
137
134
|
|
|
138
|
-
|
|
139
135
|
const importTags = settings.mode === 'typescript' ? /** @type {string[]} */ (comments.flatMap((doc) => {
|
|
140
136
|
return doc.tags.filter(({
|
|
141
137
|
tag,
|
|
@@ -144,12 +140,14 @@ export default iterateJsdoc(({
|
|
|
144
140
|
});
|
|
145
141
|
}).flatMap((tag) => {
|
|
146
142
|
const {
|
|
147
|
-
|
|
143
|
+
description,
|
|
144
|
+
name,
|
|
145
|
+
type,
|
|
148
146
|
} = tag;
|
|
149
|
-
const typePart = type ? `{${type}}
|
|
150
|
-
const imprt = 'import ' + (description
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
const typePart = type ? `{${type}} ` : '';
|
|
148
|
+
const imprt = 'import ' + (description ?
|
|
149
|
+
`${typePart}${name} ${description}` :
|
|
150
|
+
`${typePart}${name}`);
|
|
153
151
|
|
|
154
152
|
const importsExports = parseImportsExports(imprt.trim());
|
|
155
153
|
|
|
@@ -159,6 +157,7 @@ export default iterateJsdoc(({
|
|
|
159
157
|
if (namedImports.default) {
|
|
160
158
|
types.push(namedImports.default);
|
|
161
159
|
}
|
|
160
|
+
|
|
162
161
|
if (namedImports.names) {
|
|
163
162
|
types.push(...Object.keys(namedImports.names));
|
|
164
163
|
}
|
|
@@ -169,6 +168,7 @@ export default iterateJsdoc(({
|
|
|
169
168
|
if (namespaceImports.namespace) {
|
|
170
169
|
types.push(namespaceImports.namespace);
|
|
171
170
|
}
|
|
171
|
+
|
|
172
172
|
if (namespaceImports.default) {
|
|
173
173
|
types.push(namespaceImports.default);
|
|
174
174
|
}
|
|
@@ -226,14 +226,20 @@ export default iterateJsdoc(({
|
|
|
226
226
|
* @returns {Set<string>}
|
|
227
227
|
*/
|
|
228
228
|
const getValidRuntimeIdentifiers = (scope) => {
|
|
229
|
-
const result = new Set()
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
const result = new Set();
|
|
230
|
+
|
|
231
|
+
let scp = scope;
|
|
232
|
+
while (scp) {
|
|
233
|
+
for (const {
|
|
234
|
+
name,
|
|
235
|
+
} of scp.variables) {
|
|
236
|
+
result.add(name);
|
|
233
237
|
}
|
|
234
|
-
|
|
238
|
+
|
|
239
|
+
scp = scp.upper;
|
|
235
240
|
}
|
|
236
|
-
|
|
241
|
+
|
|
242
|
+
return result;
|
|
237
243
|
};
|
|
238
244
|
|
|
239
245
|
const allDefinedTypes = new Set(globalScope.variables.map(({
|
|
@@ -340,8 +346,8 @@ export default iterateJsdoc(({
|
|
|
340
346
|
].filter(Boolean));
|
|
341
347
|
|
|
342
348
|
for (const {
|
|
343
|
-
tag,
|
|
344
349
|
parsedType,
|
|
350
|
+
tag,
|
|
345
351
|
} of tagsWithTypes) {
|
|
346
352
|
traverse(parsedType, (nde) => {
|
|
347
353
|
const {
|
|
@@ -2,9 +2,9 @@ import iterateJsdoc from '../iterateJsdoc.js';
|
|
|
2
2
|
|
|
3
3
|
export default iterateJsdoc(({
|
|
4
4
|
context,
|
|
5
|
+
indent,
|
|
5
6
|
jsdoc,
|
|
6
7
|
utils,
|
|
7
|
-
indent,
|
|
8
8
|
}) => {
|
|
9
9
|
const [
|
|
10
10
|
defaultRequireValue = 'always',
|
|
@@ -28,9 +28,9 @@ export default iterateJsdoc(({
|
|
|
28
28
|
}) => {
|
|
29
29
|
const {
|
|
30
30
|
delimiter,
|
|
31
|
-
tag,
|
|
32
|
-
end,
|
|
33
31
|
description,
|
|
32
|
+
end,
|
|
33
|
+
tag,
|
|
34
34
|
} = tokens;
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -2,11 +2,11 @@ import iterateJsdoc from '../iterateJsdoc.js';
|
|
|
2
2
|
import escapeStringRegexp from 'escape-string-regexp';
|
|
3
3
|
|
|
4
4
|
const otherDescriptiveTags = new Set([
|
|
5
|
+
'classdesc', 'deprecated', 'exception', 'file', 'fileoverview', 'overview',
|
|
5
6
|
// 'copyright' and 'see' might be good addition, but as the former may be
|
|
6
7
|
// sensitive text, and the latter may have just a link, they are not
|
|
7
8
|
// included by default
|
|
8
|
-
'summary', '
|
|
9
|
-
'deprecated', 'throws', 'exception', 'yields', 'yield',
|
|
9
|
+
'summary', 'throws', 'todo', 'yield', 'yields',
|
|
10
10
|
]);
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -112,7 +112,7 @@ const validateDescription = (
|
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/
|
|
115
|
+
const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gmu, '');
|
|
116
116
|
|
|
117
117
|
const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean);
|
|
118
118
|
|
|
@@ -123,7 +123,7 @@ const validateDescription = (
|
|
|
123
123
|
let text = sourceCode.getText(jsdocNode);
|
|
124
124
|
|
|
125
125
|
if (!/[.:?!]$/u.test(paragraph)) {
|
|
126
|
-
const line = paragraph.split('\n').
|
|
126
|
+
const line = paragraph.split('\n').findLast(Boolean);
|
|
127
127
|
text = text.replace(new RegExp(`${escapeStringRegexp(
|
|
128
128
|
/** @type {string} */
|
|
129
129
|
(line),
|
|
@@ -210,11 +210,11 @@ const validateDescription = (
|
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
export default iterateJsdoc(({
|
|
213
|
-
sourceCode,
|
|
214
213
|
context,
|
|
215
214
|
jsdoc,
|
|
216
|
-
report,
|
|
217
215
|
jsdocNode,
|
|
216
|
+
report,
|
|
217
|
+
sourceCode,
|
|
218
218
|
utils,
|
|
219
219
|
}) => {
|
|
220
220
|
const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */ {
|
|
@@ -23,10 +23,10 @@ const setDefaults = (state) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export default iterateJsdoc(({
|
|
26
|
+
context,
|
|
26
27
|
jsdocNode,
|
|
27
28
|
state,
|
|
28
29
|
utils,
|
|
29
|
-
context,
|
|
30
30
|
}) => {
|
|
31
31
|
const {
|
|
32
32
|
tags = defaultTags,
|
|
@@ -70,9 +70,9 @@ export default iterateJsdoc(({
|
|
|
70
70
|
for (const [
|
|
71
71
|
tagName,
|
|
72
72
|
{
|
|
73
|
+
initialCommentsOnly = false,
|
|
73
74
|
mustExist = false,
|
|
74
75
|
preventDuplicates = false,
|
|
75
|
-
initialCommentsOnly = false,
|
|
76
76
|
},
|
|
77
77
|
] of Object.entries(tags)) {
|
|
78
78
|
const obj = utils.getPreferredTagNameObject({
|
|
@@ -144,8 +144,8 @@ export default iterateJsdoc(({
|
|
|
144
144
|
type: 'suggestion',
|
|
145
145
|
},
|
|
146
146
|
nonComment ({
|
|
147
|
-
state,
|
|
148
147
|
node,
|
|
148
|
+
state,
|
|
149
149
|
}) {
|
|
150
150
|
if (!state.hasNonComment) {
|
|
151
151
|
state.hasNonComment = node.range[0];
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
3
|
export default iterateJsdoc(({
|
|
4
|
-
sourceCode,
|
|
5
|
-
utils,
|
|
6
|
-
report,
|
|
7
4
|
context,
|
|
8
5
|
jsdoc,
|
|
9
|
-
|
|
6
|
+
utils,
|
|
10
7
|
}) => {
|
|
11
8
|
const [
|
|
12
9
|
mainCircumstance,
|
|
@@ -62,7 +59,7 @@ export default iterateJsdoc(({
|
|
|
62
59
|
break;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
|
-
}
|
|
62
|
+
},
|
|
66
63
|
);
|
|
67
64
|
}
|
|
68
65
|
} else if (startsWithHyphen) {
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
getSettings,
|
|
4
4
|
} from '../iterateJsdoc.js';
|
|
5
5
|
import {
|
|
6
|
+
enforcedContexts,
|
|
6
7
|
exemptSpeciaMethods,
|
|
7
|
-
|
|
8
|
+
getContextObject,
|
|
8
9
|
getFunctionParameterNames,
|
|
9
|
-
hasReturnValue,
|
|
10
10
|
getIndent,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
hasReturnValue,
|
|
12
|
+
isConstructor,
|
|
13
13
|
} from '../jsdocUtils.js';
|
|
14
14
|
import {
|
|
15
15
|
getDecorator,
|
|
@@ -215,13 +215,13 @@ const getOption = (context, baseObject, option, key) => {
|
|
|
215
215
|
*/
|
|
216
216
|
const getOptions = (context, settings) => {
|
|
217
217
|
const {
|
|
218
|
-
publicOnly,
|
|
219
218
|
contexts = settings.contexts || [],
|
|
219
|
+
enableFixer = true,
|
|
220
220
|
exemptEmptyConstructors = true,
|
|
221
221
|
exemptEmptyFunctions = false,
|
|
222
|
-
enableFixer = true,
|
|
223
222
|
fixerMessage = '',
|
|
224
223
|
minLineCount = undefined,
|
|
224
|
+
publicOnly,
|
|
225
225
|
} = context.options[0] || {};
|
|
226
226
|
|
|
227
227
|
return {
|
|
@@ -309,13 +309,13 @@ export default {
|
|
|
309
309
|
const opts = getOptions(context, settings);
|
|
310
310
|
|
|
311
311
|
const {
|
|
312
|
-
require: requireOption,
|
|
313
312
|
contexts,
|
|
314
|
-
exemptEmptyFunctions,
|
|
315
|
-
exemptEmptyConstructors,
|
|
316
313
|
enableFixer,
|
|
314
|
+
exemptEmptyConstructors,
|
|
315
|
+
exemptEmptyFunctions,
|
|
317
316
|
fixerMessage,
|
|
318
317
|
minLineCount,
|
|
318
|
+
require: requireOption,
|
|
319
319
|
} = opts;
|
|
320
320
|
|
|
321
321
|
const publicOnly =
|
|
@@ -429,7 +429,7 @@ export default {
|
|
|
429
429
|
|
|
430
430
|
const decorator = getDecorator(
|
|
431
431
|
/** @type {import('eslint').Rule.Node} */
|
|
432
|
-
(baseNode)
|
|
432
|
+
(baseNode),
|
|
433
433
|
);
|
|
434
434
|
if (decorator) {
|
|
435
435
|
baseNode = decorator;
|
|
@@ -535,10 +535,10 @@ export default {
|
|
|
535
535
|
|
|
536
536
|
if (
|
|
537
537
|
[
|
|
538
|
-
'
|
|
538
|
+
'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
|
|
539
539
|
].includes(node.parent.type) ||
|
|
540
540
|
[
|
|
541
|
-
'
|
|
541
|
+
'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
|
|
542
542
|
].includes(node.parent.type) &&
|
|
543
543
|
node ===
|
|
544
544
|
/**
|
|
@@ -591,10 +591,10 @@ export default {
|
|
|
591
591
|
|
|
592
592
|
if (
|
|
593
593
|
[
|
|
594
|
-
'
|
|
594
|
+
'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
|
|
595
595
|
].includes(node.parent.type) ||
|
|
596
596
|
[
|
|
597
|
-
'
|
|
597
|
+
'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
|
|
598
598
|
].includes(node.parent.type) &&
|
|
599
599
|
node ===
|
|
600
600
|
/**
|
|
@@ -33,9 +33,9 @@ const rootNamer = (desiredRoots, currentIndex) => {
|
|
|
33
33
|
|
|
34
34
|
/* eslint-disable complexity -- Temporary */
|
|
35
35
|
export default iterateJsdoc(({
|
|
36
|
+
context,
|
|
36
37
|
jsdoc,
|
|
37
38
|
utils,
|
|
38
|
-
context,
|
|
39
39
|
}) => {
|
|
40
40
|
/* eslint-enable complexity -- Temporary */
|
|
41
41
|
if (utils.avoidDocs()) {
|
|
@@ -49,18 +49,18 @@ export default iterateJsdoc(({
|
|
|
49
49
|
|
|
50
50
|
const {
|
|
51
51
|
autoIncrementBase = 0,
|
|
52
|
-
checkRestProperty = false,
|
|
53
52
|
checkDestructured = true,
|
|
54
53
|
checkDestructuredRoots = true,
|
|
54
|
+
checkRestProperty = false,
|
|
55
55
|
checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',
|
|
56
56
|
enableFixer = true,
|
|
57
|
-
enableRootFixer = true,
|
|
58
57
|
enableRestElementFixer = true,
|
|
58
|
+
enableRootFixer = true,
|
|
59
|
+
ignoreWhenAllParamsMissing = false,
|
|
59
60
|
unnamedRootBase = [
|
|
60
61
|
'root',
|
|
61
62
|
],
|
|
62
63
|
useDefaultObjectProperties = false,
|
|
63
|
-
ignoreWhenAllParamsMissing = false,
|
|
64
64
|
} = context.options[0] || {};
|
|
65
65
|
|
|
66
66
|
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
@@ -225,7 +225,6 @@ export default iterateJsdoc(({
|
|
|
225
225
|
functionParameterIdx,
|
|
226
226
|
functionParameterName,
|
|
227
227
|
] of functionParameterNames.entries()) {
|
|
228
|
-
|
|
229
228
|
let inc;
|
|
230
229
|
if (Array.isArray(functionParameterName)) {
|
|
231
230
|
const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset];
|
|
@@ -243,6 +242,7 @@ export default iterateJsdoc(({
|
|
|
243
242
|
rootName = nextRootName;
|
|
244
243
|
inc = incremented;
|
|
245
244
|
}
|
|
245
|
+
|
|
246
246
|
[
|
|
247
247
|
nextRootName,
|
|
248
248
|
incremented,
|
|
@@ -250,10 +250,10 @@ export default iterateJsdoc(({
|
|
|
250
250
|
] = namer();
|
|
251
251
|
|
|
252
252
|
const {
|
|
253
|
-
hasRestElement,
|
|
254
253
|
hasPropertyRest,
|
|
255
|
-
|
|
254
|
+
hasRestElement,
|
|
256
255
|
names,
|
|
256
|
+
rests,
|
|
257
257
|
} = /**
|
|
258
258
|
* @type {import('../jsdocUtils.js').FlattendRootInfo & {
|
|
259
259
|
* annotationParamName?: string | undefined;
|
|
@@ -394,8 +394,8 @@ export default iterateJsdoc(({
|
|
|
394
394
|
const fix = ({
|
|
395
395
|
functionParameterIdx,
|
|
396
396
|
functionParameterName,
|
|
397
|
-
remove,
|
|
398
397
|
inc,
|
|
398
|
+
remove,
|
|
399
399
|
type,
|
|
400
400
|
}) => {
|
|
401
401
|
if (inc && !enableRootFixer) {
|
|
@@ -460,8 +460,8 @@ export default iterateJsdoc(({
|
|
|
460
460
|
|
|
461
461
|
const offset = jsdoc.source.findIndex(({
|
|
462
462
|
tokens: {
|
|
463
|
-
tag,
|
|
464
463
|
end,
|
|
464
|
+
tag,
|
|
465
465
|
},
|
|
466
466
|
}) => {
|
|
467
467
|
return tag || end;
|
|
@@ -36,6 +36,7 @@ const canSkip = (utils) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export default iterateJsdoc(({
|
|
39
|
+
context,
|
|
39
40
|
info: {
|
|
40
41
|
comment,
|
|
41
42
|
},
|
|
@@ -43,7 +44,6 @@ export default iterateJsdoc(({
|
|
|
43
44
|
report,
|
|
44
45
|
settings,
|
|
45
46
|
utils,
|
|
46
|
-
context,
|
|
47
47
|
}) => {
|
|
48
48
|
const {
|
|
49
49
|
contexts,
|
|
@@ -110,7 +110,7 @@ export default iterateJsdoc(({
|
|
|
110
110
|
Boolean(
|
|
111
111
|
!exemptGenerators || !node ||
|
|
112
112
|
!('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||
|
|
113
|
-
!(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator
|
|
113
|
+
!(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,
|
|
114
114
|
)
|
|
115
115
|
) {
|
|
116
116
|
report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
1
2
|
import {
|
|
2
3
|
parse as parseType,
|
|
3
4
|
traverse,
|
|
4
5
|
tryParse as tryParseType,
|
|
5
6
|
} from '@es-joy/jsdoccomment';
|
|
6
|
-
import iterateJsdoc from '../iterateJsdoc.js';
|
|
7
7
|
|
|
8
8
|
export default iterateJsdoc(({
|
|
9
9
|
context,
|
|
10
|
-
utils,
|
|
11
10
|
node,
|
|
12
|
-
settings,
|
|
13
11
|
report,
|
|
12
|
+
settings,
|
|
13
|
+
utils,
|
|
14
14
|
}) => {
|
|
15
15
|
const {
|
|
16
16
|
requireSeparateTemplates = false,
|
|
17
17
|
} = context.options[0] || {};
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
|
-
mode
|
|
20
|
+
mode,
|
|
21
21
|
} = settings;
|
|
22
22
|
|
|
23
23
|
const usedNames = new Set();
|
|
24
24
|
const templateTags = utils.getTags('template');
|
|
25
|
-
const templateNames = templateTags.flatMap(({
|
|
26
|
-
|
|
25
|
+
const templateNames = templateTags.flatMap(({
|
|
26
|
+
name,
|
|
27
|
+
}) => {
|
|
28
|
+
return name.split(/,\s*/u);
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
for (const tag of templateTags) {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
+
const {
|
|
33
|
+
name,
|
|
34
|
+
} = tag;
|
|
35
|
+
const names = name.split(/,\s*/u);
|
|
32
36
|
if (requireSeparateTemplates && names.length > 1) {
|
|
33
37
|
report(`Missing separate @template for ${names[1]}`, null, tag);
|
|
34
38
|
}
|
|
@@ -41,11 +45,21 @@ export default iterateJsdoc(({
|
|
|
41
45
|
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
42
46
|
*/
|
|
43
47
|
const checkTypeParams = (aliasDeclaration) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
const {
|
|
49
|
+
params,
|
|
50
|
+
/* c8 ignore next -- Guard */
|
|
51
|
+
} = aliasDeclaration.typeParameters ?? {
|
|
52
|
+
/* c8 ignore next -- Guard */
|
|
53
|
+
params: [],
|
|
54
|
+
};
|
|
55
|
+
for (const {
|
|
56
|
+
name: {
|
|
57
|
+
name,
|
|
58
|
+
},
|
|
59
|
+
} of params) {
|
|
47
60
|
usedNames.add(name);
|
|
48
61
|
}
|
|
62
|
+
|
|
49
63
|
for (const usedName of usedNames) {
|
|
50
64
|
if (!templateNames.includes(usedName)) {
|
|
51
65
|
report(`Missing @template ${usedName}`);
|
|
@@ -60,32 +74,35 @@ export default iterateJsdoc(({
|
|
|
60
74
|
if (!nde) {
|
|
61
75
|
return;
|
|
62
76
|
}
|
|
77
|
+
|
|
63
78
|
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;
|
|
73
|
-
case 'ExportNamedDeclaration':
|
|
74
|
-
switch (nde.declaration?.type) {
|
|
75
79
|
case 'ClassDeclaration':
|
|
76
80
|
case 'FunctionDeclaration':
|
|
77
|
-
case 'TSTypeAliasDeclaration':
|
|
78
81
|
case 'TSInterfaceDeclaration':
|
|
79
|
-
|
|
82
|
+
case 'TSTypeAliasDeclaration':
|
|
83
|
+
checkTypeParams(nde);
|
|
84
|
+
break;
|
|
85
|
+
case 'ExportDefaultDeclaration':
|
|
86
|
+
switch (nde.declaration?.type) {
|
|
87
|
+
case 'ClassDeclaration':
|
|
88
|
+
case 'FunctionDeclaration':
|
|
89
|
+
case 'TSInterfaceDeclaration':
|
|
90
|
+
checkTypeParams(nde.declaration);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
break;
|
|
95
|
+
case 'ExportNamedDeclaration':
|
|
96
|
+
switch (nde.declaration?.type) {
|
|
97
|
+
case 'ClassDeclaration':
|
|
98
|
+
case 'FunctionDeclaration':
|
|
99
|
+
case 'TSInterfaceDeclaration':
|
|
100
|
+
case 'TSTypeAliasDeclaration':
|
|
101
|
+
checkTypeParams(nde.declaration);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
80
105
|
break;
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
case 'ClassDeclaration':
|
|
84
|
-
case 'FunctionDeclaration':
|
|
85
|
-
case 'TSTypeAliasDeclaration':
|
|
86
|
-
case 'TSInterfaceDeclaration':
|
|
87
|
-
checkTypeParams(nde);
|
|
88
|
-
break;
|
|
89
106
|
}
|
|
90
107
|
};
|
|
91
108
|
|
|
@@ -99,7 +116,7 @@ export default iterateJsdoc(({
|
|
|
99
116
|
try {
|
|
100
117
|
parsedType = mode === 'permissive' ?
|
|
101
118
|
tryParseType(/** @type {string} */ (potentialTag.type)) :
|
|
102
|
-
parseType(/** @type {string} */ (potentialTag.type), mode)
|
|
119
|
+
parseType(/** @type {string} */ (potentialTag.type), mode);
|
|
103
120
|
} catch {
|
|
104
121
|
return;
|
|
105
122
|
}
|
|
@@ -109,7 +126,7 @@ export default iterateJsdoc(({
|
|
|
109
126
|
type,
|
|
110
127
|
value,
|
|
111
128
|
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
112
|
-
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {
|
|
129
|
+
if (type === 'JsdocTypeName' && (/^[A-Z]$/u).test(value)) {
|
|
113
130
|
usedNames.add(value);
|
|
114
131
|
if (!usedNameToTag.has(value)) {
|
|
115
132
|
usedNameToTag.set(value, potentialTag);
|
|
@@ -143,7 +160,9 @@ export default iterateJsdoc(({
|
|
|
143
160
|
const callbackTags = utils.getTags('callback');
|
|
144
161
|
const functionTags = utils.getTags('function');
|
|
145
162
|
if (callbackTags.length || functionTags.length) {
|
|
146
|
-
checkTagsAndTemplates([
|
|
163
|
+
checkTagsAndTemplates([
|
|
164
|
+
'param', 'returns',
|
|
165
|
+
]);
|
|
147
166
|
return;
|
|
148
167
|
}
|
|
149
168
|
|
|
@@ -156,7 +175,9 @@ export default iterateJsdoc(({
|
|
|
156
175
|
const potentialTypedef = typedefTags[0];
|
|
157
176
|
checkForUsedTypes(potentialTypedef);
|
|
158
177
|
|
|
159
|
-
checkTagsAndTemplates([
|
|
178
|
+
checkTagsAndTemplates([
|
|
179
|
+
'property',
|
|
180
|
+
]);
|
|
160
181
|
}, {
|
|
161
182
|
iterateAllJsdocs: true,
|
|
162
183
|
meta: {
|
|
@@ -169,8 +190,8 @@ export default iterateJsdoc(({
|
|
|
169
190
|
additionalProperties: false,
|
|
170
191
|
properties: {
|
|
171
192
|
requireSeparateTemplates: {
|
|
172
|
-
type: 'boolean'
|
|
173
|
-
}
|
|
193
|
+
type: 'boolean',
|
|
194
|
+
},
|
|
174
195
|
},
|
|
175
196
|
type: 'object',
|
|
176
197
|
},
|
|
@@ -65,15 +65,15 @@ const checkTagName = (utils, report, tagName) => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export default iterateJsdoc(({
|
|
68
|
+
context,
|
|
68
69
|
report,
|
|
69
70
|
utils,
|
|
70
|
-
context,
|
|
71
71
|
}) => {
|
|
72
72
|
const {
|
|
73
|
-
next = false,
|
|
74
|
-
nextWithGeneratorTag = false,
|
|
75
73
|
forceRequireNext = false,
|
|
76
74
|
forceRequireYields = false,
|
|
75
|
+
next = false,
|
|
76
|
+
nextWithGeneratorTag = false,
|
|
77
77
|
withGeneratorTag = true,
|
|
78
78
|
} = context.options[0] || {};
|
|
79
79
|
|