eslint-plugin-jsdoc 63.3.3 → 64.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/index.d.ts +14 -0
  2. package/package.json +23 -48
  3. package/src/index.js +22 -6
  4. package/dist/WarnSettings.cjs +0 -38
  5. package/dist/WarnSettings.cjs.map +0 -1
  6. package/dist/alignTransform.cjs +0 -402
  7. package/dist/alignTransform.cjs.map +0 -1
  8. package/dist/buildForbidRuleDefinition.cjs +0 -101
  9. package/dist/buildForbidRuleDefinition.cjs.map +0 -1
  10. package/dist/buildRejectOrPreferRuleDefinition.cjs +0 -352
  11. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +0 -1
  12. package/dist/cjs/WarnSettings.d.ts +0 -16
  13. package/dist/cjs/alignTransform.d.ts +0 -33
  14. package/dist/cjs/buildForbidRuleDefinition.d.ts +0 -14
  15. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +0 -8
  16. package/dist/cjs/defaultTagOrder.d.ts +0 -4
  17. package/dist/cjs/exportParser.d.ts +0 -40
  18. package/dist/cjs/getDefaultTagStructureForMode.d.ts +0 -10
  19. package/dist/cjs/getJsdocProcessorPlugin.d.cts +0 -5
  20. package/dist/cjs/getJsdocProcessorPlugin.d.ts +0 -66
  21. package/dist/cjs/index-cjs.d.ts +0 -26
  22. package/dist/cjs/index.cjs.d.cts +0 -2
  23. package/dist/cjs/iterateJsdoc.d.cts +0 -7
  24. package/dist/cjs/iterateJsdoc.d.ts +0 -495
  25. package/dist/cjs/jsdocUtils.d.ts +0 -500
  26. package/dist/cjs/rules/checkAccess.d.ts +0 -2
  27. package/dist/cjs/rules/checkAlignment.d.ts +0 -2
  28. package/dist/cjs/rules/checkExamples.d.ts +0 -3
  29. package/dist/cjs/rules/checkIndentation.d.ts +0 -2
  30. package/dist/cjs/rules/checkLineAlignment.d.ts +0 -9
  31. package/dist/cjs/rules/checkParamNames.d.ts +0 -2
  32. package/dist/cjs/rules/checkPropertyNames.d.ts +0 -2
  33. package/dist/cjs/rules/checkSyntax.d.ts +0 -2
  34. package/dist/cjs/rules/checkTagNames.d.ts +0 -2
  35. package/dist/cjs/rules/checkTemplateNames.d.ts +0 -2
  36. package/dist/cjs/rules/checkTypes.d.ts +0 -7
  37. package/dist/cjs/rules/checkValues.d.ts +0 -2
  38. package/dist/cjs/rules/convertToJsdocComments.d.ts +0 -266
  39. package/dist/cjs/rules/emptyTags.d.ts +0 -2
  40. package/dist/cjs/rules/escapeInlineTags.d.ts +0 -2
  41. package/dist/cjs/rules/implementsOnClasses.d.ts +0 -2
  42. package/dist/cjs/rules/importsAsDependencies.d.ts +0 -2
  43. package/dist/cjs/rules/informativeDocs.d.ts +0 -2
  44. package/dist/cjs/rules/linesBeforeBlock.d.ts +0 -2
  45. package/dist/cjs/rules/matchDescription.d.ts +0 -2
  46. package/dist/cjs/rules/matchName.d.ts +0 -2
  47. package/dist/cjs/rules/multilineBlocks.d.ts +0 -2
  48. package/dist/cjs/rules/noBadBlocks.d.ts +0 -2
  49. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +0 -2
  50. package/dist/cjs/rules/noBlankBlocks.d.ts +0 -2
  51. package/dist/cjs/rules/noDefaults.d.ts +0 -2
  52. package/dist/cjs/rules/noMissingSyntax.d.ts +0 -9
  53. package/dist/cjs/rules/noMultiAsterisks.d.ts +0 -2
  54. package/dist/cjs/rules/noRestrictedSyntax.d.ts +0 -2
  55. package/dist/cjs/rules/noTypes.d.ts +0 -2
  56. package/dist/cjs/rules/noUndefinedTypes.d.ts +0 -2
  57. package/dist/cjs/rules/normalizeSeeLinks.d.ts +0 -2
  58. package/dist/cjs/rules/preferImportTag.d.ts +0 -2
  59. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +0 -2
  60. package/dist/cjs/rules/requireDescription.d.ts +0 -2
  61. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +0 -2
  62. package/dist/cjs/rules/requireExample.d.ts +0 -2
  63. package/dist/cjs/rules/requireFileOverview.d.ts +0 -2
  64. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +0 -2
  65. package/dist/cjs/rules/requireJsdoc.d.ts +0 -24
  66. package/dist/cjs/rules/requireParam.d.ts +0 -3
  67. package/dist/cjs/rules/requireParamDescription.d.ts +0 -2
  68. package/dist/cjs/rules/requireParamName.d.ts +0 -2
  69. package/dist/cjs/rules/requireParamType.d.ts +0 -2
  70. package/dist/cjs/rules/requireProperty.d.ts +0 -2
  71. package/dist/cjs/rules/requirePropertyDescription.d.ts +0 -2
  72. package/dist/cjs/rules/requirePropertyName.d.ts +0 -2
  73. package/dist/cjs/rules/requirePropertyType.d.ts +0 -2
  74. package/dist/cjs/rules/requireRejects.d.ts +0 -2
  75. package/dist/cjs/rules/requireReturns.d.ts +0 -2
  76. package/dist/cjs/rules/requireReturnsCheck.d.ts +0 -2
  77. package/dist/cjs/rules/requireReturnsDescription.d.ts +0 -2
  78. package/dist/cjs/rules/requireReturnsType.d.ts +0 -2
  79. package/dist/cjs/rules/requireTags.d.ts +0 -2
  80. package/dist/cjs/rules/requireTemplate.d.ts +0 -2
  81. package/dist/cjs/rules/requireThrows.d.ts +0 -2
  82. package/dist/cjs/rules/requireYields.d.ts +0 -2
  83. package/dist/cjs/rules/requireYieldsCheck.d.ts +0 -2
  84. package/dist/cjs/rules/sortTags.d.ts +0 -2
  85. package/dist/cjs/rules/tagLines.d.ts +0 -2
  86. package/dist/cjs/rules/textEscaping.d.ts +0 -2
  87. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +0 -2
  88. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +0 -2
  89. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +0 -2
  90. package/dist/cjs/rules/tsPreferFunctionType.d.ts +0 -2
  91. package/dist/cjs/rules/typeFormatting.d.ts +0 -2
  92. package/dist/cjs/rules/validTypes.d.ts +0 -2
  93. package/dist/cjs/tagNames.d.ts +0 -15
  94. package/dist/cjs/utils/hasReturnValue.d.ts +0 -19
  95. package/dist/defaultTagOrder.cjs +0 -46
  96. package/dist/defaultTagOrder.cjs.map +0 -1
  97. package/dist/exportParser.cjs +0 -732
  98. package/dist/exportParser.cjs.map +0 -1
  99. package/dist/generateDocs.cjs +0 -342
  100. package/dist/generateDocs.cjs.map +0 -1
  101. package/dist/generateOptions.cjs +0 -62
  102. package/dist/generateOptions.cjs.map +0 -1
  103. package/dist/generateRule.cjs +0 -248
  104. package/dist/generateRule.cjs.map +0 -1
  105. package/dist/generateRuleTypes.cjs +0 -24
  106. package/dist/generateRuleTypes.cjs.map +0 -1
  107. package/dist/getDefaultTagStructureForMode.cjs +0 -289
  108. package/dist/getDefaultTagStructureForMode.cjs.map +0 -1
  109. package/dist/getJsdocProcessorPlugin.cjs +0 -587
  110. package/dist/getJsdocProcessorPlugin.cjs.map +0 -1
  111. package/dist/getJsdocProcessorPlugin.cts +0 -5
  112. package/dist/index-cjs.cjs +0 -600
  113. package/dist/index-cjs.cjs.map +0 -1
  114. package/dist/index-cjs.d.ts +0 -27
  115. package/dist/index-esm.cjs +0 -162
  116. package/dist/index-esm.cjs.map +0 -1
  117. package/dist/index-esm.d.ts +0 -72
  118. package/dist/index.cjs +0 -748
  119. package/dist/index.cjs.cts +0 -3
  120. package/dist/index.cjs.map +0 -1
  121. package/dist/iterateJsdoc.cjs +0 -2150
  122. package/dist/iterateJsdoc.cjs.map +0 -1
  123. package/dist/iterateJsdoc.cts +0 -7
  124. package/dist/jsdocUtils.cjs +0 -1786
  125. package/dist/jsdocUtils.cjs.map +0 -1
  126. package/dist/rules/checkAccess.cjs +0 -40
  127. package/dist/rules/checkAccess.cjs.map +0 -1
  128. package/dist/rules/checkAlignment.cjs +0 -78
  129. package/dist/rules/checkAlignment.cjs.map +0 -1
  130. package/dist/rules/checkExamples.cjs +0 -521
  131. package/dist/rules/checkExamples.cjs.map +0 -1
  132. package/dist/rules/checkIndentation.cjs +0 -170
  133. package/dist/rules/checkIndentation.cjs.map +0 -1
  134. package/dist/rules/checkLineAlignment.cjs +0 -398
  135. package/dist/rules/checkLineAlignment.cjs.map +0 -1
  136. package/dist/rules/checkParamNames.cjs +0 -407
  137. package/dist/rules/checkParamNames.cjs.map +0 -1
  138. package/dist/rules/checkPropertyNames.cjs +0 -135
  139. package/dist/rules/checkPropertyNames.cjs.map +0 -1
  140. package/dist/rules/checkSyntax.cjs +0 -38
  141. package/dist/rules/checkSyntax.cjs.map +0 -1
  142. package/dist/rules/checkTagNames.cjs +0 -312
  143. package/dist/rules/checkTagNames.cjs.map +0 -1
  144. package/dist/rules/checkTemplateNames.cjs +0 -192
  145. package/dist/rules/checkTemplateNames.cjs.map +0 -1
  146. package/dist/rules/checkTypes.cjs +0 -111
  147. package/dist/rules/checkTypes.cjs.map +0 -1
  148. package/dist/rules/checkValues.cjs +0 -166
  149. package/dist/rules/checkValues.cjs.map +0 -1
  150. package/dist/rules/convertToJsdocComments.cjs +0 -356
  151. package/dist/rules/convertToJsdocComments.cjs.map +0 -1
  152. package/dist/rules/emptyTags.cjs +0 -98
  153. package/dist/rules/emptyTags.cjs.map +0 -1
  154. package/dist/rules/escapeInlineTags.cjs +0 -234
  155. package/dist/rules/escapeInlineTags.cjs.map +0 -1
  156. package/dist/rules/implementsOnClasses.cjs +0 -74
  157. package/dist/rules/implementsOnClasses.cjs.map +0 -1
  158. package/dist/rules/importsAsDependencies.cjs +0 -104
  159. package/dist/rules/importsAsDependencies.cjs.map +0 -1
  160. package/dist/rules/informativeDocs.cjs +0 -187
  161. package/dist/rules/informativeDocs.cjs.map +0 -1
  162. package/dist/rules/linesBeforeBlock.cjs +0 -120
  163. package/dist/rules/linesBeforeBlock.cjs.map +0 -1
  164. package/dist/rules/matchDescription.cjs +0 -356
  165. package/dist/rules/matchDescription.cjs.map +0 -1
  166. package/dist/rules/matchName.cjs +0 -160
  167. package/dist/rules/matchName.cjs.map +0 -1
  168. package/dist/rules/multilineBlocks.cjs +0 -431
  169. package/dist/rules/multilineBlocks.cjs.map +0 -1
  170. package/dist/rules/noBadBlocks.cjs +0 -100
  171. package/dist/rules/noBadBlocks.cjs.map +0 -1
  172. package/dist/rules/noBlankBlockDescriptions.cjs +0 -63
  173. package/dist/rules/noBlankBlockDescriptions.cjs.map +0 -1
  174. package/dist/rules/noBlankBlocks.cjs +0 -54
  175. package/dist/rules/noBlankBlocks.cjs.map +0 -1
  176. package/dist/rules/noDefaults.cjs +0 -102
  177. package/dist/rules/noDefaults.cjs.map +0 -1
  178. package/dist/rules/noMissingSyntax.cjs +0 -196
  179. package/dist/rules/noMissingSyntax.cjs.map +0 -1
  180. package/dist/rules/noMultiAsterisks.cjs +0 -126
  181. package/dist/rules/noMultiAsterisks.cjs.map +0 -1
  182. package/dist/rules/noRestrictedSyntax.cjs +0 -68
  183. package/dist/rules/noRestrictedSyntax.cjs.map +0 -1
  184. package/dist/rules/noTypes.cjs +0 -101
  185. package/dist/rules/noTypes.cjs.map +0 -1
  186. package/dist/rules/noUndefinedTypes.cjs +0 -616
  187. package/dist/rules/noUndefinedTypes.cjs.map +0 -1
  188. package/dist/rules/normalizeSeeLinks.cjs +0 -271
  189. package/dist/rules/normalizeSeeLinks.cjs.map +0 -1
  190. package/dist/rules/preferImportTag.cjs +0 -362
  191. package/dist/rules/preferImportTag.cjs.map +0 -1
  192. package/dist/rules/requireAsteriskPrefix.cjs +0 -190
  193. package/dist/rules/requireAsteriskPrefix.cjs.map +0 -1
  194. package/dist/rules/requireDescription.cjs +0 -164
  195. package/dist/rules/requireDescription.cjs.map +0 -1
  196. package/dist/rules/requireDescriptionCompleteSentence.cjs +0 -321
  197. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +0 -1
  198. package/dist/rules/requireExample.cjs +0 -136
  199. package/dist/rules/requireExample.cjs.map +0 -1
  200. package/dist/rules/requireFileOverview.cjs +0 -194
  201. package/dist/rules/requireFileOverview.cjs.map +0 -1
  202. package/dist/rules/requireHyphenBeforeParamDescription.cjs +0 -166
  203. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +0 -1
  204. package/dist/rules/requireJsdoc.cjs +0 -721
  205. package/dist/rules/requireJsdoc.cjs.map +0 -1
  206. package/dist/rules/requireParam.cjs +0 -772
  207. package/dist/rules/requireParam.cjs.map +0 -1
  208. package/dist/rules/requireParamDescription.cjs +0 -105
  209. package/dist/rules/requireParamDescription.cjs.map +0 -1
  210. package/dist/rules/requireParamName.cjs +0 -68
  211. package/dist/rules/requireParamName.cjs.map +0 -1
  212. package/dist/rules/requireParamType.cjs +0 -104
  213. package/dist/rules/requireParamType.cjs.map +0 -1
  214. package/dist/rules/requireProperty.cjs +0 -63
  215. package/dist/rules/requireProperty.cjs.map +0 -1
  216. package/dist/rules/requirePropertyDescription.cjs +0 -29
  217. package/dist/rules/requirePropertyDescription.cjs.map +0 -1
  218. package/dist/rules/requirePropertyName.cjs +0 -29
  219. package/dist/rules/requirePropertyName.cjs.map +0 -1
  220. package/dist/rules/requirePropertyType.cjs +0 -29
  221. package/dist/rules/requirePropertyType.cjs.map +0 -1
  222. package/dist/rules/requireRejects.cjs +0 -226
  223. package/dist/rules/requireRejects.cjs.map +0 -1
  224. package/dist/rules/requireReturns.cjs +0 -262
  225. package/dist/rules/requireReturns.cjs.map +0 -1
  226. package/dist/rules/requireReturnsCheck.cjs +0 -225
  227. package/dist/rules/requireReturnsCheck.cjs.map +0 -1
  228. package/dist/rules/requireReturnsDescription.cjs +0 -72
  229. package/dist/rules/requireReturnsDescription.cjs.map +0 -1
  230. package/dist/rules/requireReturnsType.cjs +0 -68
  231. package/dist/rules/requireReturnsType.cjs.map +0 -1
  232. package/dist/rules/requireTags.cjs +0 -74
  233. package/dist/rules/requireTags.cjs.map +0 -1
  234. package/dist/rules/requireTemplate.cjs +0 -220
  235. package/dist/rules/requireTemplate.cjs.map +0 -1
  236. package/dist/rules/requireThrows.cjs +0 -118
  237. package/dist/rules/requireThrows.cjs.map +0 -1
  238. package/dist/rules/requireYields.cjs +0 -224
  239. package/dist/rules/requireYields.cjs.map +0 -1
  240. package/dist/rules/requireYieldsCheck.cjs +0 -179
  241. package/dist/rules/requireYieldsCheck.cjs.map +0 -1
  242. package/dist/rules/sortTags.cjs +0 -656
  243. package/dist/rules/sortTags.cjs.map +0 -1
  244. package/dist/rules/tagLines.cjs +0 -374
  245. package/dist/rules/tagLines.cjs.map +0 -1
  246. package/dist/rules/textEscaping.cjs +0 -141
  247. package/dist/rules/textEscaping.cjs.map +0 -1
  248. package/dist/rules/tsMethodSignatureStyle.cjs +0 -240
  249. package/dist/rules/tsMethodSignatureStyle.cjs.map +0 -1
  250. package/dist/rules/tsNoEmptyObjectType.cjs +0 -62
  251. package/dist/rules/tsNoEmptyObjectType.cjs.map +0 -1
  252. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +0 -104
  253. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +0 -1
  254. package/dist/rules/tsPreferFunctionType.cjs +0 -110
  255. package/dist/rules/tsPreferFunctionType.cjs.map +0 -1
  256. package/dist/rules/typeFormatting.cjs +0 -607
  257. package/dist/rules/typeFormatting.cjs.map +0 -1
  258. package/dist/rules/validTypes.cjs +0 -324
  259. package/dist/rules/validTypes.cjs.map +0 -1
  260. package/dist/tagNames.cjs +0 -244
  261. package/dist/tagNames.cjs.map +0 -1
  262. package/dist/to-valid-identifier.cjs +0 -263
  263. package/dist/utils/hasReturnValue.cjs +0 -495
  264. package/dist/utils/hasReturnValue.cjs.map +0 -1
  265. package/rollup.config.js +0 -16
  266. package/src/getJsdocProcessorPlugin.cts +0 -5
  267. package/src/index-cjs.js +0 -760
  268. package/src/index-esm.js +0 -196
  269. package/src/index.cjs.cts +0 -3
  270. package/src/iterateJsdoc.cts +0 -7
@@ -1,656 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _defaultTagOrder = _interopRequireDefault(require("../defaultTagOrder.cjs"));
8
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- var _default = exports.default = (0, _iterateJsdoc.default)(({
11
- context,
12
- jsdoc,
13
- utils
14
- // eslint-disable-next-line complexity -- Temporary
15
- }) => {
16
- const
17
- /**
18
- * @type {{
19
- * linesBetween: import('../iterateJsdoc.js').Integer,
20
- * tagExceptions: Record<string, number>,
21
- * tagSequence: {
22
- * tags: string[]
23
- * }[],
24
- * alphabetizeExtras: boolean,
25
- * reportTagGroupSpacing: boolean,
26
- * reportIntraTagGroupSpacing: boolean,
27
- * }}
28
- */
29
- {
30
- alphabetizeExtras = false,
31
- linesBetween = 1,
32
- reportIntraTagGroupSpacing = true,
33
- reportTagGroupSpacing = true,
34
- tagExceptions = {},
35
- tagSequence = _defaultTagOrder.default
36
- } = context.options[0] || {};
37
- const tagList = tagSequence.flatMap(obj => {
38
- /* typeof obj === 'string' ? obj : */
39
- return obj.tags;
40
- });
41
- const otherPos = tagList.indexOf('-other');
42
- const endPos = otherPos > -1 ? otherPos : tagList.length;
43
- let ongoingCount = 0;
44
- for (const [idx, tag] of
45
- /**
46
- * @type {(
47
- * import('@es-joy/jsdoccomment').JsdocTagWithInline & {
48
- * originalIndex: import('../iterateJsdoc.js').Integer,
49
- * originalLine: import('../iterateJsdoc.js').Integer,
50
- * }
51
- * )[]}
52
- */
53
- jsdoc.tags.entries()) {
54
- tag.originalIndex = idx;
55
- ongoingCount += tag.source.length;
56
- tag.originalLine = ongoingCount;
57
- }
58
-
59
- /** @type {import('../iterateJsdoc.js').Integer|undefined} */
60
- let firstChangedTagLine;
61
- /** @type {import('../iterateJsdoc.js').Integer|undefined} */
62
- let firstChangedTagIndex;
63
-
64
- /**
65
- * @type {(import('comment-parser').Spec & {
66
- * originalIndex: import('../iterateJsdoc.js').Integer,
67
- * originalLine: import('../iterateJsdoc.js').Integer,
68
- * })[]}
69
- */
70
- const sortedTags = JSON.parse(JSON.stringify(jsdoc.tags));
71
- sortedTags.sort(({
72
- tag: tagNew
73
- }, {
74
- originalIndex,
75
- originalLine,
76
- tag: tagOld
77
- }) => {
78
- // Optimize: Just keep relative positions if the same tag name
79
- if (tagNew === tagOld) {
80
- return 0;
81
- }
82
- const checkOrSetFirstChanged = () => {
83
- if (!firstChangedTagLine || originalLine < firstChangedTagLine) {
84
- firstChangedTagLine = originalLine;
85
- firstChangedTagIndex = originalIndex;
86
- }
87
- };
88
- const newPos = tagList.indexOf(tagNew);
89
- const oldPos = tagList.indexOf(tagOld);
90
- const preferredNewPos = newPos === -1 ? endPos : newPos;
91
- const preferredOldPos = oldPos === -1 ? endPos : oldPos;
92
- if (preferredNewPos < preferredOldPos) {
93
- checkOrSetFirstChanged();
94
- return -1;
95
- }
96
- if (preferredNewPos > preferredOldPos) {
97
- return 1;
98
- }
99
-
100
- // preferredNewPos === preferredOldPos
101
- if (!alphabetizeExtras ||
102
- // Optimize: If tagNew (or tagOld which is the same) was found in the
103
- // priority array, it can maintain its relative position—without need
104
- // of alphabetizing (secondary sorting)
105
- newPos >= 0) {
106
- return 0;
107
- }
108
- if (tagNew < tagOld) {
109
- checkOrSetFirstChanged();
110
- return -1;
111
- }
112
-
113
- // tagNew > tagOld
114
- return 1;
115
- });
116
- if (firstChangedTagLine === undefined) {
117
- // Should be ordered by now
118
-
119
- /**
120
- * @type {import('comment-parser').Spec[]}
121
- */
122
- const lastTagsOfGroup = [];
123
-
124
- /**
125
- * @type {[
126
- * import('comment-parser').Spec,
127
- * import('../iterateJsdoc.js').Integer
128
- * ][]}
129
- */
130
- const badLastTagsOfGroup = [];
131
-
132
- /**
133
- * @param {import('comment-parser').Spec} tag
134
- */
135
- const countTagEmptyLines = tag => {
136
- return tag.source.reduce((acc, {
137
- tokens: {
138
- description,
139
- end,
140
- name,
141
- tag: tg,
142
- type
143
- }
144
- }) => {
145
- const empty = !tg && !type && !name && !description;
146
- // Reset the count so long as there is content
147
- return empty ? acc + Number(empty && !end) : 0;
148
- }, 0);
149
- };
150
- let idx = 0;
151
- for (const {
152
- tags
153
- } of tagSequence) {
154
- let innerIdx;
155
- /** @type {import('comment-parser').Spec} */
156
- let currentTag;
157
- /** @type {import('comment-parser').Spec|undefined} */
158
- let lastTag;
159
- do {
160
- currentTag = jsdoc.tags[idx];
161
- if (!currentTag) {
162
- idx++;
163
- break;
164
- }
165
- innerIdx = tags.indexOf(currentTag.tag);
166
- if (innerIdx === -1 && (
167
- // eslint-disable-next-line no-loop-func -- Safe
168
- !tags.includes('-other') || tagSequence.some(({
169
- tags: tgs
170
- }) => {
171
- return tgs.includes(currentTag.tag);
172
- }))) {
173
- idx++;
174
- break;
175
- }
176
- lastTag = currentTag;
177
- idx++;
178
- } while (true);
179
- idx--;
180
- if (lastTag) {
181
- lastTagsOfGroup.push(lastTag);
182
- const ct = countTagEmptyLines(lastTag);
183
- if (ct !== linesBetween &&
184
- // Use another rule for adding to end (should be of interest outside this rule)
185
- jsdoc.tags[idx]) {
186
- badLastTagsOfGroup.push([lastTag, ct]);
187
- }
188
- }
189
- }
190
- if (reportTagGroupSpacing && badLastTagsOfGroup.length) {
191
- /**
192
- * @param {import('comment-parser').Spec} tg
193
- * @returns {() => void}
194
- */
195
- const fixer = tg => {
196
- return () => {
197
- // Due to https://github.com/syavorsky/comment-parser/issues/110 ,
198
- // we have to modify `jsdoc.source` rather than just modify tags
199
- // directly
200
- for (const [currIdx, {
201
- tokens
202
- }] of jsdoc.source.entries()) {
203
- if (tokens.tag !== '@' + tg.tag) {
204
- continue;
205
- }
206
-
207
- // Cannot be `tokens.end`, as dropped off last tag, so safe to
208
- // go on
209
- let newIdx = currIdx;
210
- const emptyLine = () => {
211
- return {
212
- number: 0,
213
- source: '',
214
- tokens: utils.seedTokens({
215
- delimiter: '*',
216
- start: jsdoc.source[newIdx - 1].tokens.start
217
- })
218
- };
219
- };
220
- let existingEmptyLines = 0;
221
- while (true) {
222
- const nextTokens = jsdoc.source[++newIdx]?.tokens;
223
-
224
- /* c8 ignore next 3 -- Guard */
225
- if (!nextTokens) {
226
- return;
227
- }
228
-
229
- // Should be no `nextTokens.end` to worry about since ignored
230
- // if not followed by tag
231
-
232
- if (nextTokens.tag) {
233
- // Haven't made it to last tag instance yet, so keep looking
234
- if (nextTokens.tag === tokens.tag) {
235
- existingEmptyLines = 0;
236
- continue;
237
- }
238
- const lineDiff = linesBetween - existingEmptyLines;
239
- if (lineDiff > 0) {
240
- const lines = Array.from({
241
- length: lineDiff
242
- }, () => {
243
- return emptyLine();
244
- });
245
- jsdoc.source.splice(newIdx, 0, ...lines);
246
- } else {
247
- // lineDiff < 0
248
- jsdoc.source.splice(newIdx + lineDiff, -lineDiff);
249
- }
250
- break;
251
- }
252
- const empty = !nextTokens.type && !nextTokens.name && !nextTokens.description;
253
- if (empty) {
254
- existingEmptyLines++;
255
- } else {
256
- // Has content again, so reset empty line count
257
- existingEmptyLines = 0;
258
- }
259
- }
260
- break;
261
- }
262
- for (const [srcIdx, src] of jsdoc.source.entries()) {
263
- src.number = srcIdx;
264
- }
265
- };
266
- };
267
- for (const [tg] of badLastTagsOfGroup) {
268
- utils.reportJSDoc('Tag groups do not have the expected whitespace', tg, fixer(tg));
269
- }
270
- return;
271
- }
272
- if (!reportIntraTagGroupSpacing) {
273
- return;
274
- }
275
- for (const [tagIdx, tag] of jsdoc.tags.entries()) {
276
- if (!jsdoc.tags[tagIdx + 1] || lastTagsOfGroup.includes(tag)) {
277
- continue;
278
- }
279
- const ct = countTagEmptyLines(tag);
280
- if (ct && (!tagExceptions[tag.tag] || tagExceptions[tag.tag] < ct)) {
281
- const fixer = () => {
282
- let foundFirstTag = false;
283
-
284
- /** @type {string|undefined} */
285
- let currentTag;
286
- for (const [currIdx, {
287
- tokens: {
288
- description,
289
- end,
290
- name,
291
- tag: tg,
292
- type
293
- }
294
- }] of jsdoc.source.entries()) {
295
- if (tg) {
296
- foundFirstTag = true;
297
- currentTag = tg;
298
- }
299
- if (!foundFirstTag) {
300
- continue;
301
- }
302
- if (currentTag && !tg && !type && !name && !description && !end) {
303
- let nextIdx = currIdx;
304
- let ignore = true;
305
- // Even if a tag of the same name as the last tags in a group,
306
- // could still be an earlier tag in that group
307
-
308
- // eslint-disable-next-line no-loop-func -- Safe
309
- if (lastTagsOfGroup.some(lastTagOfGroup => {
310
- return currentTag === '@' + lastTagOfGroup.tag;
311
- })) {
312
- while (true) {
313
- const nextTokens = jsdoc.source[++nextIdx]?.tokens;
314
- if (!nextTokens) {
315
- break;
316
- }
317
- if (!nextTokens.tag) {
318
- continue;
319
- }
320
-
321
- // Followed by the same tag name, so not actually last in group,
322
- // and of interest
323
- if (nextTokens.tag === currentTag) {
324
- ignore = false;
325
- }
326
- }
327
- } else {
328
- while (true) {
329
- const nextTokens = jsdoc.source[++nextIdx]?.tokens;
330
- if (!nextTokens || nextTokens.end) {
331
- break;
332
- }
333
-
334
- // Not the very last tag, so don't ignore
335
- if (nextTokens.tag) {
336
- ignore = false;
337
- break;
338
- }
339
- }
340
- }
341
- if (!ignore) {
342
- jsdoc.source.splice(currIdx, 1);
343
- for (const [srcIdx, src] of jsdoc.source.entries()) {
344
- src.number = srcIdx;
345
- }
346
- }
347
- }
348
- }
349
- };
350
- utils.reportJSDoc('Intra-group tags have unexpected whitespace', tag, fixer);
351
- }
352
- }
353
- return;
354
- }
355
- const firstLine = utils.getFirstLine();
356
- const fix = () => {
357
- const itemsToMoveRange = [...Array.from({
358
- length: jsdoc.tags.length - (/** @type {import('../iterateJsdoc.js').Integer} */
359
- firstChangedTagIndex)
360
- }).keys()];
361
- const unchangedPriorTagDescriptions = jsdoc.tags.slice(0, firstChangedTagIndex).reduce((ct, {
362
- source
363
- }) => {
364
- return ct + source.length - 1;
365
- }, 0);
366
-
367
- // This offset includes not only the offset from where the first tag
368
- // must begin, and the additional offset of where the first changed
369
- // tag begins, but it must also account for prior descriptions
370
- const initialOffset = /** @type {import('../iterateJsdoc.js').Integer} */firstLine + (/** @type {import('../iterateJsdoc.js').Integer} */firstChangedTagIndex) +
371
- // May be the first tag, so don't try finding a prior one if so
372
- unchangedPriorTagDescriptions;
373
-
374
- // Use `firstChangedTagLine` for line number to begin reporting/splicing
375
- for (const idx of itemsToMoveRange) {
376
- utils.removeTag(idx + (/** @type {import('../iterateJsdoc.js').Integer} */
377
- firstChangedTagIndex));
378
- }
379
- const changedTags = sortedTags.slice(firstChangedTagIndex);
380
- let extraTagCount = 0;
381
- for (const idx of itemsToMoveRange) {
382
- const changedTag = changedTags[idx];
383
- utils.addTag(changedTag.tag, extraTagCount + initialOffset + idx, {
384
- ...changedTag.source[0].tokens,
385
- // `comment-parser` puts the `end` within the `tags` section, so
386
- // avoid adding another to jsdoc.source
387
- end: ''
388
- });
389
- for (const {
390
- tokens
391
- } of changedTag.source.slice(1)) {
392
- if (!tokens.end) {
393
- utils.addLine(extraTagCount + initialOffset + idx + 1, {
394
- ...tokens,
395
- end: ''
396
- });
397
- extraTagCount++;
398
- }
399
- }
400
- }
401
- };
402
- utils.reportJSDoc(`Tags are not in the prescribed order: ${tagList.join(', ') || '(alphabetical)'}`, jsdoc.tags[(/** @type {import('../iterateJsdoc.js').Integer} */
403
- firstChangedTagIndex)], fix, true);
404
- }, {
405
- iterateAllJsdocs: true,
406
- meta: {
407
- docs: {
408
- description: 'Sorts tags by a specified sequence according to tag name, optionally adding line breaks between tag groups.',
409
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/sort-tags.md#repos-sticky-header'
410
- },
411
- fixable: 'code',
412
- schema: [{
413
- additionalProperties: false,
414
- properties: {
415
- alphabetizeExtras: {
416
- description: `Defaults to \`false\`. Alphabetizes any items not within \`tagSequence\` after any
417
- items within \`tagSequence\` (or in place of the special \`-other\` pseudo-tag)
418
- are sorted.
419
-
420
- If you want all your tags alphabetized, you can supply an empty array for
421
- \`tagSequence\` along with setting this option to \`true\`.`,
422
- type: 'boolean'
423
- },
424
- linesBetween: {
425
- description: `Indicates the number of lines to be added between tag groups. Defaults to 1.
426
- Do not set to 0 or 2+ if you are using \`tag-lines\` and \`"always"\` and do not
427
- set to 1+ if you are using \`tag-lines\` and \`"never"\`.`,
428
- type: 'integer'
429
- },
430
- reportIntraTagGroupSpacing: {
431
- description: `Whether to enable reporting and fixing of line breaks within tags of a given
432
- tag group. Defaults to \`true\` which will remove any line breaks at the end of
433
- such tags. Do not use with \`true\` if you are using \`tag-lines\` and \`always\`.`,
434
- type: 'boolean'
435
- },
436
- reportTagGroupSpacing: {
437
- description: `Whether to enable reporting and fixing of line breaks between tag groups
438
- as set by \`linesBetween\`. Defaults to \`true\`. Note that the very last tag
439
- will not have spacing applied regardless. For adding line breaks there, you
440
- may wish to use the \`endLines\` option of the \`tag-lines\` rule.`,
441
- type: 'boolean'
442
- },
443
- tagExceptions: {
444
- description: 'Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.',
445
- patternProperties: {
446
- '.*': {
447
- type: 'number'
448
- }
449
- },
450
- type: 'object'
451
- },
452
- tagSequence: {
453
- description: `An array of tag group objects indicating the preferred sequence for sorting tags.
454
-
455
- Each item in the array should be an object with a \`tags\` property set to an array
456
- of tag names.
457
-
458
- Tag names earlier in the list will be arranged first. The relative position of
459
- tags of the same name will not be changed.
460
-
461
- Earlier groups will also be arranged before later groups, but with the added
462
- feature that additional line breaks may be added between (or before or after)
463
- such groups (depending on the setting of \`linesBetween\`).
464
-
465
- Tag names not in the list will be grouped together at the end. The pseudo-tag
466
- \`-other\` can be used to place them anywhere else if desired. The tags will be
467
- placed in their order of appearance, or alphabetized if \`alphabetizeExtras\`
468
- is enabled, see more below about that option.
469
-
470
- Defaults to the array below (noting that it is just a single tag group with
471
- no lines between groups by default).
472
-
473
- Please note that this order is still experimental, so if you want to retain
474
- a fixed order that doesn't change into the future, supply your own
475
- \`tagSequence\`.
476
-
477
- \`\`\`js
478
- [{tags: [
479
- // Brief descriptions
480
- 'summary',
481
- 'typeSummary',
482
-
483
- // Module/file-level
484
- 'module',
485
- 'exports',
486
- 'file',
487
- 'fileoverview',
488
- 'overview',
489
- 'import',
490
-
491
- // Identifying (name, type)
492
- 'typedef',
493
- 'interface',
494
- 'record',
495
- 'template',
496
- 'name',
497
- 'kind',
498
- 'type',
499
- 'alias',
500
- 'external',
501
- 'host',
502
- 'callback',
503
- 'func',
504
- 'function',
505
- 'method',
506
- 'class',
507
- 'constructor',
508
-
509
- // Relationships
510
- 'modifies',
511
- 'mixes',
512
- 'mixin',
513
- 'mixinClass',
514
- 'mixinFunction',
515
- 'namespace',
516
- 'borrows',
517
- 'constructs',
518
- 'lends',
519
- 'implements',
520
- 'requires',
521
-
522
- // Long descriptions
523
- 'desc',
524
- 'description',
525
- 'classdesc',
526
- 'tutorial',
527
- 'copyright',
528
- 'license',
529
-
530
- // Simple annotations
531
- 'const',
532
- 'constant',
533
- 'final',
534
- 'global',
535
- 'readonly',
536
- 'abstract',
537
- 'virtual',
538
- 'var',
539
- 'member',
540
- 'memberof',
541
- 'memberof!',
542
- 'inner',
543
- 'instance',
544
- 'inheritdoc',
545
- 'inheritDoc',
546
- 'override',
547
- 'hideconstructor',
548
-
549
- // Core function/object info
550
- 'param',
551
- 'arg',
552
- 'argument',
553
- 'prop',
554
- 'property',
555
- 'return',
556
- 'returns',
557
-
558
- // Important behavior details
559
- 'async',
560
- 'generator',
561
- 'default',
562
- 'defaultvalue',
563
- 'enum',
564
- 'augments',
565
- 'extends',
566
- 'throws',
567
- 'exception',
568
- 'yield',
569
- 'yields',
570
- 'event',
571
- 'fires',
572
- 'emits',
573
- 'listens',
574
- 'this',
575
-
576
- // Access
577
- 'static',
578
- 'private',
579
- 'protected',
580
- 'public',
581
- 'access',
582
- 'package',
583
-
584
- '-other',
585
-
586
- // Supplementary descriptions
587
- 'see',
588
- 'example',
589
-
590
- // METADATA
591
-
592
- // Other Closure (undocumented) metadata
593
- 'closurePrimitive',
594
- 'customElement',
595
- 'expose',
596
- 'hidden',
597
- 'idGenerator',
598
- 'meaning',
599
- 'ngInject',
600
- 'owner',
601
- 'wizaction',
602
-
603
- // Other Closure (documented) metadata
604
- 'define',
605
- 'dict',
606
- 'export',
607
- 'externs',
608
- 'implicitCast',
609
- 'noalias',
610
- 'nocollapse',
611
- 'nocompile',
612
- 'noinline',
613
- 'nosideeffects',
614
- 'polymer',
615
- 'polymerBehavior',
616
- 'preserve',
617
- 'struct',
618
- 'suppress',
619
- 'unrestricted',
620
-
621
- // @homer0/prettier-plugin-jsdoc metadata
622
- 'category',
623
-
624
- // Non-Closure metadata
625
- 'ignore',
626
- 'author',
627
- 'version',
628
- 'variation',
629
- 'since',
630
- 'deprecated',
631
- 'todo',
632
- ]}];
633
- \`\`\``,
634
- items: {
635
- additionalProperties: false,
636
- properties: {
637
- tags: {
638
- description: 'See description on `tagSequence`.',
639
- items: {
640
- type: 'string'
641
- },
642
- type: 'array'
643
- }
644
- },
645
- type: 'object'
646
- },
647
- type: 'array'
648
- }
649
- },
650
- type: 'object'
651
- }],
652
- type: 'suggestion'
653
- }
654
- });
655
- module.exports = exports.default;
656
- //# sourceMappingURL=sortTags.cjs.map