eslint-plugin-jsdoc 44.2.3 → 44.2.4
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.js +86 -4
- package/dist/alignTransform.js.map +1 -1
- package/dist/exportParser.js +134 -4
- package/dist/exportParser.js.map +1 -1
- package/dist/iterateJsdoc.js +936 -345
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +173 -105
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/checkAlignment.js +6 -0
- package/dist/rules/checkAlignment.js.map +1 -1
- package/dist/rules/checkExamples.js +70 -6
- package/dist/rules/checkExamples.js.map +1 -1
- package/dist/rules/checkIndentation.js +11 -1
- package/dist/rules/checkIndentation.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +68 -4
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/checkParamNames.js +12 -7
- package/dist/rules/checkParamNames.js.map +1 -1
- package/dist/rules/checkPropertyNames.js +13 -7
- package/dist/rules/checkPropertyNames.js.map +1 -1
- package/dist/rules/checkTagNames.js +45 -5
- package/dist/rules/checkTagNames.js.map +1 -1
- package/dist/rules/checkTypes.js +97 -36
- package/dist/rules/checkTypes.js.map +1 -1
- package/dist/rules/checkValues.js +6 -6
- package/dist/rules/checkValues.js.map +1 -1
- package/dist/rules/emptyTags.js +8 -1
- package/dist/rules/emptyTags.js.map +1 -1
- package/dist/rules/informativeDocs.js +26 -7
- package/dist/rules/informativeDocs.js.map +1 -1
- package/dist/rules/matchDescription.js +18 -1
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/matchName.js +2 -2
- package/dist/rules/matchName.js.map +1 -1
- package/dist/rules/multilineBlocks.js +12 -1
- package/dist/rules/multilineBlocks.js.map +1 -1
- package/dist/rules/noBadBlocks.js +3 -5
- package/dist/rules/noBadBlocks.js.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +2 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
- package/dist/rules/noMissingSyntax.js +58 -15
- package/dist/rules/noMissingSyntax.js.map +1 -1
- package/dist/rules/noMultiAsterisks.js +1 -6
- package/dist/rules/noMultiAsterisks.js.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +17 -4
- package/dist/rules/noRestrictedSyntax.js.map +1 -1
- package/dist/rules/noTypes.js +3 -0
- package/dist/rules/noTypes.js.map +1 -1
- package/dist/rules/noUndefinedTypes.js +61 -20
- package/dist/rules/noUndefinedTypes.js.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +20 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -1
- package/dist/rules/requireDescription.js +6 -2
- package/dist/rules/requireDescription.js.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +72 -9
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
- package/dist/rules/requireFileOverview.js +9 -4
- package/dist/rules/requireFileOverview.js.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +23 -6
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
- package/dist/rules/requireJsdoc.js +144 -28
- package/dist/rules/requireJsdoc.js.map +1 -1
- package/dist/rules/requireParam.js +46 -2
- package/dist/rules/requireParam.js.map +1 -1
- package/dist/rules/requireProperty.js +1 -1
- package/dist/rules/requireProperty.js.map +1 -1
- package/dist/rules/requireReturns.js +2 -2
- package/dist/rules/requireReturns.js.map +1 -1
- package/dist/rules/requireReturnsCheck.js +9 -2
- package/dist/rules/requireReturnsCheck.js.map +1 -1
- package/dist/rules/requireThrows.js +2 -2
- package/dist/rules/requireThrows.js.map +1 -1
- package/dist/rules/requireYields.js +9 -2
- package/dist/rules/requireYields.js.map +1 -1
- package/dist/rules/requireYieldsCheck.js +19 -5
- package/dist/rules/requireYieldsCheck.js.map +1 -1
- package/dist/rules/sortTags.js +67 -9
- package/dist/rules/sortTags.js.map +1 -1
- package/dist/rules/tagLines.js +22 -3
- package/dist/rules/tagLines.js.map +1 -1
- package/dist/rules/textEscaping.js +16 -2
- package/dist/rules/textEscaping.js.map +1 -1
- package/dist/rules/validTypes.js +25 -8
- package/dist/rules/validTypes.js.map +1 -1
- package/dist/utils/hasReturnValue.js +77 -43
- package/dist/utils/hasReturnValue.js.map +1 -1
- package/docs/rules/check-tag-names.md +15 -0
- package/docs/rules/no-missing-syntax.md +6 -0
- package/docs/rules/require-description-complete-sentence.md +525 -289
- package/docs/rules/require-description.md +289 -525
- package/docs/rules/require-file-overview.md +7 -0
- package/docs/rules/require-jsdoc.md +1 -1
- package/docs/rules/require-param-description.md +116 -1694
- package/docs/rules/require-param-name.md +58 -133
- package/docs/rules/require-param-type.md +119 -55
- package/docs/rules/require-param.md +1700 -111
- package/docs/rules/require-property-description.md +39 -79
- package/docs/rules/require-property-name.md +21 -30
- package/docs/rules/require-property-type.md +21 -21
- package/docs/rules/require-property.md +82 -33
- package/docs/rules/require-returns-check.md +636 -747
- package/docs/rules/require-returns-description.md +61 -933
- package/docs/rules/require-returns-type.md +42 -79
- package/docs/rules/require-returns.md +1081 -61
- package/docs/rules/require-yields-check.md +238 -517
- package/docs/rules/require-yields.md +517 -238
- package/docs/rules/valid-types.md +1 -1
- package/docs/settings.md +1 -1
- package/package.json +5 -4
- package/tsconfig.json +2 -3
package/dist/iterateJsdoc.js
CHANGED
|
@@ -19,6 +19,527 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
* @typedef {number} Integer
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* disallowName?: string,
|
|
25
|
+
* allowName?: string,
|
|
26
|
+
* context?: string,
|
|
27
|
+
* comment?: string,
|
|
28
|
+
* tags?: string[],
|
|
29
|
+
* replacement?: string,
|
|
30
|
+
* minimum?: Integer,
|
|
31
|
+
* message?: string
|
|
32
|
+
* }} ContextObject
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {string|ContextObject} Context
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @callback CheckJsdoc
|
|
40
|
+
* @param {{
|
|
41
|
+
* lastIndex?: Integer,
|
|
42
|
+
* isFunctionContext?: boolean,
|
|
43
|
+
* selector?: string
|
|
44
|
+
* }} info
|
|
45
|
+
* @param {null|((jsdoc: import('comment-parser').Block) => boolean|undefined)} handler
|
|
46
|
+
* @param {import('eslint').Rule.Node} node
|
|
47
|
+
* @returns {void}
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @callback ForEachPreferredTag
|
|
52
|
+
* @param {string} tagName
|
|
53
|
+
* @param {(
|
|
54
|
+
* matchingJsdocTag: import('comment-parser').Spec & {
|
|
55
|
+
* line: Integer
|
|
56
|
+
* },
|
|
57
|
+
* targetTagName: string
|
|
58
|
+
* ) => void} arrayHandler
|
|
59
|
+
* @param {boolean} [skipReportingBlockedTag]
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @callback ReportSettings
|
|
65
|
+
* @param {string} message
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @callback ParseClosureTemplateTag
|
|
71
|
+
* @param {import('comment-parser').Spec} tag
|
|
72
|
+
* @returns {string[]}
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @callback GetPreferredTagNameObject
|
|
77
|
+
* @param {{
|
|
78
|
+
* tagName: string
|
|
79
|
+
* }} cfg
|
|
80
|
+
* @returns {string|false|{
|
|
81
|
+
* message: string;
|
|
82
|
+
* replacement?: string|undefined
|
|
83
|
+
* }|{
|
|
84
|
+
* blocked: true,
|
|
85
|
+
* tagName: string
|
|
86
|
+
* }}
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {{
|
|
91
|
+
* forEachPreferredTag: ForEachPreferredTag,
|
|
92
|
+
* reportSettings: ReportSettings,
|
|
93
|
+
* parseClosureTemplateTag: ParseClosureTemplateTag,
|
|
94
|
+
* getPreferredTagNameObject: GetPreferredTagNameObject,
|
|
95
|
+
* pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith
|
|
96
|
+
* }} BasicUtils
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @callback IsIteratingFunction
|
|
101
|
+
* @returns {boolean}
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @callback IsVirtualFunction
|
|
106
|
+
* @returns {boolean}
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @callback Stringify
|
|
111
|
+
* @param {import('comment-parser').Block} tagBlock
|
|
112
|
+
* @param {boolean} [specRewire]
|
|
113
|
+
* @returns {string}
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/* eslint-disable jsdoc/valid-types -- Old version */
|
|
117
|
+
/**
|
|
118
|
+
* @callback ReportJSDoc
|
|
119
|
+
* @param {string} msg
|
|
120
|
+
* @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag]
|
|
121
|
+
* @param {(() => void)|null} [handler]
|
|
122
|
+
* @param {boolean} [specRewire]
|
|
123
|
+
* @param {undefined|{
|
|
124
|
+
* [key: string]: string
|
|
125
|
+
* }} [data]
|
|
126
|
+
*/
|
|
127
|
+
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @callback GetRegexFromString
|
|
131
|
+
* @param {string} str
|
|
132
|
+
* @param {string} [requiredFlags]
|
|
133
|
+
* @returns {RegExp}
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @callback GetTagDescription
|
|
138
|
+
* @param {import('comment-parser').Spec} tg
|
|
139
|
+
* @param {boolean} [returnArray]
|
|
140
|
+
* @returns {string[]|string}
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @callback SetTagDescription
|
|
145
|
+
* @param {import('comment-parser').Spec} tg
|
|
146
|
+
* @param {RegExp} matcher
|
|
147
|
+
* @param {(description: string) => string} setter
|
|
148
|
+
* @returns {Integer}
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @callback GetDescription
|
|
153
|
+
* @returns {{
|
|
154
|
+
* description: string,
|
|
155
|
+
* descriptions: string[],
|
|
156
|
+
* lastDescriptionLine: Integer
|
|
157
|
+
* }}
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/* eslint-disable jsdoc/no-undefined-types -- Bug */
|
|
161
|
+
/**
|
|
162
|
+
* @callback SetBlockDescription
|
|
163
|
+
* @param {(
|
|
164
|
+
* info: {
|
|
165
|
+
* delimiter: string,
|
|
166
|
+
* postDelimiter: string,
|
|
167
|
+
* start: string
|
|
168
|
+
* },
|
|
169
|
+
* seedTokens: (
|
|
170
|
+
* tokens?: Partial<import('comment-parser').Tokens>
|
|
171
|
+
* ) => import('comment-parser').Tokens,
|
|
172
|
+
* descLines: string[]
|
|
173
|
+
* ) => import('comment-parser').Line[]} setter
|
|
174
|
+
* @returns {void}
|
|
175
|
+
*/
|
|
176
|
+
/* eslint-enable jsdoc/no-undefined-types -- Bug */
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @callback SetDescriptionLines
|
|
180
|
+
* @param {RegExp} matcher
|
|
181
|
+
* @param {(description: string) => string} setter
|
|
182
|
+
* @returns {Integer}
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/* eslint-disable jsdoc/no-undefined-types -- TS */
|
|
186
|
+
/**
|
|
187
|
+
* @callback ChangeTag
|
|
188
|
+
* @param {import('comment-parser').Spec} tag
|
|
189
|
+
* @param {...Partial<import('comment-parser').Tokens>} tokens
|
|
190
|
+
* @returns {void}
|
|
191
|
+
*/
|
|
192
|
+
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
193
|
+
|
|
194
|
+
/* eslint-disable jsdoc/no-undefined-types -- TS */
|
|
195
|
+
/**
|
|
196
|
+
* @callback SetTag
|
|
197
|
+
* @param {import('comment-parser').Spec & {
|
|
198
|
+
* line: Integer
|
|
199
|
+
* }} tag
|
|
200
|
+
* @param {Partial<import('comment-parser').Tokens>} [tokens]
|
|
201
|
+
* @returns {void}
|
|
202
|
+
*/
|
|
203
|
+
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @callback RemoveTag
|
|
207
|
+
* @param {Integer} tagIndex
|
|
208
|
+
* @param {{
|
|
209
|
+
* removeEmptyBlock?: boolean,
|
|
210
|
+
* tagSourceOffset?: Integer
|
|
211
|
+
* }} [cfg]
|
|
212
|
+
* @returns {void}
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @callback AddTag
|
|
217
|
+
* @param {string} targetTagName
|
|
218
|
+
* @param {Integer} [number]
|
|
219
|
+
* @param {import('comment-parser').Tokens|{}} [tokens]
|
|
220
|
+
* @returns {void}
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @callback GetFirstLine
|
|
225
|
+
* @returns {Integer|undefined}
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
/* eslint-disable jsdoc/no-undefined-types -- TS */
|
|
229
|
+
/**
|
|
230
|
+
* @typedef {(
|
|
231
|
+
* tokens?: Partial<import('comment-parser').Tokens> | undefined
|
|
232
|
+
* ) => import('comment-parser').Tokens} SeedTokens
|
|
233
|
+
*/
|
|
234
|
+
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Sets tokens to empty string.
|
|
238
|
+
*
|
|
239
|
+
* @callback EmptyTokens
|
|
240
|
+
* @param {import('comment-parser').Tokens} tokens
|
|
241
|
+
* @returns {void}
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
/* eslint-disable jsdoc/no-undefined-types -- TS */
|
|
245
|
+
/**
|
|
246
|
+
* @callback AddLine
|
|
247
|
+
* @param {Integer} sourceIndex
|
|
248
|
+
* @param {Partial<import('comment-parser').Tokens>} tokens
|
|
249
|
+
* @returns {void}
|
|
250
|
+
*/
|
|
251
|
+
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @callback AddLines
|
|
255
|
+
* @param {Integer} tagIndex
|
|
256
|
+
* @param {Integer} tagSourceOffset
|
|
257
|
+
* @param {Integer} numLines
|
|
258
|
+
* @returns {void}
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @callback MakeMultiline
|
|
263
|
+
* @returns {void}
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @callback GetFunctionParameterNames
|
|
268
|
+
* @param {boolean} [useDefaultObjectProperties]
|
|
269
|
+
* @returns {import('./jsdocUtils.js').ParamNameInfo[]}
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @callback HasParams
|
|
274
|
+
* @returns {Integer}
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @callback IsGenerator
|
|
279
|
+
* @returns {boolean}
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @callback IsConstructor
|
|
284
|
+
* @returns {boolean}
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @callback GetJsdocTagsDeep
|
|
289
|
+
* @param {string} tagName
|
|
290
|
+
* @returns {false|{
|
|
291
|
+
* idx: Integer,
|
|
292
|
+
* name: string,
|
|
293
|
+
* type: string
|
|
294
|
+
* }[]}
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @callback GetPreferredTagName
|
|
299
|
+
* @param {{
|
|
300
|
+
* tagName: string,
|
|
301
|
+
* skipReportingBlockedTag?: boolean,
|
|
302
|
+
* allowObjectReturn?: boolean,
|
|
303
|
+
* defaultMessage?: string
|
|
304
|
+
* }} cfg
|
|
305
|
+
* @returns {string|undefined|false|{
|
|
306
|
+
* message: string;
|
|
307
|
+
* replacement?: string|undefined;
|
|
308
|
+
* }|{
|
|
309
|
+
* blocked: true,
|
|
310
|
+
* tagName: string
|
|
311
|
+
* }}
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @callback IsValidTag
|
|
316
|
+
* @param {string} name
|
|
317
|
+
* @param {string[]} definedTags
|
|
318
|
+
* @returns {boolean}
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @callback HasATag
|
|
323
|
+
* @param {string[]} names
|
|
324
|
+
* @returns {boolean}
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @callback HasTag
|
|
329
|
+
* @param {string} name
|
|
330
|
+
* @returns {boolean}
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @callback ComparePaths
|
|
335
|
+
* @param {string} name
|
|
336
|
+
* @returns {(otherPathName: string) => void}
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @callback DropPathSegmentQuotes
|
|
341
|
+
* @param {string} name
|
|
342
|
+
* @returns {string}
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @callback AvoidDocs
|
|
347
|
+
* @returns {boolean}
|
|
348
|
+
*/
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @callback TagMightHaveNamePositionTypePosition
|
|
352
|
+
* @param {string} tagName
|
|
353
|
+
* @param {import('./getDefaultTagStructureForMode.js').
|
|
354
|
+
* TagStructure[]} [otherModeMaps]
|
|
355
|
+
* @returns {boolean|{otherMode: true}}
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @callback TagMustHave
|
|
360
|
+
* @param {string} tagName
|
|
361
|
+
* @param {import('./getDefaultTagStructureForMode.js').
|
|
362
|
+
* TagStructure[]} otherModeMaps
|
|
363
|
+
* @returns {boolean|{
|
|
364
|
+
* otherMode: false
|
|
365
|
+
* }}
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @callback TagMissingRequiredTypeOrNamepath
|
|
370
|
+
* @param {import('comment-parser').Spec} tag
|
|
371
|
+
* @param {import('./getDefaultTagStructureForMode.js').
|
|
372
|
+
* TagStructure[]} otherModeMaps
|
|
373
|
+
* @returns {boolean|{
|
|
374
|
+
* otherMode: false
|
|
375
|
+
* }}
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @callback IsNamepathX
|
|
380
|
+
* @param {string} tagName
|
|
381
|
+
* @returns {boolean}
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @callback GetTagStructureForMode
|
|
386
|
+
* @param {import('./jsdocUtils.js').ParserMode} mde
|
|
387
|
+
* @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @callback MayBeUndefinedTypeTag
|
|
392
|
+
* @param {import('comment-parser').Spec} tag
|
|
393
|
+
* @returns {boolean}
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @callback HasValueOrExecutorHasNonEmptyResolveValue
|
|
398
|
+
* @param {boolean} anyPromiseAsReturn
|
|
399
|
+
* @param {boolean} [allBranches]
|
|
400
|
+
* @returns {boolean}
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @callback HasYieldValue
|
|
405
|
+
* @returns {boolean}
|
|
406
|
+
*/
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @callback HasYieldReturnValue
|
|
410
|
+
* @returns {boolean}
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* @callback HasThrowValue
|
|
415
|
+
* @returns {boolean}
|
|
416
|
+
*/
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @callback IsAsync
|
|
420
|
+
* @returns {boolean|undefined}
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @callback GetTags
|
|
425
|
+
* @param {string} tagName
|
|
426
|
+
* @returns {import('comment-parser').Spec[]}
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @callback GetPresentTags
|
|
431
|
+
* @param {string[]} tagList
|
|
432
|
+
* @returns {import('comment-parser').Spec[]}
|
|
433
|
+
*/
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @callback FilterTags
|
|
437
|
+
* @param {(tag: import('comment-parser').Spec) => boolean} filter
|
|
438
|
+
* @returns {import('comment-parser').Spec[]}
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* @callback FilterAllTags
|
|
443
|
+
* @param {(tag: (import('comment-parser').Spec|
|
|
444
|
+
* import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter
|
|
445
|
+
* @returns {(import('comment-parser').Spec|
|
|
446
|
+
* import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
|
|
447
|
+
*/
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @callback GetTagsByType
|
|
451
|
+
* @param {import('comment-parser').Spec[]} tags
|
|
452
|
+
* @returns {{
|
|
453
|
+
* tagsWithNames: import('comment-parser').Spec[],
|
|
454
|
+
* tagsWithoutNames: import('comment-parser').Spec[]
|
|
455
|
+
* }}
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* @callback HasOptionTag
|
|
460
|
+
* @param {string} tagName
|
|
461
|
+
* @returns {boolean}
|
|
462
|
+
*/
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @callback GetClassNode
|
|
466
|
+
* @returns {Node|null}
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @callback GetClassJsdoc
|
|
471
|
+
* @returns {null|import('comment-parser').Block & {
|
|
472
|
+
* inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
|
|
473
|
+
* }}
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @callback ClassHasTag
|
|
478
|
+
* @param {string} tagName
|
|
479
|
+
* @returns {boolean}
|
|
480
|
+
*/
|
|
481
|
+
/**
|
|
482
|
+
* @typedef {BasicUtils & {
|
|
483
|
+
* isIteratingFunction: IsIteratingFunction,
|
|
484
|
+
* isVirtualFunction: IsVirtualFunction,
|
|
485
|
+
* stringify: Stringify,
|
|
486
|
+
* reportJSDoc: ReportJSDoc,
|
|
487
|
+
* getRegexFromString: GetRegexFromString,
|
|
488
|
+
* getTagDescription: GetTagDescription,
|
|
489
|
+
* setTagDescription: SetTagDescription,
|
|
490
|
+
* getDescription: GetDescription,
|
|
491
|
+
* setBlockDescription: SetBlockDescription,
|
|
492
|
+
* setDescriptionLines: SetDescriptionLines,
|
|
493
|
+
* changeTag: ChangeTag,
|
|
494
|
+
* setTag: SetTag,
|
|
495
|
+
* removeTag: RemoveTag,
|
|
496
|
+
* addTag: AddTag,
|
|
497
|
+
* getFirstLine: GetFirstLine,
|
|
498
|
+
* seedTokens: SeedTokens,
|
|
499
|
+
* emptyTokens: EmptyTokens,
|
|
500
|
+
* addLine: AddLine,
|
|
501
|
+
* addLines: AddLines,
|
|
502
|
+
* makeMultiline: MakeMultiline,
|
|
503
|
+
* flattenRoots: import('./jsdocUtils.js').FlattenRoots,
|
|
504
|
+
* getFunctionParameterNames: GetFunctionParameterNames,
|
|
505
|
+
* hasParams: HasParams,
|
|
506
|
+
* isGenerator: IsGenerator,
|
|
507
|
+
* isConstructor: IsConstructor,
|
|
508
|
+
* getJsdocTagsDeep: GetJsdocTagsDeep,
|
|
509
|
+
* getPreferredTagName: GetPreferredTagName,
|
|
510
|
+
* isValidTag: IsValidTag,
|
|
511
|
+
* hasATag: HasATag,
|
|
512
|
+
* hasTag: HasTag,
|
|
513
|
+
* comparePaths: ComparePaths,
|
|
514
|
+
* dropPathSegmentQuotes: DropPathSegmentQuotes,
|
|
515
|
+
* avoidDocs: AvoidDocs,
|
|
516
|
+
* tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition,
|
|
517
|
+
* tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition,
|
|
518
|
+
* tagMustHaveNamePosition: TagMustHave,
|
|
519
|
+
* tagMustHaveTypePosition: TagMustHave,
|
|
520
|
+
* tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath,
|
|
521
|
+
* isNamepathDefiningTag: IsNamepathX,
|
|
522
|
+
* isNamepathReferencingTag: IsNamepathX,
|
|
523
|
+
* isNamepathOrUrlReferencingTag: IsNamepathX,
|
|
524
|
+
* tagMightHaveNamepath: IsNamepathX,
|
|
525
|
+
* getTagStructureForMode: GetTagStructureForMode,
|
|
526
|
+
* mayBeUndefinedTypeTag: MayBeUndefinedTypeTag,
|
|
527
|
+
* hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue,
|
|
528
|
+
* hasYieldValue: HasYieldValue,
|
|
529
|
+
* hasYieldReturnValue: HasYieldReturnValue,
|
|
530
|
+
* hasThrowValue: HasThrowValue,
|
|
531
|
+
* isAsync: IsAsync,
|
|
532
|
+
* getTags: GetTags,
|
|
533
|
+
* getPresentTags: GetPresentTags,
|
|
534
|
+
* filterTags: FilterTags,
|
|
535
|
+
* filterAllTags: FilterAllTags,
|
|
536
|
+
* getTagsByType: GetTagsByType,
|
|
537
|
+
* hasOptionTag: HasOptionTag,
|
|
538
|
+
* getClassNode: GetClassNode,
|
|
539
|
+
* getClassJsdoc: GetClassJsdoc,
|
|
540
|
+
* classHasTag: ClassHasTag
|
|
541
|
+
* }} Utils
|
|
542
|
+
*/
|
|
22
543
|
const {
|
|
23
544
|
rewireSpecs,
|
|
24
545
|
seedTokens
|
|
@@ -29,19 +550,38 @@ const {
|
|
|
29
550
|
/**
|
|
30
551
|
* Should use ESLint rule's typing.
|
|
31
552
|
*
|
|
32
|
-
* @typedef {
|
|
553
|
+
* @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta
|
|
33
554
|
*/
|
|
34
555
|
|
|
556
|
+
/* eslint-disable jsdoc/valid-types -- Old version */
|
|
35
557
|
/**
|
|
36
558
|
* A plain object for tracking state as needed by rules across iterations.
|
|
37
559
|
*
|
|
38
|
-
* @typedef {
|
|
560
|
+
* @typedef {{
|
|
561
|
+
* globalTags: {},
|
|
562
|
+
* hasDuplicates: {
|
|
563
|
+
* [key: string]: boolean
|
|
564
|
+
* },
|
|
565
|
+
* selectorMap: {
|
|
566
|
+
* [selector: string]: {
|
|
567
|
+
* [comment: string]: Integer
|
|
568
|
+
* }
|
|
569
|
+
* },
|
|
570
|
+
* hasTag: {
|
|
571
|
+
* [key: string]: boolean
|
|
572
|
+
* },
|
|
573
|
+
* hasNonComment: number,
|
|
574
|
+
* hasNonCommentBeforeTag: {
|
|
575
|
+
* [key: string]: boolean|number
|
|
576
|
+
* }
|
|
577
|
+
* }} StateObject
|
|
39
578
|
*/
|
|
579
|
+
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
40
580
|
|
|
41
581
|
/**
|
|
42
582
|
* The Node AST as supplied by the parser.
|
|
43
583
|
*
|
|
44
|
-
* @typedef {
|
|
584
|
+
* @typedef {import('eslint').Rule.Node} Node
|
|
45
585
|
*/
|
|
46
586
|
|
|
47
587
|
/*
|
|
@@ -59,18 +599,16 @@ const globalState = new Map();
|
|
|
59
599
|
* tagNamePreference?: import('./jsdocUtils.js').TagNamePreference,
|
|
60
600
|
* mode?: import('./jsdocUtils.js').ParserMode
|
|
61
601
|
* }} cfg
|
|
62
|
-
* @returns {
|
|
602
|
+
* @returns {BasicUtils}
|
|
63
603
|
*/
|
|
64
604
|
const getBasicUtils = (context, {
|
|
65
605
|
tagNamePreference,
|
|
66
606
|
mode
|
|
67
607
|
}) => {
|
|
608
|
+
/** @type {BasicUtils} */
|
|
68
609
|
const utils = {};
|
|
69
610
|
|
|
70
|
-
/**
|
|
71
|
-
* @param {string} message
|
|
72
|
-
* @returns {void}
|
|
73
|
-
*/
|
|
611
|
+
/** @type {ReportSettings} */
|
|
74
612
|
utils.reportSettings = message => {
|
|
75
613
|
context.report({
|
|
76
614
|
loc: {
|
|
@@ -87,20 +625,13 @@ const getBasicUtils = (context, {
|
|
|
87
625
|
});
|
|
88
626
|
};
|
|
89
627
|
|
|
90
|
-
/**
|
|
91
|
-
* @param {import('comment-parser').Spec} tag
|
|
92
|
-
* @returns {string[]}
|
|
93
|
-
*/
|
|
628
|
+
/** @type {ParseClosureTemplateTag} */
|
|
94
629
|
utils.parseClosureTemplateTag = tag => {
|
|
95
630
|
return _jsdocUtils.default.parseClosureTemplateTag(tag);
|
|
96
631
|
};
|
|
97
632
|
utils.pathDoesNotBeginWith = _jsdocUtils.default.pathDoesNotBeginWith;
|
|
98
633
|
|
|
99
|
-
/**
|
|
100
|
-
* @param {{
|
|
101
|
-
* tagName: string
|
|
102
|
-
* }} cfg
|
|
103
|
-
*/
|
|
634
|
+
/** @type {GetPreferredTagNameObject} */
|
|
104
635
|
utils.getPreferredTagNameObject = ({
|
|
105
636
|
tagName
|
|
106
637
|
}) => {
|
|
@@ -117,22 +648,40 @@ const getBasicUtils = (context, {
|
|
|
117
648
|
return utils;
|
|
118
649
|
};
|
|
119
650
|
|
|
651
|
+
/* eslint-disable jsdoc/valid-types -- Old version of pratt */
|
|
120
652
|
/**
|
|
121
|
-
* @
|
|
122
|
-
* @param {
|
|
123
|
-
* @param {import('
|
|
653
|
+
* @callback Report
|
|
654
|
+
* @param {string} message
|
|
655
|
+
* @param {import('eslint').Rule.ReportFixer|null} [fix]
|
|
656
|
+
* @param {null|
|
|
657
|
+
* {line?: Integer, column?: Integer}|
|
|
658
|
+
* import('comment-parser').Spec & {line?: Integer}
|
|
659
|
+
* } [jsdocLoc]
|
|
660
|
+
* @param {undefined|{
|
|
661
|
+
* [key: string]: string
|
|
662
|
+
* }} [data]
|
|
663
|
+
* @returns {void}
|
|
664
|
+
*/
|
|
665
|
+
/* eslint-enable jsdoc/valid-types -- Old version of pratt */
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* @param {Node|null} node
|
|
669
|
+
* @param {import('comment-parser').Block & {
|
|
670
|
+
* inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
|
|
671
|
+
* }} jsdoc
|
|
672
|
+
* @param {import('eslint').AST.Token} jsdocNode
|
|
124
673
|
* @param {Settings} settings
|
|
125
|
-
* @param {} report
|
|
674
|
+
* @param {Report} report
|
|
126
675
|
* @param {import('eslint').Rule.RuleContext} context
|
|
127
|
-
* @param {boolean} iteratingAll
|
|
128
|
-
* @param {} ruleConfig
|
|
676
|
+
* @param {boolean|undefined} iteratingAll
|
|
677
|
+
* @param {RuleConfig} ruleConfig
|
|
129
678
|
* @param {string} indent
|
|
130
|
-
* @returns {}
|
|
679
|
+
* @returns {Utils}
|
|
131
680
|
*/
|
|
132
681
|
const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent) => {
|
|
133
|
-
const ancestors = context.getAncestors();
|
|
682
|
+
const ancestors = /** @type {import('eslint').Rule.Node[]} */context.getAncestors();
|
|
134
683
|
const sourceCode = context.getSourceCode();
|
|
135
|
-
const utils = getBasicUtils(context, settings);
|
|
684
|
+
const utils = /** @type {Utils} */getBasicUtils(context, settings);
|
|
136
685
|
const {
|
|
137
686
|
tagNamePreference,
|
|
138
687
|
overrideReplacesDocs,
|
|
@@ -144,25 +693,17 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
144
693
|
mode
|
|
145
694
|
} = settings;
|
|
146
695
|
|
|
147
|
-
/**
|
|
148
|
-
* @returns {boolean}
|
|
149
|
-
*/
|
|
696
|
+
/** @type {IsIteratingFunction} */
|
|
150
697
|
utils.isIteratingFunction = () => {
|
|
151
|
-
return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(node && node.type);
|
|
698
|
+
return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(String(node && node.type));
|
|
152
699
|
};
|
|
153
700
|
|
|
154
|
-
/**
|
|
155
|
-
* @returns {boolean}
|
|
156
|
-
*/
|
|
701
|
+
/** @type {IsVirtualFunction} */
|
|
157
702
|
utils.isVirtualFunction = () => {
|
|
158
|
-
return iteratingAll && utils.hasATag(['callback', 'function', 'func', 'method']);
|
|
703
|
+
return Boolean(iteratingAll) && utils.hasATag(['callback', 'function', 'func', 'method']);
|
|
159
704
|
};
|
|
160
705
|
|
|
161
|
-
/**
|
|
162
|
-
* @param {import('comment-parser').Block} tagBlock
|
|
163
|
-
* @param {boolean} [specRewire]
|
|
164
|
-
* @returns {string}
|
|
165
|
-
*/
|
|
706
|
+
/** @type {Stringify} */
|
|
166
707
|
utils.stringify = (tagBlock, specRewire) => {
|
|
167
708
|
let block;
|
|
168
709
|
if (specRewire) {
|
|
@@ -172,18 +713,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
172
713
|
specRewire ? block : tagBlock);
|
|
173
714
|
};
|
|
174
715
|
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* @param {string} msg
|
|
178
|
-
* @param {import('comment-parser').Spec} tag
|
|
179
|
-
* @param {() => void} handler
|
|
180
|
-
* @param {boolean} [specRewire]
|
|
181
|
-
* @param {{
|
|
182
|
-
* [key: string]: undefined|string
|
|
183
|
-
* }} [data]
|
|
184
|
-
*/
|
|
716
|
+
/** @type {ReportJSDoc} */
|
|
185
717
|
utils.reportJSDoc = (msg, tag, handler, specRewire, data) => {
|
|
186
|
-
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
187
718
|
report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => {
|
|
188
719
|
handler();
|
|
189
720
|
const replacement = utils.stringify(jsdoc, specRewire);
|
|
@@ -199,20 +730,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
199
730
|
} : null, tag, data);
|
|
200
731
|
};
|
|
201
732
|
|
|
202
|
-
/**
|
|
203
|
-
* @param {string} str
|
|
204
|
-
* @param {string} requiredFlags
|
|
205
|
-
* @returns {RegExp}
|
|
206
|
-
*/
|
|
733
|
+
/** @type {GetRegexFromString} */
|
|
207
734
|
utils.getRegexFromString = (str, requiredFlags) => {
|
|
208
735
|
return _jsdocUtils.default.getRegexFromString(str, requiredFlags);
|
|
209
736
|
};
|
|
210
737
|
|
|
211
|
-
/**
|
|
212
|
-
* @param {import('comment-parser').Spec} tg
|
|
213
|
-
* @param {boolean} returnArray
|
|
214
|
-
* @returns {string[]|string}
|
|
215
|
-
*/
|
|
738
|
+
/** @type {GetTagDescription} */
|
|
216
739
|
utils.getTagDescription = (tg, returnArray) => {
|
|
217
740
|
/**
|
|
218
741
|
* @type {string[]}
|
|
@@ -246,12 +769,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
246
769
|
return returnArray ? descriptions : descriptions.join('\n');
|
|
247
770
|
};
|
|
248
771
|
|
|
249
|
-
/**
|
|
250
|
-
* @param {import('comment-parser').Spec} tg
|
|
251
|
-
* @param {RegExp} matcher
|
|
252
|
-
* @param {(description: string) => string} setter
|
|
253
|
-
* @returns {Integer}
|
|
254
|
-
*/
|
|
772
|
+
/** @type {SetTagDescription} */
|
|
255
773
|
utils.setTagDescription = (tg, matcher, setter) => {
|
|
256
774
|
let finalIdx = 0;
|
|
257
775
|
tg.source.some(({
|
|
@@ -269,13 +787,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
269
787
|
return finalIdx;
|
|
270
788
|
};
|
|
271
789
|
|
|
272
|
-
/**
|
|
273
|
-
* @returns {{
|
|
274
|
-
* description: string,
|
|
275
|
-
* descriptions: string[],
|
|
276
|
-
* lastDescriptionLine: Integer
|
|
277
|
-
* }}
|
|
278
|
-
*/
|
|
790
|
+
/** @type {GetDescription} */
|
|
279
791
|
utils.getDescription = () => {
|
|
280
792
|
/** @type {string[]} */
|
|
281
793
|
const descriptions = [];
|
|
@@ -310,23 +822,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
310
822
|
};
|
|
311
823
|
};
|
|
312
824
|
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @param {(
|
|
316
|
-
* info: undefined|{
|
|
317
|
-
* delimiter: string,
|
|
318
|
-
* postDelimiter: string,
|
|
319
|
-
* start: string
|
|
320
|
-
* },
|
|
321
|
-
* seedTokens: (
|
|
322
|
-
* tokens?: Partial<import('comment-parser').Tokens> | undefined
|
|
323
|
-
* ) => import('comment-parser').Tokens,
|
|
324
|
-
* descLines: string[]
|
|
325
|
-
* ) => import('comment-parser').Tokens[]} setter
|
|
326
|
-
* @returns {void}
|
|
327
|
-
*/
|
|
825
|
+
/** @type {SetBlockDescription} */
|
|
328
826
|
utils.setBlockDescription = setter => {
|
|
329
|
-
/* eslint-enable jsdoc/no-undefined-types -- Bug */
|
|
330
827
|
/** @type {string[]} */
|
|
331
828
|
const descLines = [];
|
|
332
829
|
/**
|
|
@@ -337,6 +834,14 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
337
834
|
* @type {undefined|Integer}
|
|
338
835
|
*/
|
|
339
836
|
let endIdx;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* @type {undefined|{
|
|
840
|
+
* delimiter: string,
|
|
841
|
+
* postDelimiter: string,
|
|
842
|
+
* start: string
|
|
843
|
+
* }}
|
|
844
|
+
*/
|
|
340
845
|
let info;
|
|
341
846
|
jsdoc.source.some(({
|
|
342
847
|
tokens: {
|
|
@@ -369,15 +874,19 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
369
874
|
|
|
370
875
|
/* istanbul ignore else -- Won't be called if missing */
|
|
371
876
|
if (descLines.length) {
|
|
372
|
-
jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - /** @type {Integer} */startIdx, ...setter(
|
|
877
|
+
jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - /** @type {Integer} */startIdx, ...setter(
|
|
878
|
+
/**
|
|
879
|
+
* @type {{
|
|
880
|
+
* delimiter: string,
|
|
881
|
+
* postDelimiter: string,
|
|
882
|
+
* start: string
|
|
883
|
+
* }}
|
|
884
|
+
*/
|
|
885
|
+
info, seedTokens, descLines));
|
|
373
886
|
}
|
|
374
887
|
};
|
|
375
888
|
|
|
376
|
-
/**
|
|
377
|
-
* @param {RegExp} matcher
|
|
378
|
-
* @param {(description: string) => string} setter
|
|
379
|
-
* @returns {Integer}
|
|
380
|
-
*/
|
|
889
|
+
/** @type {SetDescriptionLines} */
|
|
381
890
|
utils.setDescriptionLines = (matcher, setter) => {
|
|
382
891
|
let finalIdx = 0;
|
|
383
892
|
jsdoc.source.some(({
|
|
@@ -401,11 +910,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
401
910
|
return finalIdx;
|
|
402
911
|
};
|
|
403
912
|
|
|
404
|
-
/**
|
|
405
|
-
* @param {import('comment-parser').Spec} tag
|
|
406
|
-
* @param {import('comment-parser').Tokens[]} tokens
|
|
407
|
-
* @returns {void}
|
|
408
|
-
*/
|
|
913
|
+
/** @type {ChangeTag} */
|
|
409
914
|
utils.changeTag = (tag, ...tokens) => {
|
|
410
915
|
for (const [idx, src] of tag.source.entries()) {
|
|
411
916
|
src.tokens = {
|
|
@@ -415,16 +920,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
415
920
|
}
|
|
416
921
|
};
|
|
417
922
|
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* @param {import('comment-parser').Spec & {
|
|
421
|
-
* line: Integer
|
|
422
|
-
* }} tag
|
|
423
|
-
* @param {Partial<import('comment-parser').Tokens>} tokens
|
|
424
|
-
* @returns {void}
|
|
425
|
-
*/
|
|
923
|
+
/** @type {SetTag} */
|
|
426
924
|
utils.setTag = (tag, tokens) => {
|
|
427
|
-
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
428
925
|
tag.source = [{
|
|
429
926
|
number: tag.line,
|
|
430
927
|
// Or tag.source[0].number?
|
|
@@ -439,14 +936,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
439
936
|
}];
|
|
440
937
|
};
|
|
441
938
|
|
|
442
|
-
/**
|
|
443
|
-
* @param {Integer} tagIndex
|
|
444
|
-
* @param {{
|
|
445
|
-
* removeEmptyBlock?: boolean,
|
|
446
|
-
* tagSourceOffset?: Integer
|
|
447
|
-
* }} cfg
|
|
448
|
-
* @returns {void}
|
|
449
|
-
*/
|
|
939
|
+
/** @type {RemoveTag} */
|
|
450
940
|
utils.removeTag = (tagIndex, {
|
|
451
941
|
removeEmptyBlock = false,
|
|
452
942
|
tagSourceOffset = 0
|
|
@@ -520,12 +1010,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
520
1010
|
// correct information will be available)
|
|
521
1011
|
};
|
|
522
1012
|
|
|
523
|
-
/**
|
|
524
|
-
* @param {string} targetTagName
|
|
525
|
-
* @param {Integer} number
|
|
526
|
-
* @param {import('comment-parser').Tokens|{}} tokens
|
|
527
|
-
* @returns {void}
|
|
528
|
-
*/
|
|
1013
|
+
/** @type {AddTag} */
|
|
529
1014
|
utils.addTag = (targetTagName, number = ((() => {
|
|
530
1015
|
var _jsdoc$tags, _jsdoc$tags$source$;
|
|
531
1016
|
return (_jsdoc$tags = jsdoc.tags[jsdoc.tags.length - 1]) === null || _jsdoc$tags === void 0 ? void 0 : (_jsdoc$tags$source$ = _jsdoc$tags.source[0]) === null || _jsdoc$tags$source$ === void 0 ? void 0 : _jsdoc$tags$source$.number;
|
|
@@ -552,9 +1037,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
552
1037
|
}
|
|
553
1038
|
};
|
|
554
1039
|
|
|
555
|
-
/**
|
|
556
|
-
* @returns {Integer|undefined}
|
|
557
|
-
*/
|
|
1040
|
+
/** @type {GetFirstLine} */
|
|
558
1041
|
utils.getFirstLine = () => {
|
|
559
1042
|
let firstLine;
|
|
560
1043
|
for (const {
|
|
@@ -570,14 +1053,11 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
570
1053
|
}
|
|
571
1054
|
return firstLine;
|
|
572
1055
|
};
|
|
1056
|
+
|
|
1057
|
+
/** @type {SeedTokens} */
|
|
573
1058
|
utils.seedTokens = seedTokens;
|
|
574
1059
|
|
|
575
|
-
/**
|
|
576
|
-
* Sets tokens to empty string.
|
|
577
|
-
*
|
|
578
|
-
* @param {import('comment-parser').Tokens} tokens
|
|
579
|
-
* @returns {void}
|
|
580
|
-
*/
|
|
1060
|
+
/** @type {EmptyTokens} */
|
|
581
1061
|
utils.emptyTokens = tokens => {
|
|
582
1062
|
for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) {
|
|
583
1063
|
tokens[
|
|
@@ -589,11 +1069,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
589
1069
|
}
|
|
590
1070
|
};
|
|
591
1071
|
|
|
592
|
-
/**
|
|
593
|
-
* @param {Integer} sourceIndex
|
|
594
|
-
* @param {import('comment-parser').Tokens} tokens
|
|
595
|
-
* @returns {void}
|
|
596
|
-
*/
|
|
1072
|
+
/** @type {AddLine} */
|
|
597
1073
|
utils.addLine = (sourceIndex, tokens) => {
|
|
598
1074
|
var _jsdoc$source;
|
|
599
1075
|
const number = (((_jsdoc$source = jsdoc.source[sourceIndex - 1]) === null || _jsdoc$source === void 0 ? void 0 : _jsdoc$source.number) || 0) + 1;
|
|
@@ -609,12 +1085,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
609
1085
|
// rewireSource(jsdoc);
|
|
610
1086
|
};
|
|
611
1087
|
|
|
612
|
-
/**
|
|
613
|
-
* @param {Integer} tagIndex
|
|
614
|
-
* @param {Integer} tagSourceOffset
|
|
615
|
-
* @param {Integer} numLines
|
|
616
|
-
* @returns {void}
|
|
617
|
-
*/
|
|
1088
|
+
/** @type {AddLines} */
|
|
618
1089
|
utils.addLines = (tagIndex, tagSourceOffset, numLines) => {
|
|
619
1090
|
const {
|
|
620
1091
|
source: tagSource
|
|
@@ -662,13 +1133,11 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
662
1133
|
return false;
|
|
663
1134
|
});
|
|
664
1135
|
for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
|
|
665
|
-
src.number = firstNumber + lastIndex + idx;
|
|
1136
|
+
src.number = firstNumber + /** @type {Integer} */lastIndex + idx;
|
|
666
1137
|
}
|
|
667
1138
|
};
|
|
668
1139
|
|
|
669
|
-
/**
|
|
670
|
-
* @returns {void}
|
|
671
|
-
*/
|
|
1140
|
+
/** @type {MakeMultiline} */
|
|
672
1141
|
utils.makeMultiline = () => {
|
|
673
1142
|
const {
|
|
674
1143
|
source: [{
|
|
@@ -724,52 +1193,43 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
724
1193
|
};
|
|
725
1194
|
|
|
726
1195
|
/**
|
|
727
|
-
* @
|
|
728
|
-
* @returns {}
|
|
1196
|
+
* @type {import('./jsdocUtils.js').FlattenRoots}
|
|
729
1197
|
*/
|
|
730
|
-
utils.flattenRoots =
|
|
731
|
-
return _jsdocUtils.default.flattenRoots(params);
|
|
732
|
-
};
|
|
1198
|
+
utils.flattenRoots = _jsdocUtils.default.flattenRoots;
|
|
733
1199
|
|
|
734
|
-
/**
|
|
735
|
-
* @param {boolean} useDefaultObjectProperties
|
|
736
|
-
* @returns {}
|
|
737
|
-
*/
|
|
1200
|
+
/** @type {GetFunctionParameterNames} */
|
|
738
1201
|
utils.getFunctionParameterNames = useDefaultObjectProperties => {
|
|
739
1202
|
return _jsdocUtils.default.getFunctionParameterNames(node, useDefaultObjectProperties);
|
|
740
1203
|
};
|
|
741
1204
|
|
|
742
|
-
/**
|
|
743
|
-
* @returns {Integer}
|
|
744
|
-
*/
|
|
1205
|
+
/** @type {HasParams} */
|
|
745
1206
|
utils.hasParams = () => {
|
|
746
|
-
return _jsdocUtils.default.hasParams(node);
|
|
1207
|
+
return _jsdocUtils.default.hasParams( /** @type {Node} */node);
|
|
747
1208
|
};
|
|
748
1209
|
|
|
749
|
-
/**
|
|
750
|
-
* @returns {boolean}
|
|
751
|
-
*/
|
|
1210
|
+
/** @type {IsGenerator} */
|
|
752
1211
|
utils.isGenerator = () => {
|
|
753
|
-
return node
|
|
1212
|
+
return node !== null && Boolean(
|
|
1213
|
+
/**
|
|
1214
|
+
* @type {import('estree').FunctionDeclaration|
|
|
1215
|
+
* import('estree').FunctionExpression}
|
|
1216
|
+
*/
|
|
1217
|
+
node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type) && /** @type {import('estree').FunctionDeclaration} */
|
|
1218
|
+
/**
|
|
1219
|
+
* @type {import('estree').ExportNamedDeclaration|
|
|
1220
|
+
* import('estree').ExportDefaultDeclaration}
|
|
1221
|
+
*/
|
|
1222
|
+
node.declaration.generator);
|
|
754
1223
|
};
|
|
755
1224
|
|
|
756
|
-
/**
|
|
757
|
-
* @returns {boolean}
|
|
758
|
-
*/
|
|
1225
|
+
/** @type {IsConstructor} */
|
|
759
1226
|
utils.isConstructor = () => {
|
|
760
|
-
return _jsdocUtils.default.isConstructor(node);
|
|
1227
|
+
return _jsdocUtils.default.isConstructor( /** @type {Node} */node);
|
|
761
1228
|
};
|
|
762
1229
|
|
|
763
|
-
/**
|
|
764
|
-
* @param {string} tagName
|
|
765
|
-
* @returns {false|{
|
|
766
|
-
* idx: Integer,
|
|
767
|
-
* name: string,
|
|
768
|
-
* type: string
|
|
769
|
-
* }[]}
|
|
770
|
-
*/
|
|
1230
|
+
/** @type {GetJsdocTagsDeep} */
|
|
771
1231
|
utils.getJsdocTagsDeep = tagName => {
|
|
772
|
-
const name = utils.getPreferredTagName({
|
|
1232
|
+
const name = /** @type {string|false} */utils.getPreferredTagName({
|
|
773
1233
|
tagName
|
|
774
1234
|
});
|
|
775
1235
|
if (!name) {
|
|
@@ -778,14 +1238,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
778
1238
|
return _jsdocUtils.default.getJsdocTagsDeep(jsdoc, name);
|
|
779
1239
|
};
|
|
780
1240
|
|
|
781
|
-
/**
|
|
782
|
-
* @param {{
|
|
783
|
-
* tagName: string,
|
|
784
|
-
* skipReportingBlockedTag?: boolean,
|
|
785
|
-
* allowObjectReturn?: boolean,
|
|
786
|
-
* defaultMessage?: string
|
|
787
|
-
* }} cfg
|
|
788
|
-
*/
|
|
1241
|
+
/** @type {GetPreferredTagName} */
|
|
789
1242
|
utils.getPreferredTagName = ({
|
|
790
1243
|
tagName,
|
|
791
1244
|
skipReportingBlockedTag = false,
|
|
@@ -808,56 +1261,39 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
808
1261
|
return isObject && !allowObjectReturn ? ret.replacement : ret;
|
|
809
1262
|
};
|
|
810
1263
|
|
|
811
|
-
/**
|
|
812
|
-
* @param {string} name
|
|
813
|
-
* @param {string[]} definedTags
|
|
814
|
-
* @returns {boolean}
|
|
815
|
-
*/
|
|
1264
|
+
/** @type {IsValidTag} */
|
|
816
1265
|
utils.isValidTag = (name, definedTags) => {
|
|
817
1266
|
return _jsdocUtils.default.isValidTag(context, mode, name, definedTags);
|
|
818
1267
|
};
|
|
819
1268
|
|
|
820
|
-
/**
|
|
821
|
-
* @param {string[]} names
|
|
822
|
-
* @returns {boolean}
|
|
823
|
-
*/
|
|
1269
|
+
/** @type {HasATag} */
|
|
824
1270
|
utils.hasATag = names => {
|
|
825
1271
|
return _jsdocUtils.default.hasATag(jsdoc, names);
|
|
826
1272
|
};
|
|
827
1273
|
|
|
828
|
-
/**
|
|
829
|
-
* @param {string} name
|
|
830
|
-
* @returns {boolean}
|
|
831
|
-
*/
|
|
1274
|
+
/** @type {HasTag} */
|
|
832
1275
|
utils.hasTag = name => {
|
|
833
1276
|
return _jsdocUtils.default.hasTag(jsdoc, name);
|
|
834
1277
|
};
|
|
835
1278
|
|
|
836
|
-
/**
|
|
837
|
-
* @param {string} name
|
|
838
|
-
* @returns {}
|
|
839
|
-
*/
|
|
1279
|
+
/** @type {ComparePaths} */
|
|
840
1280
|
utils.comparePaths = name => {
|
|
841
1281
|
return _jsdocUtils.default.comparePaths(name);
|
|
842
1282
|
};
|
|
843
1283
|
|
|
844
|
-
/**
|
|
845
|
-
* @param {string} name
|
|
846
|
-
* @returns {}
|
|
847
|
-
*/
|
|
1284
|
+
/** @type {DropPathSegmentQuotes} */
|
|
848
1285
|
utils.dropPathSegmentQuotes = name => {
|
|
849
1286
|
return _jsdocUtils.default.dropPathSegmentQuotes(name);
|
|
850
1287
|
};
|
|
851
1288
|
|
|
852
|
-
/**
|
|
853
|
-
* @returns {boolean}
|
|
854
|
-
*/
|
|
1289
|
+
/** @type {AvoidDocs} */
|
|
855
1290
|
utils.avoidDocs = () => {
|
|
856
1291
|
var _context$options$;
|
|
857
1292
|
if (ignoreReplacesDocs !== false && (utils.hasTag('ignore') || utils.classHasTag('ignore')) || overrideReplacesDocs !== false && (utils.hasTag('override') || utils.classHasTag('override')) || implementsReplacesDocs !== false && (utils.hasTag('implements') || utils.classHasTag('implements')) || augmentsExtendsReplacesDocs && (utils.hasATag(['augments', 'extends']) || utils.classHasTag('augments') || utils.classHasTag('extends'))) {
|
|
858
1293
|
return true;
|
|
859
1294
|
}
|
|
860
|
-
if (_jsdocUtils.default.exemptSpeciaMethods(jsdoc, node, context,
|
|
1295
|
+
if (_jsdocUtils.default.exemptSpeciaMethods(jsdoc, node, context, /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */
|
|
1296
|
+
ruleConfig.meta.schema)) {
|
|
861
1297
|
return true;
|
|
862
1298
|
}
|
|
863
1299
|
const exemptedBy = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.exemptedBy) ?? ['inheritDoc', ...(mode === 'closure' ? [] : ['inheritdoc'])];
|
|
@@ -867,12 +1303,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
867
1303
|
return false;
|
|
868
1304
|
};
|
|
869
1305
|
for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
|
|
870
|
-
/**
|
|
871
|
-
* @param {string} tagName
|
|
872
|
-
* @param {import('./getDefaultTagStructureForMode.js').
|
|
873
|
-
* TagStructure[]} [otherModeMaps]
|
|
874
|
-
* @returns {boolean|{otherMode: true}}
|
|
875
|
-
*/
|
|
1306
|
+
/** @type {TagMightHaveNamePositionTypePosition} */
|
|
876
1307
|
utils[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
|
|
877
1308
|
method] = (tagName, otherModeMaps) => {
|
|
878
1309
|
const result = _jsdocUtils.default[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
|
|
@@ -892,16 +1323,25 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
892
1323
|
} : false;
|
|
893
1324
|
};
|
|
894
1325
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1326
|
+
|
|
1327
|
+
/** @type {TagMissingRequiredTypeOrNamepath} */
|
|
1328
|
+
utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => {
|
|
1329
|
+
const result = _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName);
|
|
1330
|
+
if (!result) {
|
|
1331
|
+
return false;
|
|
1332
|
+
}
|
|
1333
|
+
const otherResult = otherModeMaps.every(otherModeMap => {
|
|
1334
|
+
return _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap);
|
|
1335
|
+
});
|
|
1336
|
+
return otherResult ? true : {
|
|
1337
|
+
otherMode: false
|
|
1338
|
+
};
|
|
1339
|
+
};
|
|
1340
|
+
for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) {
|
|
1341
|
+
/** @type {TagMustHave} */
|
|
1342
|
+
utils[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
903
1343
|
method] = (tagName, otherModeMaps) => {
|
|
904
|
-
const result = _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"
|
|
1344
|
+
const result = _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
905
1345
|
method](tagName);
|
|
906
1346
|
if (!result) {
|
|
907
1347
|
return false;
|
|
@@ -910,7 +1350,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
910
1350
|
// if (!otherModeMaps) { return true; }
|
|
911
1351
|
|
|
912
1352
|
const otherResult = otherModeMaps.every(otherModeMap => {
|
|
913
|
-
return _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"
|
|
1353
|
+
return _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
914
1354
|
method](tagName, otherModeMap);
|
|
915
1355
|
});
|
|
916
1356
|
return otherResult ? true : {
|
|
@@ -919,102 +1359,104 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
919
1359
|
};
|
|
920
1360
|
}
|
|
921
1361
|
for (const method of ['isNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNamepath']) {
|
|
922
|
-
/**
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
return _jsdocUtils.default[method](tagName);
|
|
1362
|
+
/** @type {IsNamepathX} */
|
|
1363
|
+
utils[/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
|
|
1364
|
+
method] = tagName => {
|
|
1365
|
+
return _jsdocUtils.default[/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
|
|
1366
|
+
method](tagName);
|
|
928
1367
|
};
|
|
929
1368
|
}
|
|
930
1369
|
|
|
931
|
-
/**
|
|
932
|
-
* @param {import('./jsdocUtils.js').ParserMode} mde
|
|
933
|
-
* @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
934
|
-
*/
|
|
1370
|
+
/** @type {GetTagStructureForMode} */
|
|
935
1371
|
utils.getTagStructureForMode = mde => {
|
|
936
1372
|
return _jsdocUtils.default.getTagStructureForMode(mde, settings.structuredTags);
|
|
937
1373
|
};
|
|
938
1374
|
|
|
939
|
-
/**
|
|
940
|
-
* @param {} tag
|
|
941
|
-
* @returns {}
|
|
942
|
-
*/
|
|
1375
|
+
/** @type {MayBeUndefinedTypeTag} */
|
|
943
1376
|
utils.mayBeUndefinedTypeTag = tag => {
|
|
944
1377
|
return _jsdocUtils.default.mayBeUndefinedTypeTag(tag, settings.mode);
|
|
945
1378
|
};
|
|
1379
|
+
|
|
1380
|
+
/** @type {HasValueOrExecutorHasNonEmptyResolveValue} */
|
|
946
1381
|
utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
|
|
947
|
-
return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue(node, anyPromiseAsReturn, allBranches);
|
|
1382
|
+
return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue( /** @type {Node} */node, anyPromiseAsReturn, allBranches);
|
|
948
1383
|
};
|
|
949
1384
|
|
|
950
|
-
/**
|
|
951
|
-
* @returns {boolean}
|
|
952
|
-
*/
|
|
1385
|
+
/** @type {HasYieldValue} */
|
|
953
1386
|
utils.hasYieldValue = () => {
|
|
954
|
-
if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type)) {
|
|
955
|
-
return _jsdocUtils.default.hasYieldValue(
|
|
1387
|
+
if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes( /** @type {Node} */node.type)) {
|
|
1388
|
+
return _jsdocUtils.default.hasYieldValue( /** @type {import('estree').Declaration|import('estree').Expression} */
|
|
1389
|
+
/** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */
|
|
1390
|
+
node.declaration);
|
|
956
1391
|
}
|
|
957
|
-
return _jsdocUtils.default.hasYieldValue(node);
|
|
1392
|
+
return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node);
|
|
958
1393
|
};
|
|
959
1394
|
|
|
960
|
-
/**
|
|
961
|
-
* @returns {boolean}
|
|
962
|
-
*/
|
|
1395
|
+
/** @type {HasYieldReturnValue} */
|
|
963
1396
|
utils.hasYieldReturnValue = () => {
|
|
964
|
-
return _jsdocUtils.default.hasYieldValue(node, true);
|
|
1397
|
+
return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node, true);
|
|
965
1398
|
};
|
|
966
1399
|
|
|
967
|
-
/**
|
|
968
|
-
* @returns {boolean}
|
|
969
|
-
*/
|
|
1400
|
+
/** @type {HasThrowValue} */
|
|
970
1401
|
utils.hasThrowValue = () => {
|
|
971
1402
|
return _jsdocUtils.default.hasThrowValue(node);
|
|
972
1403
|
};
|
|
973
1404
|
|
|
974
|
-
/**
|
|
975
|
-
* @returns {boolean}
|
|
976
|
-
*/
|
|
1405
|
+
/** @type {IsAsync} */
|
|
977
1406
|
utils.isAsync = () => {
|
|
978
|
-
return node.async;
|
|
1407
|
+
return 'async' in /** @type {Node} */node && node.async;
|
|
979
1408
|
};
|
|
1409
|
+
|
|
1410
|
+
/** @type {GetTags} */
|
|
980
1411
|
utils.getTags = tagName => {
|
|
981
1412
|
return utils.filterTags(item => {
|
|
982
1413
|
return item.tag === tagName;
|
|
983
1414
|
});
|
|
984
1415
|
};
|
|
1416
|
+
|
|
1417
|
+
/** @type {GetPresentTags} */
|
|
985
1418
|
utils.getPresentTags = tagList => {
|
|
986
1419
|
return utils.filterTags(tag => {
|
|
987
1420
|
return tagList.includes(tag.tag);
|
|
988
1421
|
});
|
|
989
1422
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1423
|
+
|
|
1424
|
+
/** @type {FilterTags} */
|
|
1425
|
+
utils.filterTags = filter => {
|
|
1426
|
+
return jsdoc.tags.filter(tag => {
|
|
1427
|
+
return filter(tag);
|
|
1428
|
+
});
|
|
993
1429
|
};
|
|
994
1430
|
|
|
995
|
-
/**
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1431
|
+
/** @type {FilterAllTags} */
|
|
1432
|
+
utils.filterAllTags = filter => {
|
|
1433
|
+
const tags = _jsdocUtils.default.getAllTags(jsdoc);
|
|
1434
|
+
return tags.filter(tag => {
|
|
1435
|
+
return filter(tag);
|
|
1436
|
+
});
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
/** @type {GetTagsByType} */
|
|
999
1440
|
utils.getTagsByType = tags => {
|
|
1000
1441
|
return _jsdocUtils.default.getTagsByType(context, mode, tags, tagNamePreference);
|
|
1001
1442
|
};
|
|
1002
1443
|
|
|
1003
|
-
/**
|
|
1004
|
-
* @param {string} tagName
|
|
1005
|
-
* @returns {boolean}
|
|
1006
|
-
*/
|
|
1444
|
+
/** @type {HasOptionTag} */
|
|
1007
1445
|
utils.hasOptionTag = tagName => {
|
|
1008
1446
|
const {
|
|
1009
1447
|
tags
|
|
1010
1448
|
} = context.options[0] ?? {};
|
|
1011
1449
|
return Boolean(tags && tags.includes(tagName));
|
|
1012
1450
|
};
|
|
1451
|
+
|
|
1452
|
+
/** @type {GetClassNode} */
|
|
1013
1453
|
utils.getClassNode = () => {
|
|
1014
1454
|
return [...ancestors, node].reverse().find(parent => {
|
|
1015
1455
|
return parent && ['ClassDeclaration', 'ClassExpression'].includes(parent.type);
|
|
1016
|
-
})
|
|
1456
|
+
}) ?? null;
|
|
1017
1457
|
};
|
|
1458
|
+
|
|
1459
|
+
/** @type {GetClassJsdoc} */
|
|
1018
1460
|
utils.getClassJsdoc = () => {
|
|
1019
1461
|
const classNode = utils.getClassNode();
|
|
1020
1462
|
if (!classNode) {
|
|
@@ -1029,12 +1471,17 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
1029
1471
|
}
|
|
1030
1472
|
return null;
|
|
1031
1473
|
};
|
|
1474
|
+
|
|
1475
|
+
/** @type {ClassHasTag} */
|
|
1032
1476
|
utils.classHasTag = tagName => {
|
|
1033
1477
|
const classJsdoc = utils.getClassJsdoc();
|
|
1034
|
-
return
|
|
1478
|
+
return classJsdoc !== null && _jsdocUtils.default.hasTag(classJsdoc, tagName);
|
|
1035
1479
|
};
|
|
1480
|
+
|
|
1481
|
+
/** @type {ForEachPreferredTag} */
|
|
1036
1482
|
utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag = false) => {
|
|
1037
|
-
const targetTagName =
|
|
1483
|
+
const targetTagName = /** @type {string|false} */
|
|
1484
|
+
utils.getPreferredTagName({
|
|
1038
1485
|
skipReportingBlockedTag,
|
|
1039
1486
|
tagName
|
|
1040
1487
|
});
|
|
@@ -1047,25 +1494,56 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
|
|
|
1047
1494
|
return tag === targetTagName;
|
|
1048
1495
|
});
|
|
1049
1496
|
for (const matchingJsdocTag of matchingJsdocTags) {
|
|
1050
|
-
arrayHandler(
|
|
1497
|
+
arrayHandler(
|
|
1498
|
+
/**
|
|
1499
|
+
* @type {import('comment-parser').Spec & {
|
|
1500
|
+
* line: Integer
|
|
1501
|
+
* }}
|
|
1502
|
+
*/
|
|
1503
|
+
matchingJsdocTag, targetTagName);
|
|
1051
1504
|
}
|
|
1052
1505
|
};
|
|
1053
1506
|
return utils;
|
|
1054
1507
|
};
|
|
1055
1508
|
|
|
1056
1509
|
/* eslint-disable jsdoc/valid-types -- Old version */
|
|
1510
|
+
/**
|
|
1511
|
+
* @typedef {{
|
|
1512
|
+
* [key: string]: false|string|{
|
|
1513
|
+
* message: string,
|
|
1514
|
+
* replacement?: false|string
|
|
1515
|
+
* skipRootChecking?: boolean
|
|
1516
|
+
* }
|
|
1517
|
+
* }} PreferredTypes
|
|
1518
|
+
*/
|
|
1519
|
+
/**
|
|
1520
|
+
* @typedef {{
|
|
1521
|
+
* [key: string]: {
|
|
1522
|
+
* name?: "text"|"namepath-defining"|"namepath-referencing"|false,
|
|
1523
|
+
* type?: boolean|string[],
|
|
1524
|
+
* required?: ("name"|"type"|"typeOrNameRequired")[]
|
|
1525
|
+
* }
|
|
1526
|
+
* }} StructuredTags
|
|
1527
|
+
*/
|
|
1057
1528
|
/**
|
|
1058
1529
|
* Settings from ESLint types.
|
|
1059
1530
|
*
|
|
1060
1531
|
* @typedef {{
|
|
1061
|
-
*
|
|
1532
|
+
* maxLines: Integer,
|
|
1533
|
+
* minLines: Integer,
|
|
1534
|
+
* tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
|
|
1535
|
+
* mode: import('./jsdocUtils.js').ParserMode,
|
|
1536
|
+
* preferredTypes: PreferredTypes,
|
|
1537
|
+
* structuredTags: StructuredTags,
|
|
1538
|
+
* [name: string]: any,
|
|
1539
|
+
* contexts?: Context[]
|
|
1062
1540
|
* }} Settings
|
|
1063
1541
|
*/
|
|
1064
1542
|
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
1065
1543
|
|
|
1066
1544
|
/**
|
|
1067
1545
|
* @param {import('eslint').Rule.RuleContext} context
|
|
1068
|
-
* @returns {Settings}
|
|
1546
|
+
* @returns {Settings|false}
|
|
1069
1547
|
*/
|
|
1070
1548
|
const getSettings = context => {
|
|
1071
1549
|
var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12, _context$settings$jsd13, _context$settings$jsd14;
|
|
@@ -1103,12 +1581,16 @@ const getSettings = context => {
|
|
|
1103
1581
|
} catch (error) {
|
|
1104
1582
|
context.report({
|
|
1105
1583
|
loc: {
|
|
1584
|
+
end: {
|
|
1585
|
+
column: 1,
|
|
1586
|
+
line: 1
|
|
1587
|
+
},
|
|
1106
1588
|
start: {
|
|
1107
1589
|
column: 1,
|
|
1108
1590
|
line: 1
|
|
1109
1591
|
}
|
|
1110
1592
|
},
|
|
1111
|
-
message: error.message
|
|
1593
|
+
message: /** @type {Error} */error.message
|
|
1112
1594
|
});
|
|
1113
1595
|
return false;
|
|
1114
1596
|
}
|
|
@@ -1118,29 +1600,24 @@ const getSettings = context => {
|
|
|
1118
1600
|
/**
|
|
1119
1601
|
* Create the report function
|
|
1120
1602
|
*
|
|
1603
|
+
* @callback MakeReport
|
|
1121
1604
|
* @param {import('eslint').Rule.RuleContext} context
|
|
1122
|
-
* @param {
|
|
1605
|
+
* @param {import('estree').Node} commentNode
|
|
1606
|
+
* @returns {Report}
|
|
1123
1607
|
*/
|
|
1608
|
+
|
|
1609
|
+
/** @type {MakeReport} */
|
|
1124
1610
|
exports.getSettings = getSettings;
|
|
1125
1611
|
const makeReport = (context, commentNode) => {
|
|
1126
|
-
|
|
1127
|
-
/**
|
|
1128
|
-
* @param {string} message
|
|
1129
|
-
* @param {import('eslint').Rule.ReportFixer|null} fix
|
|
1130
|
-
* @param {} jsdocLoc
|
|
1131
|
-
* @param {undefined|{
|
|
1132
|
-
* [key: string]: string
|
|
1133
|
-
* }} data
|
|
1134
|
-
* @returns {void}
|
|
1135
|
-
*/
|
|
1612
|
+
/** @type {Report} */
|
|
1136
1613
|
const report = (message, fix = null, jsdocLoc = null, data = undefined) => {
|
|
1137
1614
|
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
1138
1615
|
let loc;
|
|
1139
1616
|
if (jsdocLoc) {
|
|
1140
1617
|
if (!('line' in jsdocLoc)) {
|
|
1141
|
-
jsdocLoc.line = jsdocLoc.source[0].number;
|
|
1618
|
+
jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number;
|
|
1142
1619
|
}
|
|
1143
|
-
const lineNumber = commentNode.loc.start.line + jsdocLoc.line;
|
|
1620
|
+
const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + /** @type {Integer} */jsdocLoc.line;
|
|
1144
1621
|
loc = {
|
|
1145
1622
|
end: {
|
|
1146
1623
|
column: 0,
|
|
@@ -1154,8 +1631,8 @@ const makeReport = (context, commentNode) => {
|
|
|
1154
1631
|
|
|
1155
1632
|
// Todo: Remove ignore once `check-examples` can be restored for ESLint 8+
|
|
1156
1633
|
// istanbul ignore if
|
|
1157
|
-
if (jsdocLoc.column) {
|
|
1158
|
-
const colNumber = commentNode.loc.start.column + jsdocLoc.column;
|
|
1634
|
+
if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') {
|
|
1635
|
+
const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column;
|
|
1159
1636
|
loc.end.column = colNumber;
|
|
1160
1637
|
loc.start.column = colNumber;
|
|
1161
1638
|
}
|
|
@@ -1171,43 +1648,89 @@ const makeReport = (context, commentNode) => {
|
|
|
1171
1648
|
return report;
|
|
1172
1649
|
};
|
|
1173
1650
|
|
|
1174
|
-
/* eslint-disable jsdoc/
|
|
1651
|
+
/* eslint-disable jsdoc/valid-types -- Old version */
|
|
1652
|
+
/**
|
|
1653
|
+
* @typedef {(
|
|
1654
|
+
* arg: {
|
|
1655
|
+
* context: import('eslint').Rule.RuleContext,
|
|
1656
|
+
* sourceCode: import('eslint').SourceCode,
|
|
1657
|
+
* indent?: string,
|
|
1658
|
+
* info?: {
|
|
1659
|
+
* comment?: string|undefined,
|
|
1660
|
+
* lastIndex?: Integer|undefined
|
|
1661
|
+
* },
|
|
1662
|
+
* state?: StateObject,
|
|
1663
|
+
* globalState?: Map<string, Map<string, string>>,
|
|
1664
|
+
* jsdoc?: import('comment-parser').Block,
|
|
1665
|
+
* jsdocNode?: import('eslint').Rule.Node & {
|
|
1666
|
+
* range: [number, number]
|
|
1667
|
+
* },
|
|
1668
|
+
* node?: Node,
|
|
1669
|
+
* allComments?: import('estree').Node[]
|
|
1670
|
+
* report?: Report,
|
|
1671
|
+
* makeReport?: MakeReport,
|
|
1672
|
+
* settings: Settings,
|
|
1673
|
+
* utils: BasicUtils,
|
|
1674
|
+
* }
|
|
1675
|
+
* ) => any } JsdocVisitorBasic
|
|
1676
|
+
*/
|
|
1175
1677
|
/**
|
|
1176
|
-
* @typedef {ReturnType<typeof getUtils>} Utils
|
|
1177
1678
|
* @typedef {(
|
|
1178
1679
|
* arg: {
|
|
1179
1680
|
* context: import('eslint').Rule.RuleContext,
|
|
1180
1681
|
* sourceCode: import('eslint').SourceCode,
|
|
1181
1682
|
* indent: string,
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1683
|
+
* info: {
|
|
1684
|
+
* comment?: string|undefined,
|
|
1685
|
+
* lastIndex?: Integer|undefined
|
|
1686
|
+
* },
|
|
1687
|
+
* state: StateObject,
|
|
1688
|
+
* globalState: Map<string, Map<string, string>>,
|
|
1689
|
+
* jsdoc: import('comment-parser').Block,
|
|
1690
|
+
* jsdocNode: import('eslint').Rule.Node & {
|
|
1691
|
+
* range: [number, number]
|
|
1692
|
+
* },
|
|
1693
|
+
* node: Node|null,
|
|
1694
|
+
* allComments?: import('estree').Node[]
|
|
1695
|
+
* report: Report,
|
|
1696
|
+
* makeReport?: MakeReport,
|
|
1186
1697
|
* settings: Settings,
|
|
1187
1698
|
* utils: Utils,
|
|
1188
1699
|
* }
|
|
1189
1700
|
* ) => any } JsdocVisitor
|
|
1190
1701
|
*/
|
|
1702
|
+
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
1191
1703
|
/* eslint-enable jsdoc/no-undefined-types -- canonical still using an older version where not defined */
|
|
1192
1704
|
|
|
1193
1705
|
/**
|
|
1194
|
-
* @param {
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1706
|
+
* @param {{
|
|
1707
|
+
* comment?: string,
|
|
1708
|
+
* lastIndex?: Integer,
|
|
1709
|
+
* selector?: string,
|
|
1710
|
+
* isFunctionContext?: boolean,
|
|
1711
|
+
* }} info
|
|
1712
|
+
* @param {string} indent
|
|
1713
|
+
* @param {import('comment-parser').Block & {
|
|
1714
|
+
* inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
|
|
1715
|
+
* }} jsdoc
|
|
1716
|
+
* @param {RuleConfig} ruleConfig
|
|
1198
1717
|
* @param {import('eslint').Rule.RuleContext} context
|
|
1199
|
-
* @param {} lines
|
|
1718
|
+
* @param {string[]} lines
|
|
1200
1719
|
* @param {import('@es-joy/jsdoccomment').Token} jsdocNode
|
|
1201
|
-
* @param {} node
|
|
1720
|
+
* @param {Node|null} node
|
|
1202
1721
|
* @param {Settings} settings
|
|
1203
1722
|
* @param {import('eslint').SourceCode} sourceCode
|
|
1204
|
-
* @param {} iterator
|
|
1205
|
-
* @param {} state
|
|
1206
|
-
* @param {boolean} iteratingAll
|
|
1723
|
+
* @param {JsdocVisitor} iterator
|
|
1724
|
+
* @param {StateObject} state
|
|
1725
|
+
* @param {boolean} [iteratingAll]
|
|
1726
|
+
* @returns {void}
|
|
1207
1727
|
*/
|
|
1208
1728
|
const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => {
|
|
1209
|
-
const
|
|
1210
|
-
const
|
|
1729
|
+
const jsdocNde = /** @type {unknown} */jsdocNode;
|
|
1730
|
+
const report = makeReport(context, /** @type {import('estree').Node} */
|
|
1731
|
+
jsdocNde);
|
|
1732
|
+
const utils = getUtils(node, jsdoc, /** @type {import('eslint').AST.Token} */
|
|
1733
|
+
jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent);
|
|
1211
1734
|
if (!ruleConfig.checkInternal && settings.ignoreInternal && utils.hasTag('internal')) {
|
|
1212
1735
|
return;
|
|
1213
1736
|
}
|
|
@@ -1227,9 +1750,13 @@ const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, nod
|
|
|
1227
1750
|
globalState,
|
|
1228
1751
|
indent,
|
|
1229
1752
|
info,
|
|
1230
|
-
iteratingAll,
|
|
1231
1753
|
jsdoc,
|
|
1232
|
-
jsdocNode
|
|
1754
|
+
jsdocNode:
|
|
1755
|
+
/**
|
|
1756
|
+
* @type {import('eslint').Rule.Node & {
|
|
1757
|
+
* range: [number, number];}}
|
|
1758
|
+
*/
|
|
1759
|
+
jsdocNde,
|
|
1233
1760
|
node,
|
|
1234
1761
|
report,
|
|
1235
1762
|
settings,
|
|
@@ -1240,22 +1767,26 @@ const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, nod
|
|
|
1240
1767
|
};
|
|
1241
1768
|
|
|
1242
1769
|
/**
|
|
1243
|
-
* @param {} lines
|
|
1244
|
-
* @param {import('
|
|
1770
|
+
* @param {string[]} lines
|
|
1771
|
+
* @param {import('estree').Comment} jsdocNode
|
|
1245
1772
|
* @returns {[indent: string, jsdoc: import('comment-parser').Block & {
|
|
1246
|
-
* inlineTags: import('@es-joy/jsdoccomment').
|
|
1773
|
+
* inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
|
|
1247
1774
|
* }]}
|
|
1248
1775
|
*/
|
|
1249
1776
|
const getIndentAndJSDoc = function (lines, jsdocNode) {
|
|
1250
|
-
const sourceLine = lines[
|
|
1251
|
-
|
|
1777
|
+
const sourceLine = lines[/** @type {import('estree').SourceLocation} */
|
|
1778
|
+
jsdocNode.loc.start.line - 1];
|
|
1779
|
+
const indnt = sourceLine.charAt(0).repeat( /** @type {import('estree').SourceLocation} */
|
|
1780
|
+
jsdocNode.loc.start.column);
|
|
1252
1781
|
const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, '');
|
|
1253
1782
|
return [indnt, jsdc];
|
|
1254
1783
|
};
|
|
1255
1784
|
|
|
1256
1785
|
/**
|
|
1257
1786
|
*
|
|
1258
|
-
* @typedef {{node: Node
|
|
1787
|
+
* @typedef {{node: Node & {
|
|
1788
|
+
* range: [number, number]
|
|
1789
|
+
* }, state: StateObject}} NonCommentArgs
|
|
1259
1790
|
*/
|
|
1260
1791
|
|
|
1261
1792
|
/**
|
|
@@ -1265,9 +1796,20 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
|
|
|
1265
1796
|
* @property {true} [contextSelected] Whether to force a `contexts` check
|
|
1266
1797
|
* @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default
|
|
1267
1798
|
* regardless of context
|
|
1268
|
-
* @property {
|
|
1269
|
-
*
|
|
1270
|
-
* @property {
|
|
1799
|
+
* @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted)
|
|
1800
|
+
* @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted)
|
|
1801
|
+
* @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment
|
|
1802
|
+
* @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts
|
|
1803
|
+
* @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as
|
|
1804
|
+
* non-tracked may conduct further actions)
|
|
1805
|
+
* @property {true} [matchContext] Whether the rule expects contexts to be based on a match option
|
|
1806
|
+
* @property {(args: {
|
|
1807
|
+
* context: import('eslint').Rule.RuleContext,
|
|
1808
|
+
* state: StateObject,
|
|
1809
|
+
* settings: Settings,
|
|
1810
|
+
* utils: BasicUtils
|
|
1811
|
+
* }) => void} [exit] Handler to be executed upon exiting iteration of program AST
|
|
1812
|
+
* @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes
|
|
1271
1813
|
* to be supplied nodes without comments
|
|
1272
1814
|
*/
|
|
1273
1815
|
|
|
@@ -1277,31 +1819,46 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
|
|
|
1277
1819
|
*
|
|
1278
1820
|
* @param {JsdocVisitor} iterator
|
|
1279
1821
|
* @param {RuleConfig} ruleConfig The rule's configuration
|
|
1280
|
-
* @param contexts The `contexts` containing relevant `comment` info.
|
|
1281
|
-
* @param {boolean} additiveCommentContexts If true, will have a separate
|
|
1822
|
+
* @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info.
|
|
1823
|
+
* @param {boolean} [additiveCommentContexts] If true, will have a separate
|
|
1282
1824
|
* iteration for each matching comment context. Otherwise, will iterate
|
|
1283
1825
|
* once if there is a single matching comment context.
|
|
1284
1826
|
* @returns {import('eslint').Rule.RuleModule}
|
|
1285
1827
|
*/
|
|
1286
1828
|
const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => {
|
|
1287
1829
|
const trackedJsdocs = new Set();
|
|
1830
|
+
|
|
1831
|
+
/** @type {import('@es-joy/jsdoccomment').CommentHandler} */
|
|
1288
1832
|
let handler;
|
|
1833
|
+
|
|
1834
|
+
/** @type {Settings|false} */
|
|
1289
1835
|
let settings;
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
1839
|
+
* @param {Node|null} node
|
|
1840
|
+
* @param {import('estree').Comment[]} jsdocNodes
|
|
1841
|
+
* @param {StateObject} state
|
|
1842
|
+
* @param {boolean} [lastCall]
|
|
1843
|
+
* @returns {void}
|
|
1844
|
+
*/
|
|
1290
1845
|
const callIterator = (context, node, jsdocNodes, state, lastCall) => {
|
|
1291
1846
|
const sourceCode = context.getSourceCode();
|
|
1292
1847
|
const {
|
|
1293
1848
|
lines
|
|
1294
1849
|
} = sourceCode;
|
|
1295
|
-
const utils = getBasicUtils(context, settings);
|
|
1850
|
+
const utils = getBasicUtils(context, /** @type {Settings} */settings);
|
|
1296
1851
|
for (const jsdocNode of jsdocNodes) {
|
|
1297
|
-
|
|
1852
|
+
const jsdocNde = /** @type {unknown} */jsdocNode;
|
|
1853
|
+
if (!/^\/\*\*\s/u.test(sourceCode.getText( /** @type {import('estree').Node} */
|
|
1854
|
+
jsdocNde))) {
|
|
1298
1855
|
continue;
|
|
1299
1856
|
}
|
|
1300
1857
|
const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode);
|
|
1301
1858
|
if (additiveCommentContexts) {
|
|
1302
1859
|
for (const [idx, {
|
|
1303
1860
|
comment
|
|
1304
|
-
}] of contexts.entries()) {
|
|
1861
|
+
}] of /** @type {ContextObject[]} */contexts.entries()) {
|
|
1305
1862
|
if (comment && handler(comment, jsdoc) === false) {
|
|
1306
1863
|
continue;
|
|
1307
1864
|
}
|
|
@@ -1309,7 +1866,9 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1309
1866
|
comment,
|
|
1310
1867
|
lastIndex: idx,
|
|
1311
1868
|
selector: node === null || node === void 0 ? void 0 : node.type
|
|
1312
|
-
}, indent, jsdoc, ruleConfig, context, lines, jsdocNode,
|
|
1869
|
+
}, indent, jsdoc, ruleConfig, context, lines, jsdocNode, /** @type {Node} */
|
|
1870
|
+
node, /** @type {Settings} */
|
|
1871
|
+
settings, sourceCode, iterator, state, true);
|
|
1313
1872
|
}
|
|
1314
1873
|
continue;
|
|
1315
1874
|
}
|
|
@@ -1332,18 +1891,21 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1332
1891
|
} : {
|
|
1333
1892
|
lastIndex,
|
|
1334
1893
|
selector: node === null || node === void 0 ? void 0 : node.type
|
|
1335
|
-
}, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node,
|
|
1894
|
+
}, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, /** @type {Settings} */
|
|
1895
|
+
settings, sourceCode, iterator, state, true);
|
|
1336
1896
|
}
|
|
1897
|
+
const settngs = /** @type {Settings} */settings;
|
|
1337
1898
|
if (lastCall && ruleConfig.exit) {
|
|
1338
1899
|
ruleConfig.exit({
|
|
1339
1900
|
context,
|
|
1340
|
-
settings,
|
|
1901
|
+
settings: settngs,
|
|
1341
1902
|
state,
|
|
1342
1903
|
utils
|
|
1343
1904
|
});
|
|
1344
1905
|
}
|
|
1345
1906
|
};
|
|
1346
1907
|
return {
|
|
1908
|
+
// @ts-expect-error ESLint accepts
|
|
1347
1909
|
create(context) {
|
|
1348
1910
|
const sourceCode = context.getSourceCode();
|
|
1349
1911
|
settings = getSettings(context);
|
|
@@ -1355,29 +1917,38 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1355
1917
|
}
|
|
1356
1918
|
const state = {};
|
|
1357
1919
|
return {
|
|
1920
|
+
/**
|
|
1921
|
+
* @param {import('eslint').Rule.Node & {
|
|
1922
|
+
* range: [Integer, Integer];
|
|
1923
|
+
* }} node
|
|
1924
|
+
* @returns {void}
|
|
1925
|
+
*/
|
|
1358
1926
|
'*:not(Program)'(node) {
|
|
1359
|
-
const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
|
|
1927
|
+
const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, /** @type {Settings} */settings);
|
|
1360
1928
|
if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) {
|
|
1361
1929
|
return;
|
|
1362
1930
|
}
|
|
1363
1931
|
if (!commentNode) {
|
|
1364
1932
|
if (ruleConfig.nonComment) {
|
|
1933
|
+
const ste = /** @type {StateObject} */state;
|
|
1365
1934
|
ruleConfig.nonComment({
|
|
1366
1935
|
node,
|
|
1367
|
-
state
|
|
1936
|
+
state: ste
|
|
1368
1937
|
});
|
|
1369
1938
|
}
|
|
1370
1939
|
return;
|
|
1371
1940
|
}
|
|
1372
1941
|
trackedJsdocs.add(commentNode);
|
|
1373
|
-
callIterator(context, node, [
|
|
1942
|
+
callIterator(context, node, [/** @type {import('estree').Comment} */
|
|
1943
|
+
commentNode], /** @type {StateObject} */state);
|
|
1374
1944
|
},
|
|
1375
1945
|
'Program:exit'() {
|
|
1376
1946
|
const allComments = sourceCode.getAllComments();
|
|
1377
1947
|
const untrackedJSdoc = allComments.filter(node => {
|
|
1378
1948
|
return !trackedJsdocs.has(node);
|
|
1379
1949
|
});
|
|
1380
|
-
callIterator(context, null, untrackedJSdoc,
|
|
1950
|
+
callIterator(context, null, untrackedJSdoc, /** @type {StateObject} */
|
|
1951
|
+
state, true);
|
|
1381
1952
|
}
|
|
1382
1953
|
};
|
|
1383
1954
|
},
|
|
@@ -1389,7 +1960,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1389
1960
|
* Create an eslint rule that iterates over all JSDocs, regardless of whether
|
|
1390
1961
|
* they are attached to a function-like node.
|
|
1391
1962
|
*
|
|
1392
|
-
* @param {
|
|
1963
|
+
* @param {JsdocVisitorBasic} iterator
|
|
1393
1964
|
* @param {RuleConfig} ruleConfig
|
|
1394
1965
|
* @returns {import('eslint').Rule.RuleModule}
|
|
1395
1966
|
*/
|
|
@@ -1403,15 +1974,11 @@ const checkFile = (iterator, ruleConfig) => {
|
|
|
1403
1974
|
}
|
|
1404
1975
|
return {
|
|
1405
1976
|
'Program:exit'() {
|
|
1406
|
-
const
|
|
1407
|
-
const {
|
|
1408
|
-
lines
|
|
1409
|
-
} = sourceCode;
|
|
1977
|
+
const allComms = /** @type {unknown} */sourceCode.getAllComments();
|
|
1410
1978
|
const utils = getBasicUtils(context, settings);
|
|
1411
1979
|
iterator({
|
|
1412
|
-
allComments,
|
|
1980
|
+
allComments: /** @type {import('estree').Node[]} */allComms,
|
|
1413
1981
|
context,
|
|
1414
|
-
lines,
|
|
1415
1982
|
makeReport,
|
|
1416
1983
|
settings,
|
|
1417
1984
|
sourceCode,
|
|
@@ -1438,7 +2005,7 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
1438
2005
|
throw new TypeError('The iterator argument must be a function.');
|
|
1439
2006
|
}
|
|
1440
2007
|
if (ruleConfig.checkFile) {
|
|
1441
|
-
return checkFile(iterator, ruleConfig);
|
|
2008
|
+
return checkFile( /** @type {JsdocVisitorBasic} */iterator, ruleConfig);
|
|
1442
2009
|
}
|
|
1443
2010
|
if (ruleConfig.iterateAllJsdocs) {
|
|
1444
2011
|
return iterateAllJsdocs(iterator, ruleConfig);
|
|
@@ -1453,14 +2020,19 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
1453
2020
|
* a reference to the context which hold all important information
|
|
1454
2021
|
* like settings and the sourcecode to check.
|
|
1455
2022
|
* @returns {import('eslint').Rule.RuleListener}
|
|
1456
|
-
* a
|
|
2023
|
+
* a listener with parser callback function.
|
|
1457
2024
|
*/
|
|
1458
2025
|
create(context) {
|
|
1459
2026
|
const settings = getSettings(context);
|
|
1460
2027
|
if (!settings) {
|
|
1461
2028
|
return {};
|
|
1462
2029
|
}
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* @type {Context[]|undefined}
|
|
2033
|
+
*/
|
|
1463
2034
|
let contexts;
|
|
2035
|
+
/* eslint-enable jsdoc/valid-types -- Old version */
|
|
1464
2036
|
if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) {
|
|
1465
2037
|
var _context$options$2, _contexts, _contexts2;
|
|
1466
2038
|
contexts = ruleConfig.matchContext && (_context$options$2 = context.options[0]) !== null && _context$options$2 !== void 0 && _context$options$2.match ? context.options[0].match : _jsdocUtils.default.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings);
|
|
@@ -1477,23 +2049,33 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
1477
2049
|
}
|
|
1478
2050
|
const hasPlainAny = (_contexts = contexts) === null || _contexts === void 0 ? void 0 : _contexts.includes('any');
|
|
1479
2051
|
const hasObjectAny = !hasPlainAny && ((_contexts2 = contexts) === null || _contexts2 === void 0 ? void 0 : _contexts2.find(ctxt => {
|
|
2052
|
+
if (typeof ctxt === 'string') {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
1480
2055
|
return (ctxt === null || ctxt === void 0 ? void 0 : ctxt.context) === 'any';
|
|
1481
2056
|
}));
|
|
1482
2057
|
if (hasPlainAny || hasObjectAny) {
|
|
1483
|
-
return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? contexts : null, ruleConfig.matchContext).create(context);
|
|
2058
|
+
return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? /** @type {ContextObject[]} */contexts : null, ruleConfig.matchContext).create(context);
|
|
1484
2059
|
}
|
|
1485
2060
|
}
|
|
1486
2061
|
const sourceCode = context.getSourceCode();
|
|
1487
2062
|
const {
|
|
1488
2063
|
lines
|
|
1489
2064
|
} = sourceCode;
|
|
2065
|
+
|
|
2066
|
+
/* eslint-disable jsdoc/no-undefined-types -- TS */
|
|
2067
|
+
/** @type {Partial<StateObject>} */
|
|
1490
2068
|
const state = {};
|
|
2069
|
+
/* eslint-enable jsdoc/no-undefined-types -- TS */
|
|
2070
|
+
|
|
2071
|
+
/** @type {CheckJsdoc} */
|
|
1491
2072
|
const checkJsdoc = (info, handler, node) => {
|
|
1492
2073
|
const jsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
|
|
1493
2074
|
if (!jsdocNode) {
|
|
1494
2075
|
return;
|
|
1495
2076
|
}
|
|
1496
|
-
const [indent, jsdoc] = getIndentAndJSDoc(lines,
|
|
2077
|
+
const [indent, jsdoc] = getIndentAndJSDoc(lines, /** @type {import('estree').Comment} */
|
|
2078
|
+
jsdocNode);
|
|
1497
2079
|
if (
|
|
1498
2080
|
// Note, `handler` should already be bound in its first argument
|
|
1499
2081
|
// with these only to be called after the value of
|
|
@@ -1501,8 +2083,11 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
1501
2083
|
handler && handler(jsdoc) === false) {
|
|
1502
2084
|
return;
|
|
1503
2085
|
}
|
|
1504
|
-
iterate(info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator,
|
|
2086
|
+
iterate(info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, /** @type {StateObject} */
|
|
2087
|
+
state);
|
|
1505
2088
|
};
|
|
2089
|
+
|
|
2090
|
+
/** @type {import('eslint').Rule.RuleListener} */
|
|
1506
2091
|
let contextObject = {};
|
|
1507
2092
|
if (contexts && (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext)) {
|
|
1508
2093
|
contextObject = _jsdocUtils.default.getContextObject(contexts, checkJsdoc, (0, _jsdoccomment.commentHandler)(settings));
|
|
@@ -1513,15 +2098,21 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
1513
2098
|
}, null);
|
|
1514
2099
|
}
|
|
1515
2100
|
}
|
|
1516
|
-
if (ruleConfig.exit) {
|
|
2101
|
+
if (typeof ruleConfig.exit === 'function') {
|
|
1517
2102
|
contextObject['Program:exit'] = () => {
|
|
2103
|
+
const ste = /** @type {StateObject} */state;
|
|
2104
|
+
/* eslint-disable jsdoc/no-undefined-types -- Bug */
|
|
2105
|
+
// @ts-expect-error `utils` not needed at this point
|
|
2106
|
+
/** @type {Required<RuleConfig>} */
|
|
1518
2107
|
ruleConfig.exit({
|
|
1519
2108
|
context,
|
|
1520
2109
|
settings,
|
|
1521
|
-
state
|
|
2110
|
+
state: ste
|
|
1522
2111
|
});
|
|
2112
|
+
/* eslint-enable jsdoc/no-undefined-types -- Bug */
|
|
1523
2113
|
};
|
|
1524
2114
|
}
|
|
2115
|
+
|
|
1525
2116
|
return contextObject;
|
|
1526
2117
|
},
|
|
1527
2118
|
meta: ruleConfig.meta
|