eslint-plugin-jsdoc 56.0.0 → 56.0.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.
- package/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -1
- package/dist/cjs/iterateJsdoc.d.cts +6 -2
- package/dist/getJsdocProcessorPlugin.cts +3 -1
- package/dist/iterateJsdoc.cts +9 -4
- package/package.json +4 -4
- package/src/getJsdocProcessorPlugin.cts +3 -1
- package/src/iterateJsdoc.cts +9 -4
- package/dist/cjs/WarnSettings.js +0 -30
- package/dist/cjs/alignTransform.js +0 -285
- package/dist/cjs/defaultTagOrder.js +0 -152
- package/dist/cjs/exportParser.js +0 -754
- package/dist/cjs/getDefaultTagStructureForMode.js +0 -840
- package/dist/cjs/getJsdocProcessorPlugin.cjs +0 -4
- package/dist/cjs/getJsdocProcessorPlugin.js +0 -553
- package/dist/cjs/index-cjs.js +0 -492
- package/dist/cjs/index.cjs.cjs +0 -6
- package/dist/cjs/iterateJsdoc.cjs +0 -38
- package/dist/cjs/iterateJsdoc.js +0 -1981
- package/dist/cjs/jsdocUtils.js +0 -1470
- package/dist/cjs/rules/checkAccess.js +0 -35
- package/dist/cjs/rules/checkAlignment.js +0 -63
- package/dist/cjs/rules/checkExamples.js +0 -486
- package/dist/cjs/rules/checkIndentation.js +0 -66
- package/dist/cjs/rules/checkLineAlignment.js +0 -297
- package/dist/cjs/rules/checkParamNames.js +0 -320
- package/dist/cjs/rules/checkPropertyNames.js +0 -105
- package/dist/cjs/rules/checkSyntax.js +0 -27
- package/dist/cjs/rules/checkTagNames.js +0 -252
- package/dist/cjs/rules/checkTemplateNames.js +0 -189
- package/dist/cjs/rules/checkTypes.js +0 -421
- package/dist/cjs/rules/checkValues.js +0 -163
- package/dist/cjs/rules/convertToJsdocComments.js +0 -313
- package/dist/cjs/rules/emptyTags.js +0 -79
- package/dist/cjs/rules/implementsOnClasses.js +0 -63
- package/dist/cjs/rules/importsAsDependencies.js +0 -105
- package/dist/cjs/rules/informativeDocs.js +0 -153
- package/dist/cjs/rules/linesBeforeBlock.js +0 -106
- package/dist/cjs/rules/matchDescription.js +0 -240
- package/dist/cjs/rules/matchName.js +0 -122
- package/dist/cjs/rules/multilineBlocks.js +0 -339
- package/dist/cjs/rules/noBadBlocks.js +0 -88
- package/dist/cjs/rules/noBlankBlockDescriptions.js +0 -56
- package/dist/cjs/rules/noBlankBlocks.js +0 -41
- package/dist/cjs/rules/noDefaults.js +0 -84
- package/dist/cjs/rules/noMissingSyntax.js +0 -164
- package/dist/cjs/rules/noMultiAsterisks.js +0 -83
- package/dist/cjs/rules/noRestrictedSyntax.js +0 -75
- package/dist/cjs/rules/noTypes.js +0 -88
- package/dist/cjs/rules/noUndefinedTypes.js +0 -451
- package/dist/cjs/rules/requireAsteriskPrefix.js +0 -144
- package/dist/cjs/rules/requireDescription.js +0 -136
- package/dist/cjs/rules/requireDescriptionCompleteSentence.js +0 -258
- package/dist/cjs/rules/requireExample.js +0 -103
- package/dist/cjs/rules/requireFileOverview.js +0 -117
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +0 -144
- package/dist/cjs/rules/requireJsdoc.js +0 -629
- package/dist/cjs/rules/requireParam.js +0 -480
- package/dist/cjs/rules/requireParamDescription.js +0 -77
- package/dist/cjs/rules/requireParamName.js +0 -52
- package/dist/cjs/rules/requireParamType.js +0 -77
- package/dist/cjs/rules/requireProperty.js +0 -44
- package/dist/cjs/rules/requirePropertyDescription.js +0 -22
- package/dist/cjs/rules/requirePropertyName.js +0 -22
- package/dist/cjs/rules/requirePropertyType.js +0 -22
- package/dist/cjs/rules/requireReturns.js +0 -197
- package/dist/cjs/rules/requireReturnsCheck.js +0 -108
- package/dist/cjs/rules/requireReturnsDescription.js +0 -58
- package/dist/cjs/rules/requireReturnsType.js +0 -52
- package/dist/cjs/rules/requireTemplate.js +0 -173
- package/dist/cjs/rules/requireThrows.js +0 -101
- package/dist/cjs/rules/requireYields.js +0 -172
- package/dist/cjs/rules/requireYieldsCheck.js +0 -164
- package/dist/cjs/rules/sortTags.js +0 -392
- package/dist/cjs/rules/tagLines.js +0 -259
- package/dist/cjs/rules/textEscaping.js +0 -125
- package/dist/cjs/rules/typeFormatting.js +0 -328
- package/dist/cjs/rules/validTypes.js +0 -333
- package/dist/cjs/tagNames.js +0 -209
- package/dist/cjs/utils/hasReturnValue.js +0 -469
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {[string, boolean, () => RootNamerReturn]} RootNamerReturn
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @param {string[]} desiredRoots
|
|
12
|
-
* @param {number} currentIndex
|
|
13
|
-
* @returns {RootNamerReturn}
|
|
14
|
-
*/
|
|
15
|
-
const rootNamer = (desiredRoots, currentIndex) => {
|
|
16
|
-
/** @type {string} */
|
|
17
|
-
let name;
|
|
18
|
-
let idx = currentIndex;
|
|
19
|
-
const incremented = desiredRoots.length <= 1;
|
|
20
|
-
if (incremented) {
|
|
21
|
-
const base = desiredRoots[0];
|
|
22
|
-
const suffix = idx++;
|
|
23
|
-
name = `${base}${suffix}`;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
name = /** @type {string} */ (desiredRoots.shift());
|
|
27
|
-
}
|
|
28
|
-
return [
|
|
29
|
-
name,
|
|
30
|
-
incremented,
|
|
31
|
-
() => {
|
|
32
|
-
return rootNamer(desiredRoots, idx);
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
};
|
|
36
|
-
/* eslint-disable complexity -- Temporary */
|
|
37
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, jsdoc, utils, }) => {
|
|
38
|
-
/* eslint-enable complexity -- Temporary */
|
|
39
|
-
if (utils.avoidDocs()) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// Param type is specified by type in @type
|
|
43
|
-
if (utils.hasTag('type')) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const { autoIncrementBase = 0, checkDestructured = true, checkDestructuredRoots = true, checkRestProperty = false, checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/', enableFixer = true, enableRestElementFixer = true, enableRootFixer = true, ignoreWhenAllParamsMissing = false, unnamedRootBase = [
|
|
47
|
-
'root',
|
|
48
|
-
], useDefaultObjectProperties = false, } = context.options[0] || {};
|
|
49
|
-
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
50
|
-
tagName: 'param',
|
|
51
|
-
}));
|
|
52
|
-
if (!preferredTagName) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);
|
|
56
|
-
if (!functionParameterNames.length) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const jsdocParameterNames =
|
|
60
|
-
/**
|
|
61
|
-
* @type {{
|
|
62
|
-
* idx: import('../iterateJsdoc.js').Integer;
|
|
63
|
-
* name: string;
|
|
64
|
-
* type: string;
|
|
65
|
-
* }[]}
|
|
66
|
-
*/ (utils.getJsdocTagsDeep(preferredTagName));
|
|
67
|
-
if (ignoreWhenAllParamsMissing && !jsdocParameterNames.length) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const shallowJsdocParameterNames = jsdocParameterNames.filter((tag) => {
|
|
71
|
-
return !tag.name.includes('.');
|
|
72
|
-
}).map((tag, idx) => {
|
|
73
|
-
return {
|
|
74
|
-
...tag,
|
|
75
|
-
idx,
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
const checkTypesRegex = utils.getRegexFromString(checkTypesPattern);
|
|
79
|
-
/**
|
|
80
|
-
* @type {{
|
|
81
|
-
* functionParameterIdx: import('../iterateJsdoc.js').Integer,
|
|
82
|
-
* functionParameterName: string,
|
|
83
|
-
* inc: boolean|undefined,
|
|
84
|
-
* remove?: true,
|
|
85
|
-
* type?: string|undefined
|
|
86
|
-
* }[]}
|
|
87
|
-
*/
|
|
88
|
-
const missingTags = [];
|
|
89
|
-
const flattenedRoots = utils.flattenRoots(functionParameterNames).names;
|
|
90
|
-
/**
|
|
91
|
-
* @type {{
|
|
92
|
-
* [key: string]: import('../iterateJsdoc.js').Integer
|
|
93
|
-
* }}
|
|
94
|
-
*/
|
|
95
|
-
const paramIndex = {};
|
|
96
|
-
/**
|
|
97
|
-
* @param {string} cur
|
|
98
|
-
* @returns {boolean}
|
|
99
|
-
*/
|
|
100
|
-
const hasParamIndex = (cur) => {
|
|
101
|
-
return utils.dropPathSegmentQuotes(String(cur)) in paramIndex;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {string|number|undefined} cur
|
|
106
|
-
* @returns {import('../iterateJsdoc.js').Integer}
|
|
107
|
-
*/
|
|
108
|
-
const getParamIndex = (cur) => {
|
|
109
|
-
return paramIndex[utils.dropPathSegmentQuotes(String(cur))];
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* @param {string} cur
|
|
114
|
-
* @param {import('../iterateJsdoc.js').Integer} idx
|
|
115
|
-
* @returns {void}
|
|
116
|
-
*/
|
|
117
|
-
const setParamIndex = (cur, idx) => {
|
|
118
|
-
paramIndex[utils.dropPathSegmentQuotes(String(cur))] = idx;
|
|
119
|
-
};
|
|
120
|
-
for (const [idx, cur,] of flattenedRoots.entries()) {
|
|
121
|
-
setParamIndex(cur, idx);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* @param {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {
|
|
126
|
-
* newAdd?: boolean
|
|
127
|
-
* })[]} jsdocTags
|
|
128
|
-
* @param {import('../iterateJsdoc.js').Integer} indexAtFunctionParams
|
|
129
|
-
* @returns {import('../iterateJsdoc.js').Integer}
|
|
130
|
-
*/
|
|
131
|
-
const findExpectedIndex = (jsdocTags, indexAtFunctionParams) => {
|
|
132
|
-
const remainingRoots = functionParameterNames.slice(indexAtFunctionParams || 0);
|
|
133
|
-
const foundIndex = jsdocTags.findIndex(({ name, newAdd, }) => {
|
|
134
|
-
return !newAdd && remainingRoots.some((remainingRoot) => {
|
|
135
|
-
if (Array.isArray(remainingRoot)) {
|
|
136
|
-
return (
|
|
137
|
-
/**
|
|
138
|
-
* @type {import('../jsdocUtils.js').FlattendRootInfo & {
|
|
139
|
-
* annotationParamName?: string|undefined;
|
|
140
|
-
* }}
|
|
141
|
-
*/ (remainingRoot[1]).names.includes(name));
|
|
142
|
-
}
|
|
143
|
-
if (typeof remainingRoot === 'object') {
|
|
144
|
-
return name === remainingRoot.name;
|
|
145
|
-
}
|
|
146
|
-
return name === remainingRoot;
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
const tags = foundIndex > -1 ?
|
|
150
|
-
jsdocTags.slice(0, foundIndex) :
|
|
151
|
-
jsdocTags.filter(({ tag, }) => {
|
|
152
|
-
return tag === preferredTagName;
|
|
153
|
-
});
|
|
154
|
-
let tagLineCount = 0;
|
|
155
|
-
for (const { source, } of tags) {
|
|
156
|
-
for (const { tokens: { end, }, } of source) {
|
|
157
|
-
if (!end) {
|
|
158
|
-
tagLineCount++;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return tagLineCount;
|
|
163
|
-
};
|
|
164
|
-
let [nextRootName, incremented, namer,] = rootNamer([
|
|
165
|
-
...unnamedRootBase,
|
|
166
|
-
], autoIncrementBase);
|
|
167
|
-
const thisOffset = functionParameterNames[0] === 'this' ? 1 : 0;
|
|
168
|
-
for (const [functionParameterIdx, functionParameterName,] of functionParameterNames.entries()) {
|
|
169
|
-
let inc;
|
|
170
|
-
if (Array.isArray(functionParameterName)) {
|
|
171
|
-
const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset];
|
|
172
|
-
/** @type {string} */
|
|
173
|
-
let rootName;
|
|
174
|
-
if (functionParameterName[0]) {
|
|
175
|
-
rootName = functionParameterName[0];
|
|
176
|
-
}
|
|
177
|
-
else if (matchedJsdoc && matchedJsdoc.name) {
|
|
178
|
-
rootName = matchedJsdoc.name;
|
|
179
|
-
if (matchedJsdoc.type && matchedJsdoc.type.search(checkTypesRegex) === -1) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
rootName = nextRootName;
|
|
185
|
-
inc = incremented;
|
|
186
|
-
}
|
|
187
|
-
[
|
|
188
|
-
nextRootName,
|
|
189
|
-
incremented,
|
|
190
|
-
namer,
|
|
191
|
-
] = namer();
|
|
192
|
-
const { hasPropertyRest, hasRestElement, names, rests, } = /**
|
|
193
|
-
* @type {import('../jsdocUtils.js').FlattendRootInfo & {
|
|
194
|
-
* annotationParamName?: string | undefined;
|
|
195
|
-
* }}
|
|
196
|
-
*/ (functionParameterName[1]);
|
|
197
|
-
const notCheckingNames = [];
|
|
198
|
-
if (!enableRestElementFixer && hasRestElement) {
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
if (!checkDestructuredRoots) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
for (const [idx, paramName,] of names.entries()) {
|
|
205
|
-
// Add root if the root name is not in the docs (and is not already
|
|
206
|
-
// in the tags to be fixed)
|
|
207
|
-
if (!jsdocParameterNames.find(({ name, }) => {
|
|
208
|
-
return name === rootName;
|
|
209
|
-
}) && !missingTags.find(({ functionParameterName: fpn, }) => {
|
|
210
|
-
return fpn === rootName;
|
|
211
|
-
})) {
|
|
212
|
-
const emptyParamIdx = jsdocParameterNames.findIndex(({ name, }) => {
|
|
213
|
-
return !name;
|
|
214
|
-
});
|
|
215
|
-
if (emptyParamIdx > -1) {
|
|
216
|
-
missingTags.push({
|
|
217
|
-
functionParameterIdx: emptyParamIdx,
|
|
218
|
-
functionParameterName: rootName,
|
|
219
|
-
inc,
|
|
220
|
-
remove: true,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
missingTags.push({
|
|
225
|
-
functionParameterIdx: hasParamIndex(rootName) ?
|
|
226
|
-
getParamIndex(rootName) :
|
|
227
|
-
getParamIndex(paramName),
|
|
228
|
-
functionParameterName: rootName,
|
|
229
|
-
inc,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (!checkDestructured) {
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (!checkRestProperty && rests[idx]) {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
const fullParamName = `${rootName}.${paramName}`;
|
|
240
|
-
const notCheckingName = jsdocParameterNames.find(({ name, type: paramType, }) => {
|
|
241
|
-
return utils.comparePaths(name)(fullParamName) && paramType.search(checkTypesRegex) === -1 && paramType !== '';
|
|
242
|
-
});
|
|
243
|
-
if (notCheckingName !== undefined) {
|
|
244
|
-
notCheckingNames.push(notCheckingName.name);
|
|
245
|
-
}
|
|
246
|
-
if (notCheckingNames.find((name) => {
|
|
247
|
-
return fullParamName.startsWith(name);
|
|
248
|
-
})) {
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if (jsdocParameterNames && !jsdocParameterNames.find(({ name, }) => {
|
|
252
|
-
return utils.comparePaths(name)(fullParamName);
|
|
253
|
-
})) {
|
|
254
|
-
missingTags.push({
|
|
255
|
-
functionParameterIdx: getParamIndex(functionParameterName[0] ? fullParamName : paramName),
|
|
256
|
-
functionParameterName: fullParamName,
|
|
257
|
-
inc,
|
|
258
|
-
type: hasRestElement && !hasPropertyRest ? '{...any}' : undefined,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
/** @type {string} */
|
|
265
|
-
let funcParamName;
|
|
266
|
-
let type;
|
|
267
|
-
if (typeof functionParameterName === 'object') {
|
|
268
|
-
if (!enableRestElementFixer && functionParameterName.restElement) {
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
funcParamName = /** @type {string} */ (functionParameterName.name);
|
|
272
|
-
type = '{...any}';
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
funcParamName = /** @type {string} */ (functionParameterName);
|
|
276
|
-
}
|
|
277
|
-
if (jsdocParameterNames && !jsdocParameterNames.find(({ name, }) => {
|
|
278
|
-
return name === funcParamName;
|
|
279
|
-
}) && funcParamName !== 'this') {
|
|
280
|
-
missingTags.push({
|
|
281
|
-
functionParameterIdx: getParamIndex(funcParamName),
|
|
282
|
-
functionParameterName: funcParamName,
|
|
283
|
-
inc,
|
|
284
|
-
type,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
* @param {{
|
|
291
|
-
* functionParameterIdx: import('../iterateJsdoc.js').Integer,
|
|
292
|
-
* functionParameterName: string,
|
|
293
|
-
* remove?: true,
|
|
294
|
-
* inc?: boolean,
|
|
295
|
-
* type?: string
|
|
296
|
-
* }} cfg
|
|
297
|
-
*/
|
|
298
|
-
const fix = ({ functionParameterIdx, functionParameterName, inc, remove, type, }) => {
|
|
299
|
-
if (inc && !enableRootFixer) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
*
|
|
304
|
-
* @param {import('../iterateJsdoc.js').Integer} tagIndex
|
|
305
|
-
* @param {import('../iterateJsdoc.js').Integer} sourceIndex
|
|
306
|
-
* @param {import('../iterateJsdoc.js').Integer} spliceCount
|
|
307
|
-
* @returns {void}
|
|
308
|
-
*/
|
|
309
|
-
const createTokens = (tagIndex, sourceIndex, spliceCount) => {
|
|
310
|
-
// console.log(sourceIndex, tagIndex, jsdoc.tags, jsdoc.source);
|
|
311
|
-
const tokens = {
|
|
312
|
-
number: sourceIndex + 1,
|
|
313
|
-
source: '',
|
|
314
|
-
tokens: {
|
|
315
|
-
delimiter: '*',
|
|
316
|
-
description: '',
|
|
317
|
-
end: '',
|
|
318
|
-
lineEnd: '',
|
|
319
|
-
name: functionParameterName,
|
|
320
|
-
newAdd: true,
|
|
321
|
-
postDelimiter: ' ',
|
|
322
|
-
postName: '',
|
|
323
|
-
postTag: ' ',
|
|
324
|
-
postType: type ? ' ' : '',
|
|
325
|
-
start: jsdoc.source[sourceIndex].tokens.start,
|
|
326
|
-
tag: `@${preferredTagName}`,
|
|
327
|
-
type: type ?? '',
|
|
328
|
-
},
|
|
329
|
-
};
|
|
330
|
-
/**
|
|
331
|
-
* @type {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {
|
|
332
|
-
* newAdd?: true
|
|
333
|
-
* })[]}
|
|
334
|
-
*/ (jsdoc.tags).splice(tagIndex, spliceCount, {
|
|
335
|
-
description: '',
|
|
336
|
-
inlineTags: [],
|
|
337
|
-
name: functionParameterName,
|
|
338
|
-
newAdd: true,
|
|
339
|
-
optional: false,
|
|
340
|
-
problems: [],
|
|
341
|
-
source: [
|
|
342
|
-
tokens,
|
|
343
|
-
],
|
|
344
|
-
tag: preferredTagName,
|
|
345
|
-
type: type ?? '',
|
|
346
|
-
});
|
|
347
|
-
const firstNumber = jsdoc.source[0].number;
|
|
348
|
-
jsdoc.source.splice(sourceIndex, spliceCount, tokens);
|
|
349
|
-
for (const [idx, src,] of jsdoc.source.slice(sourceIndex).entries()) {
|
|
350
|
-
src.number = firstNumber + sourceIndex + idx;
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
const offset = jsdoc.source.findIndex(({ tokens: { end, tag, }, }) => {
|
|
354
|
-
return tag || end;
|
|
355
|
-
});
|
|
356
|
-
if (remove) {
|
|
357
|
-
createTokens(functionParameterIdx, offset + functionParameterIdx, 1);
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
const expectedIdx = findExpectedIndex(jsdoc.tags, functionParameterIdx);
|
|
361
|
-
createTokens(expectedIdx, offset + expectedIdx, 0);
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
/**
|
|
365
|
-
* @returns {void}
|
|
366
|
-
*/
|
|
367
|
-
const fixer = () => {
|
|
368
|
-
for (const missingTag of missingTags) {
|
|
369
|
-
fix(missingTag);
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
if (missingTags.length && jsdoc.source.length === 1) {
|
|
373
|
-
utils.makeMultiline();
|
|
374
|
-
}
|
|
375
|
-
for (const { functionParameterName, } of missingTags) {
|
|
376
|
-
utils.reportJSDoc(`Missing JSDoc @${preferredTagName} "${functionParameterName}" declaration.`, null, enableFixer ? fixer : null);
|
|
377
|
-
}
|
|
378
|
-
}, {
|
|
379
|
-
contextDefaults: true,
|
|
380
|
-
meta: {
|
|
381
|
-
docs: {
|
|
382
|
-
description: 'Requires that all function parameters are documented.',
|
|
383
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md#repos-sticky-header',
|
|
384
|
-
},
|
|
385
|
-
fixable: 'code',
|
|
386
|
-
schema: [
|
|
387
|
-
{
|
|
388
|
-
additionalProperties: false,
|
|
389
|
-
properties: {
|
|
390
|
-
autoIncrementBase: {
|
|
391
|
-
default: 0,
|
|
392
|
-
type: 'integer',
|
|
393
|
-
},
|
|
394
|
-
checkConstructors: {
|
|
395
|
-
default: true,
|
|
396
|
-
type: 'boolean',
|
|
397
|
-
},
|
|
398
|
-
checkDestructured: {
|
|
399
|
-
default: true,
|
|
400
|
-
type: 'boolean',
|
|
401
|
-
},
|
|
402
|
-
checkDestructuredRoots: {
|
|
403
|
-
default: true,
|
|
404
|
-
type: 'boolean',
|
|
405
|
-
},
|
|
406
|
-
checkGetters: {
|
|
407
|
-
default: false,
|
|
408
|
-
type: 'boolean',
|
|
409
|
-
},
|
|
410
|
-
checkRestProperty: {
|
|
411
|
-
default: false,
|
|
412
|
-
type: 'boolean',
|
|
413
|
-
},
|
|
414
|
-
checkSetters: {
|
|
415
|
-
default: false,
|
|
416
|
-
type: 'boolean',
|
|
417
|
-
},
|
|
418
|
-
checkTypesPattern: {
|
|
419
|
-
type: 'string',
|
|
420
|
-
},
|
|
421
|
-
contexts: {
|
|
422
|
-
items: {
|
|
423
|
-
anyOf: [
|
|
424
|
-
{
|
|
425
|
-
type: 'string',
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
additionalProperties: false,
|
|
429
|
-
properties: {
|
|
430
|
-
comment: {
|
|
431
|
-
type: 'string',
|
|
432
|
-
},
|
|
433
|
-
context: {
|
|
434
|
-
type: 'string',
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
type: 'object',
|
|
438
|
-
},
|
|
439
|
-
],
|
|
440
|
-
},
|
|
441
|
-
type: 'array',
|
|
442
|
-
},
|
|
443
|
-
enableFixer: {
|
|
444
|
-
type: 'boolean',
|
|
445
|
-
},
|
|
446
|
-
enableRestElementFixer: {
|
|
447
|
-
type: 'boolean',
|
|
448
|
-
},
|
|
449
|
-
enableRootFixer: {
|
|
450
|
-
type: 'boolean',
|
|
451
|
-
},
|
|
452
|
-
exemptedBy: {
|
|
453
|
-
items: {
|
|
454
|
-
type: 'string',
|
|
455
|
-
},
|
|
456
|
-
type: 'array',
|
|
457
|
-
},
|
|
458
|
-
ignoreWhenAllParamsMissing: {
|
|
459
|
-
type: 'boolean',
|
|
460
|
-
},
|
|
461
|
-
unnamedRootBase: {
|
|
462
|
-
items: {
|
|
463
|
-
type: 'string',
|
|
464
|
-
},
|
|
465
|
-
type: 'array',
|
|
466
|
-
},
|
|
467
|
-
useDefaultObjectProperties: {
|
|
468
|
-
type: 'boolean',
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
type: 'object',
|
|
472
|
-
},
|
|
473
|
-
],
|
|
474
|
-
type: 'suggestion',
|
|
475
|
-
},
|
|
476
|
-
// We cannot cache comment nodes as the contexts may recur with the
|
|
477
|
-
// same comment node but a different JS node, and we may need the different
|
|
478
|
-
// JS node to ensure we iterate its context
|
|
479
|
-
noTracking: true,
|
|
480
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, report, settings, utils, }) => {
|
|
8
|
-
const { defaultDestructuredRootDescription = 'The root object', setDefaultDestructuredRootDescription = false, } = context.options[0] || {};
|
|
9
|
-
const functionParameterNames = utils.getFunctionParameterNames();
|
|
10
|
-
let rootCount = -1;
|
|
11
|
-
utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => {
|
|
12
|
-
rootCount += jsdocParameter.name.includes('.') ? 0 : 1;
|
|
13
|
-
if (!jsdocParameter.description.trim()) {
|
|
14
|
-
if (Array.isArray(functionParameterNames[rootCount])) {
|
|
15
|
-
if (settings.exemptDestructuredRootsFromChecks) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (setDefaultDestructuredRootDescription) {
|
|
19
|
-
utils.reportJSDoc(`Missing root description for @${targetTagName}.`, jsdocParameter, () => {
|
|
20
|
-
utils.changeTag(jsdocParameter, {
|
|
21
|
-
description: defaultDestructuredRootDescription,
|
|
22
|
-
postName: ' ',
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
report(`Missing JSDoc @${targetTagName} "${jsdocParameter.name}" description.`, null, jsdocParameter);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}, {
|
|
32
|
-
contextDefaults: true,
|
|
33
|
-
meta: {
|
|
34
|
-
docs: {
|
|
35
|
-
description: 'Requires that each `@param` tag has a `description` value.',
|
|
36
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md#repos-sticky-header',
|
|
37
|
-
},
|
|
38
|
-
fixable: 'code',
|
|
39
|
-
schema: [
|
|
40
|
-
{
|
|
41
|
-
additionalProperties: false,
|
|
42
|
-
properties: {
|
|
43
|
-
contexts: {
|
|
44
|
-
items: {
|
|
45
|
-
anyOf: [
|
|
46
|
-
{
|
|
47
|
-
type: 'string',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
additionalProperties: false,
|
|
51
|
-
properties: {
|
|
52
|
-
comment: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
},
|
|
55
|
-
context: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
type: 'object',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
type: 'array',
|
|
64
|
-
},
|
|
65
|
-
defaultDestructuredRootDescription: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
},
|
|
68
|
-
setDefaultDestructuredRootDescription: {
|
|
69
|
-
type: 'boolean',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
type: 'object',
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
type: 'suggestion',
|
|
76
|
-
},
|
|
77
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => {
|
|
9
|
-
if (jsdocParameter.tag && jsdocParameter.name === '') {
|
|
10
|
-
report(`There must be an identifier after @${targetTagName} ${jsdocParameter.type === '' ? 'type' : 'tag'}.`, null, jsdocParameter);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, {
|
|
14
|
-
contextDefaults: true,
|
|
15
|
-
meta: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Requires that all function parameters have names.',
|
|
18
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-name.md#repos-sticky-header',
|
|
19
|
-
},
|
|
20
|
-
schema: [
|
|
21
|
-
{
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
properties: {
|
|
24
|
-
contexts: {
|
|
25
|
-
items: {
|
|
26
|
-
anyOf: [
|
|
27
|
-
{
|
|
28
|
-
type: 'string',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
additionalProperties: false,
|
|
32
|
-
properties: {
|
|
33
|
-
comment: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
},
|
|
36
|
-
context: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
type: 'object',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
type: 'array',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
type: 'object',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
type: 'suggestion',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, report, settings, utils, }) => {
|
|
8
|
-
const { defaultDestructuredRootType = 'object', setDefaultDestructuredRootType = false, } = context.options[0] || {};
|
|
9
|
-
const functionParameterNames = utils.getFunctionParameterNames();
|
|
10
|
-
let rootCount = -1;
|
|
11
|
-
utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => {
|
|
12
|
-
rootCount += jsdocParameter.name.includes('.') ? 0 : 1;
|
|
13
|
-
if (!jsdocParameter.type) {
|
|
14
|
-
if (Array.isArray(functionParameterNames[rootCount])) {
|
|
15
|
-
if (settings.exemptDestructuredRootsFromChecks) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (setDefaultDestructuredRootType) {
|
|
19
|
-
utils.reportJSDoc(`Missing root type for @${targetTagName}.`, jsdocParameter, () => {
|
|
20
|
-
utils.changeTag(jsdocParameter, {
|
|
21
|
-
postType: ' ',
|
|
22
|
-
type: `{${defaultDestructuredRootType}}`,
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
report(`Missing JSDoc @${targetTagName} "${jsdocParameter.name}" type.`, null, jsdocParameter);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}, {
|
|
32
|
-
contextDefaults: true,
|
|
33
|
-
meta: {
|
|
34
|
-
docs: {
|
|
35
|
-
description: 'Requires that each `@param` tag has a `type` value.',
|
|
36
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md#repos-sticky-header',
|
|
37
|
-
},
|
|
38
|
-
fixable: 'code',
|
|
39
|
-
schema: [
|
|
40
|
-
{
|
|
41
|
-
additionalProperties: false,
|
|
42
|
-
properties: {
|
|
43
|
-
contexts: {
|
|
44
|
-
items: {
|
|
45
|
-
anyOf: [
|
|
46
|
-
{
|
|
47
|
-
type: 'string',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
additionalProperties: false,
|
|
51
|
-
properties: {
|
|
52
|
-
comment: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
},
|
|
55
|
-
context: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
type: 'object',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
type: 'array',
|
|
64
|
-
},
|
|
65
|
-
defaultDestructuredRootType: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
},
|
|
68
|
-
setDefaultDestructuredRootType: {
|
|
69
|
-
type: 'boolean',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
type: 'object',
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
type: 'suggestion',
|
|
76
|
-
},
|
|
77
|
-
});
|