eslint-plugin-jsdoc 55.3.0 → 56.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/cjs/WarnSettings.d.ts +16 -0
  2. package/dist/cjs/WarnSettings.js +30 -0
  3. package/dist/cjs/alignTransform.d.ts +33 -0
  4. package/dist/cjs/alignTransform.js +285 -0
  5. package/dist/cjs/defaultTagOrder.d.ts +4 -0
  6. package/dist/cjs/defaultTagOrder.js +152 -0
  7. package/dist/cjs/exportParser.d.ts +40 -0
  8. package/dist/cjs/exportParser.js +754 -0
  9. package/dist/cjs/getDefaultTagStructureForMode.d.ts +10 -0
  10. package/dist/cjs/getDefaultTagStructureForMode.js +840 -0
  11. package/dist/cjs/getJsdocProcessorPlugin.cjs +4 -0
  12. package/dist/cjs/getJsdocProcessorPlugin.d.cts +1 -0
  13. package/dist/cjs/getJsdocProcessorPlugin.d.ts +66 -0
  14. package/dist/cjs/getJsdocProcessorPlugin.js +553 -0
  15. package/dist/cjs/index-cjs.d.ts +16 -0
  16. package/dist/cjs/index-cjs.js +492 -0
  17. package/dist/cjs/index.cjs.cjs +6 -0
  18. package/dist/cjs/index.cjs.d.cts +2 -0
  19. package/dist/cjs/iterateJsdoc.cjs +38 -0
  20. package/dist/cjs/iterateJsdoc.d.cts +2 -0
  21. package/dist/cjs/iterateJsdoc.d.ts +462 -0
  22. package/dist/cjs/iterateJsdoc.js +1981 -0
  23. package/dist/cjs/jsdocUtils.d.ts +454 -0
  24. package/dist/cjs/jsdocUtils.js +1470 -0
  25. package/dist/cjs/rules/checkAccess.d.ts +2 -0
  26. package/dist/cjs/rules/checkAccess.js +35 -0
  27. package/dist/cjs/rules/checkAlignment.d.ts +2 -0
  28. package/dist/cjs/rules/checkAlignment.js +63 -0
  29. package/dist/cjs/rules/checkExamples.d.ts +3 -0
  30. package/dist/cjs/rules/checkExamples.js +486 -0
  31. package/dist/cjs/rules/checkIndentation.d.ts +2 -0
  32. package/dist/cjs/rules/checkIndentation.js +66 -0
  33. package/dist/cjs/rules/checkLineAlignment.d.ts +9 -0
  34. package/dist/cjs/rules/checkLineAlignment.js +297 -0
  35. package/dist/cjs/rules/checkParamNames.d.ts +2 -0
  36. package/dist/cjs/rules/checkParamNames.js +320 -0
  37. package/dist/cjs/rules/checkPropertyNames.d.ts +2 -0
  38. package/dist/cjs/rules/checkPropertyNames.js +105 -0
  39. package/dist/cjs/rules/checkSyntax.d.ts +2 -0
  40. package/dist/cjs/rules/checkSyntax.js +27 -0
  41. package/dist/cjs/rules/checkTagNames.d.ts +2 -0
  42. package/dist/cjs/rules/checkTagNames.js +252 -0
  43. package/dist/cjs/rules/checkTemplateNames.d.ts +2 -0
  44. package/dist/cjs/rules/checkTemplateNames.js +189 -0
  45. package/dist/cjs/rules/checkTypes.d.ts +2 -0
  46. package/dist/cjs/rules/checkTypes.js +421 -0
  47. package/dist/cjs/rules/checkValues.d.ts +2 -0
  48. package/dist/cjs/rules/checkValues.js +163 -0
  49. package/dist/cjs/rules/convertToJsdocComments.d.ts +251 -0
  50. package/dist/cjs/rules/convertToJsdocComments.js +313 -0
  51. package/dist/cjs/rules/emptyTags.d.ts +2 -0
  52. package/dist/cjs/rules/emptyTags.js +79 -0
  53. package/dist/cjs/rules/implementsOnClasses.d.ts +2 -0
  54. package/dist/cjs/rules/implementsOnClasses.js +63 -0
  55. package/dist/cjs/rules/importsAsDependencies.d.ts +2 -0
  56. package/dist/cjs/rules/importsAsDependencies.js +105 -0
  57. package/dist/cjs/rules/informativeDocs.d.ts +2 -0
  58. package/dist/cjs/rules/informativeDocs.js +153 -0
  59. package/dist/cjs/rules/linesBeforeBlock.d.ts +2 -0
  60. package/dist/cjs/rules/linesBeforeBlock.js +106 -0
  61. package/dist/cjs/rules/matchDescription.d.ts +2 -0
  62. package/dist/cjs/rules/matchDescription.js +240 -0
  63. package/dist/cjs/rules/matchName.d.ts +2 -0
  64. package/dist/cjs/rules/matchName.js +122 -0
  65. package/dist/cjs/rules/multilineBlocks.d.ts +2 -0
  66. package/dist/cjs/rules/multilineBlocks.js +339 -0
  67. package/dist/cjs/rules/noBadBlocks.d.ts +2 -0
  68. package/dist/cjs/rules/noBadBlocks.js +88 -0
  69. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +2 -0
  70. package/dist/cjs/rules/noBlankBlockDescriptions.js +56 -0
  71. package/dist/cjs/rules/noBlankBlocks.d.ts +2 -0
  72. package/dist/cjs/rules/noBlankBlocks.js +41 -0
  73. package/dist/cjs/rules/noDefaults.d.ts +2 -0
  74. package/dist/cjs/rules/noDefaults.js +84 -0
  75. package/dist/cjs/rules/noMissingSyntax.d.ts +9 -0
  76. package/dist/cjs/rules/noMissingSyntax.js +164 -0
  77. package/dist/cjs/rules/noMultiAsterisks.d.ts +2 -0
  78. package/dist/cjs/rules/noMultiAsterisks.js +83 -0
  79. package/dist/cjs/rules/noRestrictedSyntax.d.ts +2 -0
  80. package/dist/cjs/rules/noRestrictedSyntax.js +75 -0
  81. package/dist/cjs/rules/noTypes.d.ts +2 -0
  82. package/dist/cjs/rules/noTypes.js +88 -0
  83. package/dist/cjs/rules/noUndefinedTypes.d.ts +2 -0
  84. package/dist/cjs/rules/noUndefinedTypes.js +451 -0
  85. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +2 -0
  86. package/dist/cjs/rules/requireAsteriskPrefix.js +144 -0
  87. package/dist/cjs/rules/requireDescription.d.ts +2 -0
  88. package/dist/cjs/rules/requireDescription.js +136 -0
  89. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +2 -0
  90. package/dist/cjs/rules/requireDescriptionCompleteSentence.js +258 -0
  91. package/dist/cjs/rules/requireExample.d.ts +2 -0
  92. package/dist/cjs/rules/requireExample.js +103 -0
  93. package/dist/cjs/rules/requireFileOverview.d.ts +2 -0
  94. package/dist/cjs/rules/requireFileOverview.js +117 -0
  95. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +2 -0
  96. package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +144 -0
  97. package/dist/cjs/rules/requireJsdoc.d.ts +25 -0
  98. package/dist/cjs/rules/requireJsdoc.js +629 -0
  99. package/dist/cjs/rules/requireParam.d.ts +3 -0
  100. package/dist/cjs/rules/requireParam.js +480 -0
  101. package/dist/cjs/rules/requireParamDescription.d.ts +2 -0
  102. package/dist/cjs/rules/requireParamDescription.js +77 -0
  103. package/dist/cjs/rules/requireParamName.d.ts +2 -0
  104. package/dist/cjs/rules/requireParamName.js +52 -0
  105. package/dist/cjs/rules/requireParamType.d.ts +2 -0
  106. package/dist/cjs/rules/requireParamType.js +77 -0
  107. package/dist/cjs/rules/requireProperty.d.ts +2 -0
  108. package/dist/cjs/rules/requireProperty.js +44 -0
  109. package/dist/cjs/rules/requirePropertyDescription.d.ts +2 -0
  110. package/dist/cjs/rules/requirePropertyDescription.js +22 -0
  111. package/dist/cjs/rules/requirePropertyName.d.ts +2 -0
  112. package/dist/cjs/rules/requirePropertyName.js +22 -0
  113. package/dist/cjs/rules/requirePropertyType.d.ts +2 -0
  114. package/dist/cjs/rules/requirePropertyType.js +22 -0
  115. package/dist/cjs/rules/requireReturns.d.ts +2 -0
  116. package/dist/cjs/rules/requireReturns.js +197 -0
  117. package/dist/cjs/rules/requireReturnsCheck.d.ts +2 -0
  118. package/dist/cjs/rules/requireReturnsCheck.js +108 -0
  119. package/dist/cjs/rules/requireReturnsDescription.d.ts +2 -0
  120. package/dist/cjs/rules/requireReturnsDescription.js +58 -0
  121. package/dist/cjs/rules/requireReturnsType.d.ts +2 -0
  122. package/dist/cjs/rules/requireReturnsType.js +52 -0
  123. package/dist/cjs/rules/requireTemplate.d.ts +2 -0
  124. package/dist/cjs/rules/requireTemplate.js +173 -0
  125. package/dist/cjs/rules/requireThrows.d.ts +2 -0
  126. package/dist/cjs/rules/requireThrows.js +101 -0
  127. package/dist/cjs/rules/requireYields.d.ts +2 -0
  128. package/dist/cjs/rules/requireYields.js +172 -0
  129. package/dist/cjs/rules/requireYieldsCheck.d.ts +2 -0
  130. package/dist/cjs/rules/requireYieldsCheck.js +164 -0
  131. package/dist/cjs/rules/sortTags.d.ts +2 -0
  132. package/dist/cjs/rules/sortTags.js +392 -0
  133. package/dist/cjs/rules/tagLines.d.ts +2 -0
  134. package/dist/cjs/rules/tagLines.js +259 -0
  135. package/dist/cjs/rules/textEscaping.d.ts +2 -0
  136. package/dist/cjs/rules/textEscaping.js +125 -0
  137. package/dist/cjs/rules/typeFormatting.d.ts +2 -0
  138. package/dist/cjs/rules/typeFormatting.js +328 -0
  139. package/dist/cjs/rules/validTypes.d.ts +2 -0
  140. package/dist/cjs/rules/validTypes.js +333 -0
  141. package/dist/cjs/tagNames.d.ts +15 -0
  142. package/dist/cjs/tagNames.js +209 -0
  143. package/dist/cjs/utils/hasReturnValue.d.ts +19 -0
  144. package/dist/cjs/utils/hasReturnValue.js +469 -0
  145. package/dist/getJsdocProcessorPlugin.cts +3 -0
  146. package/dist/index.cjs.cts +3 -0
  147. package/dist/iterateJsdoc.cts +6 -0
  148. package/dist/rules/typeFormatting.cjs +82 -38
  149. package/dist/rules/typeFormatting.cjs.map +1 -1
  150. package/dist/rules.d.ts +4 -7
  151. package/package.json +24 -13
  152. package/src/getJsdocProcessorPlugin.cts +3 -0
  153. package/src/index.cjs.cts +3 -0
  154. package/src/iterateJsdoc.cts +6 -0
  155. package/src/rules/typeFormatting.js +104 -40
  156. package/src/rules.d.ts +4 -7
@@ -0,0 +1,339 @@
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
+ * @param {import('@es-joy/jsdoccomment').JsdocBlockWithInline} jsdoc
9
+ * @param {import('../iterateJsdoc.js').Utils} utils
10
+ * @param {number} requireSingleLineUnderCount
11
+ */
12
+ const checkForShortTags = (jsdoc, utils, requireSingleLineUnderCount) => {
13
+ if (!requireSingleLineUnderCount || !jsdoc.tags.length) {
14
+ return false;
15
+ }
16
+ let lastLineWithTag = 0;
17
+ let isUnderCountLimit = false;
18
+ let hasMultiDescOrType = false;
19
+ const tagLines = jsdoc.source.reduce((acc, { tokens: { delimiter, description: desc, name, postDelimiter, postName, postTag, postType, start, tag, type, }, }, idx) => {
20
+ if (tag.length) {
21
+ lastLineWithTag = idx;
22
+ if (start.length + delimiter.length + postDelimiter.length +
23
+ type.length + postType.length + name.length + postName.length +
24
+ tag.length + postTag.length + desc.length <
25
+ requireSingleLineUnderCount) {
26
+ isUnderCountLimit = true;
27
+ }
28
+ return acc + 1;
29
+ }
30
+ else if (desc.length || type.length) {
31
+ hasMultiDescOrType = true;
32
+ return acc;
33
+ }
34
+ return acc;
35
+ }, 0);
36
+ // Could be tagLines > 1
37
+ if (!hasMultiDescOrType && isUnderCountLimit && tagLines === 1) {
38
+ const fixer = () => {
39
+ const tokens = jsdoc.source[lastLineWithTag].tokens;
40
+ jsdoc.source = [
41
+ {
42
+ number: 0,
43
+ source: '',
44
+ tokens: utils.seedTokens({
45
+ delimiter: '/**',
46
+ description: tokens.description.trimEnd() + ' ',
47
+ end: '*/',
48
+ name: tokens.name,
49
+ postDelimiter: ' ',
50
+ postName: tokens.postName,
51
+ postTag: tokens.postTag,
52
+ postType: tokens.postType,
53
+ start: jsdoc.source[0].tokens.start,
54
+ tag: tokens.tag,
55
+ type: tokens.type,
56
+ }),
57
+ },
58
+ ];
59
+ };
60
+ utils.reportJSDoc('Description is too short to be multi-line.', null, fixer);
61
+ return true;
62
+ }
63
+ return false;
64
+ };
65
+ /**
66
+ * @param {import('@es-joy/jsdoccomment').JsdocBlockWithInline} jsdoc
67
+ * @param {import('../iterateJsdoc.js').Utils} utils
68
+ * @param {number} requireSingleLineUnderCount
69
+ */
70
+ const checkForShortDescriptions = (jsdoc, utils, requireSingleLineUnderCount) => {
71
+ if (!requireSingleLineUnderCount || jsdoc.tags.length) {
72
+ return false;
73
+ }
74
+ let lastLineWithDesc = 0;
75
+ let isUnderCountLimit = false;
76
+ const descLines = jsdoc.source.reduce((acc, { tokens: { delimiter, description: desc, postDelimiter, start, }, }, idx) => {
77
+ if (desc.length) {
78
+ lastLineWithDesc = idx;
79
+ if (start.length + delimiter.length + postDelimiter.length + desc.length <
80
+ requireSingleLineUnderCount) {
81
+ isUnderCountLimit = true;
82
+ }
83
+ return acc + 1;
84
+ }
85
+ return acc;
86
+ }, 0);
87
+ // Could be descLines > 1
88
+ if (isUnderCountLimit && descLines === 1) {
89
+ const fixer = () => {
90
+ const desc = jsdoc.source[lastLineWithDesc].tokens.description;
91
+ jsdoc.source = [
92
+ {
93
+ number: 0,
94
+ source: '',
95
+ tokens: utils.seedTokens({
96
+ delimiter: '/**',
97
+ description: desc.trimEnd() + ' ',
98
+ end: '*/',
99
+ postDelimiter: ' ',
100
+ start: jsdoc.source[0].tokens.start,
101
+ }),
102
+ },
103
+ ];
104
+ };
105
+ utils.reportJSDoc('Description is too short to be multi-line.', null, fixer);
106
+ return true;
107
+ }
108
+ return false;
109
+ };
110
+ exports.default = (0, iterateJsdoc_js_1.default)(({ context, jsdoc, utils, }) => {
111
+ const { allowMultipleTags = true, minimumLengthForMultiline = Number.POSITIVE_INFINITY, multilineTags = [
112
+ '*',
113
+ ], noFinalLineText = true, noMultilineBlocks = false, noSingleLineBlocks = false, noZeroLineText = true, requireSingleLineUnderCount = null, singleLineTags = [
114
+ 'lends', 'type',
115
+ ], } = context.options[0] || {};
116
+ const { source: [{ tokens, },], } = jsdoc;
117
+ const { description, tag, } = tokens;
118
+ const sourceLength = jsdoc.source.length;
119
+ /**
120
+ * @param {string} tagName
121
+ * @returns {boolean}
122
+ */
123
+ const isInvalidSingleLine = (tagName) => {
124
+ return noSingleLineBlocks &&
125
+ (!tagName ||
126
+ !singleLineTags.includes(tagName) && !singleLineTags.includes('*'));
127
+ };
128
+ if (sourceLength === 1) {
129
+ if (!isInvalidSingleLine(tag.slice(1))) {
130
+ return;
131
+ }
132
+ const fixer = () => {
133
+ utils.makeMultiline();
134
+ };
135
+ utils.reportJSDoc('Single line blocks are not permitted by your configuration.', null, fixer, true);
136
+ return;
137
+ }
138
+ if (checkForShortDescriptions(jsdoc, utils, requireSingleLineUnderCount)) {
139
+ return;
140
+ }
141
+ if (checkForShortTags(jsdoc, utils, requireSingleLineUnderCount)) {
142
+ return;
143
+ }
144
+ const lineChecks = () => {
145
+ if (noZeroLineText &&
146
+ (tag || description)) {
147
+ const fixer = () => {
148
+ const line = {
149
+ ...tokens,
150
+ };
151
+ utils.emptyTokens(tokens);
152
+ const { tokens: { delimiter, start, }, } = jsdoc.source[1];
153
+ utils.addLine(1, {
154
+ ...line,
155
+ delimiter,
156
+ start,
157
+ });
158
+ };
159
+ utils.reportJSDoc('Should have no text on the "0th" line (after the `/**`).', null, fixer);
160
+ return;
161
+ }
162
+ const finalLine = jsdoc.source[jsdoc.source.length - 1];
163
+ const finalLineTokens = finalLine.tokens;
164
+ if (noFinalLineText &&
165
+ finalLineTokens.description.trim()) {
166
+ const fixer = () => {
167
+ const line = {
168
+ ...finalLineTokens,
169
+ };
170
+ line.description = line.description.trimEnd();
171
+ const { delimiter, } = line;
172
+ for (const prop of [
173
+ 'delimiter',
174
+ 'postDelimiter',
175
+ 'tag',
176
+ 'type',
177
+ 'lineEnd',
178
+ 'postType',
179
+ 'postTag',
180
+ 'name',
181
+ 'postName',
182
+ 'description',
183
+ ]) {
184
+ finalLineTokens[
185
+ /**
186
+ * @type {"delimiter"|"postDelimiter"|"tag"|"type"|
187
+ * "lineEnd"|"postType"|"postTag"|"name"|
188
+ * "postName"|"description"}
189
+ */ (prop)] = '';
190
+ }
191
+ utils.addLine(jsdoc.source.length - 1, {
192
+ ...line,
193
+ delimiter,
194
+ end: '',
195
+ });
196
+ };
197
+ utils.reportJSDoc('Should have no text on the final line (before the `*/`).', null, fixer);
198
+ }
199
+ };
200
+ if (noMultilineBlocks) {
201
+ if (jsdoc.tags.length &&
202
+ (multilineTags.includes('*') || utils.hasATag(multilineTags))) {
203
+ lineChecks();
204
+ return;
205
+ }
206
+ if (jsdoc.description.length >= minimumLengthForMultiline) {
207
+ lineChecks();
208
+ return;
209
+ }
210
+ if (noSingleLineBlocks &&
211
+ (!jsdoc.tags.length ||
212
+ !utils.filterTags(({ tag: tg, }) => {
213
+ return !isInvalidSingleLine(tg);
214
+ }).length)) {
215
+ utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
216
+ 'your configuration but fixing would result in a single ' +
217
+ 'line block which you have prohibited with `noSingleLineBlocks`.');
218
+ return;
219
+ }
220
+ if (jsdoc.tags.length > 1) {
221
+ if (!allowMultipleTags) {
222
+ utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
223
+ 'your configuration but the block has multiple tags.');
224
+ return;
225
+ }
226
+ }
227
+ else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) {
228
+ if (!allowMultipleTags) {
229
+ utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
230
+ 'your configuration but the block has a description with a tag.');
231
+ return;
232
+ }
233
+ }
234
+ else {
235
+ const fixer = () => {
236
+ jsdoc.source = [
237
+ {
238
+ number: 1,
239
+ source: '',
240
+ tokens: jsdoc.source.reduce((obj, { tokens: { description: desc, lineEnd, name: nme, postName, postTag, postType, tag: tg, type: typ, }, }) => {
241
+ if (typ) {
242
+ obj.type = typ;
243
+ }
244
+ if (tg && typ && nme) {
245
+ obj.postType = postType;
246
+ }
247
+ if (nme) {
248
+ obj.name += nme;
249
+ }
250
+ if (nme && desc) {
251
+ obj.postName = postName;
252
+ }
253
+ obj.description += desc;
254
+ const nameOrDescription = obj.description || obj.name;
255
+ if (nameOrDescription && nameOrDescription.slice(-1) !== ' ') {
256
+ obj.description += ' ';
257
+ }
258
+ obj.lineEnd = lineEnd;
259
+ // Already filtered for multiple tags
260
+ obj.tag += tg;
261
+ if (tg) {
262
+ obj.postTag = postTag || ' ';
263
+ }
264
+ return obj;
265
+ }, utils.seedTokens({
266
+ delimiter: '/**',
267
+ end: '*/',
268
+ postDelimiter: ' ',
269
+ })),
270
+ },
271
+ ];
272
+ };
273
+ utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
274
+ 'your configuration.', null, fixer);
275
+ return;
276
+ }
277
+ }
278
+ lineChecks();
279
+ }, {
280
+ iterateAllJsdocs: true,
281
+ meta: {
282
+ docs: {
283
+ description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.',
284
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/multiline-blocks.md#repos-sticky-header',
285
+ },
286
+ fixable: 'code',
287
+ schema: [
288
+ {
289
+ additionalProperties: false,
290
+ properties: {
291
+ allowMultipleTags: {
292
+ type: 'boolean',
293
+ },
294
+ minimumLengthForMultiline: {
295
+ type: 'integer',
296
+ },
297
+ multilineTags: {
298
+ anyOf: [
299
+ {
300
+ enum: [
301
+ '*',
302
+ ],
303
+ type: 'string',
304
+ }, {
305
+ items: {
306
+ type: 'string',
307
+ },
308
+ type: 'array',
309
+ },
310
+ ],
311
+ },
312
+ noFinalLineText: {
313
+ type: 'boolean',
314
+ },
315
+ noMultilineBlocks: {
316
+ type: 'boolean',
317
+ },
318
+ noSingleLineBlocks: {
319
+ type: 'boolean',
320
+ },
321
+ noZeroLineText: {
322
+ type: 'boolean',
323
+ },
324
+ requireSingleLineUnderCount: {
325
+ type: 'number',
326
+ },
327
+ singleLineTags: {
328
+ items: {
329
+ type: 'string',
330
+ },
331
+ type: 'array',
332
+ },
333
+ },
334
+ type: 'object',
335
+ },
336
+ ],
337
+ type: 'suggestion',
338
+ },
339
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
@@ -0,0 +1,88 @@
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
+ const comment_parser_1 = require("comment-parser");
8
+ // Neither a single nor 3+ asterisks are valid jsdoc per
9
+ // https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code
10
+ const commentRegexp = /^\/\*(?!\*)/v;
11
+ const extraAsteriskCommentRegexp = /^\/\*{3,}/v;
12
+ exports.default = (0, iterateJsdoc_js_1.default)(({ allComments, context, makeReport, sourceCode, }) => {
13
+ const [{ ignore = [
14
+ 'ts-check',
15
+ 'ts-expect-error',
16
+ 'ts-ignore',
17
+ 'ts-nocheck',
18
+ ], preventAllMultiAsteriskBlocks = false, } = {},] = context.options;
19
+ let extraAsterisks = false;
20
+ const nonJsdocNodes = /** @type {import('estree').Node[]} */ (allComments).filter((comment) => {
21
+ const commentText = sourceCode.getText(comment);
22
+ const initialText = commentText.replace(commentRegexp, '').trimStart();
23
+ if ([
24
+ 'eslint',
25
+ ].some((directive) => {
26
+ return initialText.startsWith(directive);
27
+ })) {
28
+ return false;
29
+ }
30
+ let sliceIndex = 2;
31
+ if (!commentRegexp.test(commentText)) {
32
+ const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];
33
+ if (!multiline) {
34
+ return false;
35
+ }
36
+ sliceIndex = multiline.length;
37
+ extraAsterisks = true;
38
+ if (preventAllMultiAsteriskBlocks) {
39
+ return true;
40
+ }
41
+ }
42
+ const tags = ((0, comment_parser_1.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`)[0] || {}).tags ?? [];
43
+ return tags.length && !tags.some(({ tag, }) => {
44
+ return ignore.includes(tag);
45
+ });
46
+ });
47
+ if (!nonJsdocNodes.length) {
48
+ return;
49
+ }
50
+ for (const node of nonJsdocNodes) {
51
+ const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (makeReport)(context, node);
52
+ // eslint-disable-next-line no-loop-func
53
+ const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
54
+ const text = sourceCode.getText(node);
55
+ return fixer.replaceText(node, extraAsterisks ?
56
+ text.replace(extraAsteriskCommentRegexp, '/**') :
57
+ text.replace('/*', '/**'));
58
+ };
59
+ report('Expected JSDoc-like comment to begin with two asterisks.', fix);
60
+ }
61
+ }, {
62
+ checkFile: true,
63
+ meta: {
64
+ docs: {
65
+ description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',
66
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',
67
+ },
68
+ fixable: 'code',
69
+ schema: [
70
+ {
71
+ additionalProperties: false,
72
+ properties: {
73
+ ignore: {
74
+ items: {
75
+ type: 'string',
76
+ },
77
+ type: 'array',
78
+ },
79
+ preventAllMultiAsteriskBlocks: {
80
+ type: 'boolean',
81
+ },
82
+ },
83
+ type: 'object',
84
+ },
85
+ ],
86
+ type: 'layout',
87
+ },
88
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
@@ -0,0 +1,56 @@
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
+ const anyWhitespaceLines = /^\s*$/v;
8
+ const atLeastTwoLinesWhitespace = /^[ \t]*\n[ \t]*\n\s*$/v;
9
+ exports.default = (0, iterateJsdoc_js_1.default)(({ jsdoc, utils, }) => {
10
+ const { description, descriptions, lastDescriptionLine, } = utils.getDescription();
11
+ const regex = jsdoc.tags.length ?
12
+ anyWhitespaceLines :
13
+ atLeastTwoLinesWhitespace;
14
+ if (descriptions.length && regex.test(description)) {
15
+ if (jsdoc.tags.length) {
16
+ utils.reportJSDoc('There should be no blank lines in block descriptions followed by tags.', {
17
+ line: lastDescriptionLine,
18
+ }, () => {
19
+ utils.setBlockDescription(() => {
20
+ // Remove all lines
21
+ return [];
22
+ });
23
+ });
24
+ }
25
+ else {
26
+ utils.reportJSDoc('There should be no extra blank lines in block descriptions not followed by tags.', {
27
+ line: lastDescriptionLine,
28
+ }, () => {
29
+ utils.setBlockDescription((info, seedTokens) => {
30
+ return [
31
+ // Keep the starting line
32
+ {
33
+ number: 0,
34
+ source: '',
35
+ tokens: seedTokens({
36
+ ...info,
37
+ description: '',
38
+ }),
39
+ },
40
+ ];
41
+ });
42
+ });
43
+ }
44
+ }
45
+ }, {
46
+ iterateAllJsdocs: true,
47
+ meta: {
48
+ docs: {
49
+ description: 'Detects and removes extra lines of a blank block description',
50
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-block-descriptions.md#repos-sticky-header',
51
+ },
52
+ fixable: 'whitespace',
53
+ schema: [],
54
+ type: 'layout',
55
+ },
56
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
@@ -0,0 +1,41 @@
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, jsdoc, utils, }) => {
8
+ if (jsdoc.tags.length) {
9
+ return;
10
+ }
11
+ const { description, lastDescriptionLine, } = utils.getDescription();
12
+ if (description.trim()) {
13
+ return;
14
+ }
15
+ const { enableFixer, } = context.options[0] || {};
16
+ utils.reportJSDoc('No empty blocks', {
17
+ line: lastDescriptionLine,
18
+ }, enableFixer ? () => {
19
+ jsdoc.source.splice(0);
20
+ } : null);
21
+ }, {
22
+ iterateAllJsdocs: true,
23
+ meta: {
24
+ docs: {
25
+ description: 'Removes empty blocks with nothing but possibly line breaks',
26
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-blocks.md#repos-sticky-header',
27
+ },
28
+ fixable: 'code',
29
+ schema: [
30
+ {
31
+ additionalProperties: false,
32
+ properties: {
33
+ enableFixer: {
34
+ type: 'boolean',
35
+ },
36
+ },
37
+ },
38
+ ],
39
+ type: 'suggestion',
40
+ },
41
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
@@ -0,0 +1,84 @@
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, utils, }) => {
8
+ const { noOptionalParamNames, } = context.options[0] || {};
9
+ const paramTags = utils.getPresentTags([
10
+ 'param', 'arg', 'argument',
11
+ ]);
12
+ for (const tag of paramTags) {
13
+ if (noOptionalParamNames && tag.optional) {
14
+ utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => {
15
+ utils.changeTag(tag, {
16
+ name: tag.name.replace(/([^=]*)(=.+)?/v, '$1'),
17
+ });
18
+ });
19
+ }
20
+ else if (tag.default) {
21
+ utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => {
22
+ utils.changeTag(tag, {
23
+ name: tag.name.replace(/([^=]*)(=.+)?/v, '[$1]'),
24
+ });
25
+ });
26
+ }
27
+ }
28
+ const defaultTags = utils.getPresentTags([
29
+ 'default', 'defaultvalue',
30
+ ]);
31
+ for (const tag of defaultTags) {
32
+ if (tag.description.trim()) {
33
+ utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => {
34
+ utils.changeTag(tag, {
35
+ description: '',
36
+ postTag: '',
37
+ });
38
+ });
39
+ }
40
+ }
41
+ }, {
42
+ contextDefaults: true,
43
+ meta: {
44
+ docs: {
45
+ description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.',
46
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#repos-sticky-header',
47
+ },
48
+ fixable: 'code',
49
+ schema: [
50
+ {
51
+ additionalProperties: false,
52
+ properties: {
53
+ contexts: {
54
+ items: {
55
+ anyOf: [
56
+ {
57
+ type: 'string',
58
+ },
59
+ {
60
+ additionalProperties: false,
61
+ properties: {
62
+ comment: {
63
+ type: 'string',
64
+ },
65
+ context: {
66
+ type: 'string',
67
+ },
68
+ },
69
+ type: 'object',
70
+ },
71
+ ],
72
+ },
73
+ type: 'array',
74
+ },
75
+ noOptionalParamNames: {
76
+ type: 'boolean',
77
+ },
78
+ },
79
+ type: 'object',
80
+ },
81
+ ],
82
+ type: 'suggestion',
83
+ },
84
+ });
@@ -0,0 +1,9 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
3
+ export type ContextObject = {
4
+ comment: string;
5
+ context: string;
6
+ message: string;
7
+ minimum: import("../iterateJsdoc.js").Integer;
8
+ };
9
+ export type Context = string | ContextObject;