@depup/eslint-plugin-jsdoc 63.3.2-depup.1 → 64.0.0-depup.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 (272) hide show
  1. package/README.md +3 -11
  2. package/changes.json +3 -16
  3. package/dist/index.d.ts +7 -4
  4. package/package.json +29 -67
  5. package/src/index.js +7 -8
  6. package/dist/WarnSettings.cjs +0 -38
  7. package/dist/WarnSettings.cjs.map +0 -1
  8. package/dist/alignTransform.cjs +0 -402
  9. package/dist/alignTransform.cjs.map +0 -1
  10. package/dist/buildForbidRuleDefinition.cjs +0 -101
  11. package/dist/buildForbidRuleDefinition.cjs.map +0 -1
  12. package/dist/buildRejectOrPreferRuleDefinition.cjs +0 -352
  13. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +0 -1
  14. package/dist/cjs/WarnSettings.d.ts +0 -16
  15. package/dist/cjs/alignTransform.d.ts +0 -33
  16. package/dist/cjs/buildForbidRuleDefinition.d.ts +0 -14
  17. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +0 -8
  18. package/dist/cjs/defaultTagOrder.d.ts +0 -4
  19. package/dist/cjs/exportParser.d.ts +0 -40
  20. package/dist/cjs/getDefaultTagStructureForMode.d.ts +0 -10
  21. package/dist/cjs/getJsdocProcessorPlugin.d.cts +0 -5
  22. package/dist/cjs/getJsdocProcessorPlugin.d.ts +0 -66
  23. package/dist/cjs/index-cjs.d.ts +0 -23
  24. package/dist/cjs/index.cjs.d.cts +0 -2
  25. package/dist/cjs/iterateJsdoc.d.cts +0 -7
  26. package/dist/cjs/iterateJsdoc.d.ts +0 -495
  27. package/dist/cjs/jsdocUtils.d.ts +0 -500
  28. package/dist/cjs/rules/checkAccess.d.ts +0 -2
  29. package/dist/cjs/rules/checkAlignment.d.ts +0 -2
  30. package/dist/cjs/rules/checkExamples.d.ts +0 -3
  31. package/dist/cjs/rules/checkIndentation.d.ts +0 -2
  32. package/dist/cjs/rules/checkLineAlignment.d.ts +0 -9
  33. package/dist/cjs/rules/checkParamNames.d.ts +0 -2
  34. package/dist/cjs/rules/checkPropertyNames.d.ts +0 -2
  35. package/dist/cjs/rules/checkSyntax.d.ts +0 -2
  36. package/dist/cjs/rules/checkTagNames.d.ts +0 -2
  37. package/dist/cjs/rules/checkTemplateNames.d.ts +0 -2
  38. package/dist/cjs/rules/checkTypes.d.ts +0 -7
  39. package/dist/cjs/rules/checkValues.d.ts +0 -2
  40. package/dist/cjs/rules/convertToJsdocComments.d.ts +0 -266
  41. package/dist/cjs/rules/emptyTags.d.ts +0 -2
  42. package/dist/cjs/rules/escapeInlineTags.d.ts +0 -2
  43. package/dist/cjs/rules/implementsOnClasses.d.ts +0 -2
  44. package/dist/cjs/rules/importsAsDependencies.d.ts +0 -2
  45. package/dist/cjs/rules/informativeDocs.d.ts +0 -2
  46. package/dist/cjs/rules/linesBeforeBlock.d.ts +0 -2
  47. package/dist/cjs/rules/matchDescription.d.ts +0 -2
  48. package/dist/cjs/rules/matchName.d.ts +0 -2
  49. package/dist/cjs/rules/multilineBlocks.d.ts +0 -2
  50. package/dist/cjs/rules/noBadBlocks.d.ts +0 -2
  51. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +0 -2
  52. package/dist/cjs/rules/noBlankBlocks.d.ts +0 -2
  53. package/dist/cjs/rules/noDefaults.d.ts +0 -2
  54. package/dist/cjs/rules/noMissingSyntax.d.ts +0 -9
  55. package/dist/cjs/rules/noMultiAsterisks.d.ts +0 -2
  56. package/dist/cjs/rules/noRestrictedSyntax.d.ts +0 -2
  57. package/dist/cjs/rules/noTypes.d.ts +0 -2
  58. package/dist/cjs/rules/noUndefinedTypes.d.ts +0 -2
  59. package/dist/cjs/rules/normalizeSeeLinks.d.ts +0 -2
  60. package/dist/cjs/rules/preferImportTag.d.ts +0 -2
  61. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +0 -2
  62. package/dist/cjs/rules/requireDescription.d.ts +0 -2
  63. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +0 -2
  64. package/dist/cjs/rules/requireExample.d.ts +0 -2
  65. package/dist/cjs/rules/requireFileOverview.d.ts +0 -2
  66. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +0 -2
  67. package/dist/cjs/rules/requireJsdoc.d.ts +0 -24
  68. package/dist/cjs/rules/requireParam.d.ts +0 -3
  69. package/dist/cjs/rules/requireParamDescription.d.ts +0 -2
  70. package/dist/cjs/rules/requireParamName.d.ts +0 -2
  71. package/dist/cjs/rules/requireParamType.d.ts +0 -2
  72. package/dist/cjs/rules/requireProperty.d.ts +0 -2
  73. package/dist/cjs/rules/requirePropertyDescription.d.ts +0 -2
  74. package/dist/cjs/rules/requirePropertyName.d.ts +0 -2
  75. package/dist/cjs/rules/requirePropertyType.d.ts +0 -2
  76. package/dist/cjs/rules/requireRejects.d.ts +0 -2
  77. package/dist/cjs/rules/requireReturns.d.ts +0 -2
  78. package/dist/cjs/rules/requireReturnsCheck.d.ts +0 -2
  79. package/dist/cjs/rules/requireReturnsDescription.d.ts +0 -2
  80. package/dist/cjs/rules/requireReturnsType.d.ts +0 -2
  81. package/dist/cjs/rules/requireTags.d.ts +0 -2
  82. package/dist/cjs/rules/requireTemplate.d.ts +0 -2
  83. package/dist/cjs/rules/requireThrows.d.ts +0 -2
  84. package/dist/cjs/rules/requireYields.d.ts +0 -2
  85. package/dist/cjs/rules/requireYieldsCheck.d.ts +0 -2
  86. package/dist/cjs/rules/sortTags.d.ts +0 -2
  87. package/dist/cjs/rules/tagLines.d.ts +0 -2
  88. package/dist/cjs/rules/textEscaping.d.ts +0 -2
  89. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +0 -2
  90. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +0 -2
  91. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +0 -2
  92. package/dist/cjs/rules/tsPreferFunctionType.d.ts +0 -2
  93. package/dist/cjs/rules/typeFormatting.d.ts +0 -2
  94. package/dist/cjs/rules/validTypes.d.ts +0 -2
  95. package/dist/cjs/tagNames.d.ts +0 -15
  96. package/dist/cjs/utils/hasReturnValue.d.ts +0 -19
  97. package/dist/defaultTagOrder.cjs +0 -46
  98. package/dist/defaultTagOrder.cjs.map +0 -1
  99. package/dist/exportParser.cjs +0 -732
  100. package/dist/exportParser.cjs.map +0 -1
  101. package/dist/generateDocs.cjs +0 -342
  102. package/dist/generateDocs.cjs.map +0 -1
  103. package/dist/generateOptions.cjs +0 -62
  104. package/dist/generateOptions.cjs.map +0 -1
  105. package/dist/generateRule.cjs +0 -248
  106. package/dist/generateRule.cjs.map +0 -1
  107. package/dist/generateRuleTypes.cjs +0 -24
  108. package/dist/generateRuleTypes.cjs.map +0 -1
  109. package/dist/getDefaultTagStructureForMode.cjs +0 -289
  110. package/dist/getDefaultTagStructureForMode.cjs.map +0 -1
  111. package/dist/getJsdocProcessorPlugin.cjs +0 -587
  112. package/dist/getJsdocProcessorPlugin.cjs.map +0 -1
  113. package/dist/getJsdocProcessorPlugin.cts +0 -5
  114. package/dist/index-cjs.cjs +0 -598
  115. package/dist/index-cjs.cjs.map +0 -1
  116. package/dist/index-cjs.d.ts +0 -24
  117. package/dist/index-esm.cjs +0 -162
  118. package/dist/index-esm.cjs.map +0 -1
  119. package/dist/index-esm.d.ts +0 -72
  120. package/dist/index.cjs +0 -746
  121. package/dist/index.cjs.cts +0 -3
  122. package/dist/index.cjs.map +0 -1
  123. package/dist/iterateJsdoc.cjs +0 -2150
  124. package/dist/iterateJsdoc.cjs.map +0 -1
  125. package/dist/iterateJsdoc.cts +0 -7
  126. package/dist/jsdocUtils.cjs +0 -1786
  127. package/dist/jsdocUtils.cjs.map +0 -1
  128. package/dist/rules/checkAccess.cjs +0 -40
  129. package/dist/rules/checkAccess.cjs.map +0 -1
  130. package/dist/rules/checkAlignment.cjs +0 -78
  131. package/dist/rules/checkAlignment.cjs.map +0 -1
  132. package/dist/rules/checkExamples.cjs +0 -521
  133. package/dist/rules/checkExamples.cjs.map +0 -1
  134. package/dist/rules/checkIndentation.cjs +0 -170
  135. package/dist/rules/checkIndentation.cjs.map +0 -1
  136. package/dist/rules/checkLineAlignment.cjs +0 -398
  137. package/dist/rules/checkLineAlignment.cjs.map +0 -1
  138. package/dist/rules/checkParamNames.cjs +0 -407
  139. package/dist/rules/checkParamNames.cjs.map +0 -1
  140. package/dist/rules/checkPropertyNames.cjs +0 -135
  141. package/dist/rules/checkPropertyNames.cjs.map +0 -1
  142. package/dist/rules/checkSyntax.cjs +0 -38
  143. package/dist/rules/checkSyntax.cjs.map +0 -1
  144. package/dist/rules/checkTagNames.cjs +0 -312
  145. package/dist/rules/checkTagNames.cjs.map +0 -1
  146. package/dist/rules/checkTemplateNames.cjs +0 -192
  147. package/dist/rules/checkTemplateNames.cjs.map +0 -1
  148. package/dist/rules/checkTypes.cjs +0 -111
  149. package/dist/rules/checkTypes.cjs.map +0 -1
  150. package/dist/rules/checkValues.cjs +0 -166
  151. package/dist/rules/checkValues.cjs.map +0 -1
  152. package/dist/rules/convertToJsdocComments.cjs +0 -356
  153. package/dist/rules/convertToJsdocComments.cjs.map +0 -1
  154. package/dist/rules/emptyTags.cjs +0 -98
  155. package/dist/rules/emptyTags.cjs.map +0 -1
  156. package/dist/rules/escapeInlineTags.cjs +0 -234
  157. package/dist/rules/escapeInlineTags.cjs.map +0 -1
  158. package/dist/rules/implementsOnClasses.cjs +0 -74
  159. package/dist/rules/implementsOnClasses.cjs.map +0 -1
  160. package/dist/rules/importsAsDependencies.cjs +0 -104
  161. package/dist/rules/importsAsDependencies.cjs.map +0 -1
  162. package/dist/rules/informativeDocs.cjs +0 -187
  163. package/dist/rules/informativeDocs.cjs.map +0 -1
  164. package/dist/rules/linesBeforeBlock.cjs +0 -120
  165. package/dist/rules/linesBeforeBlock.cjs.map +0 -1
  166. package/dist/rules/matchDescription.cjs +0 -356
  167. package/dist/rules/matchDescription.cjs.map +0 -1
  168. package/dist/rules/matchName.cjs +0 -160
  169. package/dist/rules/matchName.cjs.map +0 -1
  170. package/dist/rules/multilineBlocks.cjs +0 -431
  171. package/dist/rules/multilineBlocks.cjs.map +0 -1
  172. package/dist/rules/noBadBlocks.cjs +0 -100
  173. package/dist/rules/noBadBlocks.cjs.map +0 -1
  174. package/dist/rules/noBlankBlockDescriptions.cjs +0 -63
  175. package/dist/rules/noBlankBlockDescriptions.cjs.map +0 -1
  176. package/dist/rules/noBlankBlocks.cjs +0 -54
  177. package/dist/rules/noBlankBlocks.cjs.map +0 -1
  178. package/dist/rules/noDefaults.cjs +0 -102
  179. package/dist/rules/noDefaults.cjs.map +0 -1
  180. package/dist/rules/noMissingSyntax.cjs +0 -196
  181. package/dist/rules/noMissingSyntax.cjs.map +0 -1
  182. package/dist/rules/noMultiAsterisks.cjs +0 -126
  183. package/dist/rules/noMultiAsterisks.cjs.map +0 -1
  184. package/dist/rules/noRestrictedSyntax.cjs +0 -68
  185. package/dist/rules/noRestrictedSyntax.cjs.map +0 -1
  186. package/dist/rules/noTypes.cjs +0 -101
  187. package/dist/rules/noTypes.cjs.map +0 -1
  188. package/dist/rules/noUndefinedTypes.cjs +0 -616
  189. package/dist/rules/noUndefinedTypes.cjs.map +0 -1
  190. package/dist/rules/normalizeSeeLinks.cjs +0 -271
  191. package/dist/rules/normalizeSeeLinks.cjs.map +0 -1
  192. package/dist/rules/preferImportTag.cjs +0 -362
  193. package/dist/rules/preferImportTag.cjs.map +0 -1
  194. package/dist/rules/requireAsteriskPrefix.cjs +0 -190
  195. package/dist/rules/requireAsteriskPrefix.cjs.map +0 -1
  196. package/dist/rules/requireDescription.cjs +0 -164
  197. package/dist/rules/requireDescription.cjs.map +0 -1
  198. package/dist/rules/requireDescriptionCompleteSentence.cjs +0 -321
  199. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +0 -1
  200. package/dist/rules/requireExample.cjs +0 -136
  201. package/dist/rules/requireExample.cjs.map +0 -1
  202. package/dist/rules/requireFileOverview.cjs +0 -194
  203. package/dist/rules/requireFileOverview.cjs.map +0 -1
  204. package/dist/rules/requireHyphenBeforeParamDescription.cjs +0 -166
  205. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +0 -1
  206. package/dist/rules/requireJsdoc.cjs +0 -721
  207. package/dist/rules/requireJsdoc.cjs.map +0 -1
  208. package/dist/rules/requireParam.cjs +0 -772
  209. package/dist/rules/requireParam.cjs.map +0 -1
  210. package/dist/rules/requireParamDescription.cjs +0 -105
  211. package/dist/rules/requireParamDescription.cjs.map +0 -1
  212. package/dist/rules/requireParamName.cjs +0 -68
  213. package/dist/rules/requireParamName.cjs.map +0 -1
  214. package/dist/rules/requireParamType.cjs +0 -104
  215. package/dist/rules/requireParamType.cjs.map +0 -1
  216. package/dist/rules/requireProperty.cjs +0 -63
  217. package/dist/rules/requireProperty.cjs.map +0 -1
  218. package/dist/rules/requirePropertyDescription.cjs +0 -29
  219. package/dist/rules/requirePropertyDescription.cjs.map +0 -1
  220. package/dist/rules/requirePropertyName.cjs +0 -29
  221. package/dist/rules/requirePropertyName.cjs.map +0 -1
  222. package/dist/rules/requirePropertyType.cjs +0 -29
  223. package/dist/rules/requirePropertyType.cjs.map +0 -1
  224. package/dist/rules/requireRejects.cjs +0 -226
  225. package/dist/rules/requireRejects.cjs.map +0 -1
  226. package/dist/rules/requireReturns.cjs +0 -262
  227. package/dist/rules/requireReturns.cjs.map +0 -1
  228. package/dist/rules/requireReturnsCheck.cjs +0 -225
  229. package/dist/rules/requireReturnsCheck.cjs.map +0 -1
  230. package/dist/rules/requireReturnsDescription.cjs +0 -72
  231. package/dist/rules/requireReturnsDescription.cjs.map +0 -1
  232. package/dist/rules/requireReturnsType.cjs +0 -68
  233. package/dist/rules/requireReturnsType.cjs.map +0 -1
  234. package/dist/rules/requireTags.cjs +0 -74
  235. package/dist/rules/requireTags.cjs.map +0 -1
  236. package/dist/rules/requireTemplate.cjs +0 -220
  237. package/dist/rules/requireTemplate.cjs.map +0 -1
  238. package/dist/rules/requireThrows.cjs +0 -118
  239. package/dist/rules/requireThrows.cjs.map +0 -1
  240. package/dist/rules/requireYields.cjs +0 -224
  241. package/dist/rules/requireYields.cjs.map +0 -1
  242. package/dist/rules/requireYieldsCheck.cjs +0 -179
  243. package/dist/rules/requireYieldsCheck.cjs.map +0 -1
  244. package/dist/rules/sortTags.cjs +0 -656
  245. package/dist/rules/sortTags.cjs.map +0 -1
  246. package/dist/rules/tagLines.cjs +0 -374
  247. package/dist/rules/tagLines.cjs.map +0 -1
  248. package/dist/rules/textEscaping.cjs +0 -141
  249. package/dist/rules/textEscaping.cjs.map +0 -1
  250. package/dist/rules/tsMethodSignatureStyle.cjs +0 -240
  251. package/dist/rules/tsMethodSignatureStyle.cjs.map +0 -1
  252. package/dist/rules/tsNoEmptyObjectType.cjs +0 -62
  253. package/dist/rules/tsNoEmptyObjectType.cjs.map +0 -1
  254. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +0 -104
  255. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +0 -1
  256. package/dist/rules/tsPreferFunctionType.cjs +0 -110
  257. package/dist/rules/tsPreferFunctionType.cjs.map +0 -1
  258. package/dist/rules/typeFormatting.cjs +0 -607
  259. package/dist/rules/typeFormatting.cjs.map +0 -1
  260. package/dist/rules/validTypes.cjs +0 -324
  261. package/dist/rules/validTypes.cjs.map +0 -1
  262. package/dist/tagNames.cjs +0 -244
  263. package/dist/tagNames.cjs.map +0 -1
  264. package/dist/to-valid-identifier.cjs +0 -263
  265. package/dist/utils/hasReturnValue.cjs +0 -495
  266. package/dist/utils/hasReturnValue.cjs.map +0 -1
  267. package/rollup.config.js +0 -16
  268. package/src/getJsdocProcessorPlugin.cts +0 -5
  269. package/src/index-cjs.js +0 -758
  270. package/src/index-esm.js +0 -196
  271. package/src/index.cjs.cts +0 -3
  272. package/src/iterateJsdoc.cts +0 -7
@@ -1,2150 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = iterateJsdoc;
7
- exports.getSettings = void 0;
8
- Object.defineProperty(exports, "parseComment", {
9
- enumerable: true,
10
- get: function () {
11
- return _jsdoccomment.parseComment;
12
- }
13
- });
14
- var jsdocUtils = _interopRequireWildcard(require("./jsdocUtils.cjs"));
15
- var _jsdoccomment = require("@es-joy/jsdoccomment");
16
- var _commentParser = require("comment-parser");
17
- var _esquery = _interopRequireDefault(require("esquery"));
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
- /**
21
- * @typedef {number} Integer
22
- */
23
-
24
- /**
25
- * @typedef {import('@es-joy/jsdoccomment').JsdocBlockWithInline} JsdocBlockWithInline
26
- */
27
-
28
- /**
29
- * @typedef {{
30
- * disallowName?: string,
31
- * allowName?: string,
32
- * context?: string,
33
- * comment?: string,
34
- * tags?: string[],
35
- * replacement?: string,
36
- * minimum?: Integer,
37
- * message?: string,
38
- * forceRequireReturn?: boolean
39
- * }} ContextObject
40
- */
41
- /**
42
- * @typedef {string|ContextObject} Context
43
- */
44
-
45
- /**
46
- * @callback CheckJsdoc
47
- * @param {{
48
- * lastIndex?: Integer,
49
- * isFunctionContext?: boolean,
50
- * selector?: string,
51
- * comment?: string
52
- * }} info
53
- * @param {null|((jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean|undefined)} handler
54
- * @param {import('eslint').Rule.Node} node
55
- * @returns {void}
56
- */
57
-
58
- /**
59
- * @callback ForEachPreferredTag
60
- * @param {string} tagName
61
- * @param {(
62
- * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
63
- * targetTagName: string
64
- * ) => void} arrayHandler
65
- * @param {boolean} [skipReportingBlockedTag]
66
- * @returns {void}
67
- */
68
-
69
- /**
70
- * @callback ReportSettings
71
- * @param {string} message
72
- * @returns {void}
73
- */
74
-
75
- /**
76
- * @callback ParseClosureTemplateTag
77
- * @param {import('comment-parser').Spec} tag
78
- * @returns {string[]}
79
- */
80
-
81
- /**
82
- * @callback GetPreferredTagNameObject
83
- * @param {{
84
- * tagName: string
85
- * }} cfg
86
- * @returns {string|false|{
87
- * message: string;
88
- * replacement?: string|undefined
89
- * }|{
90
- * blocked: true,
91
- * tagName: string
92
- * }}
93
- */
94
-
95
- /**
96
- * @typedef {{
97
- * forEachPreferredTag: ForEachPreferredTag,
98
- * reportSettings: ReportSettings,
99
- * parseClosureTemplateTag: ParseClosureTemplateTag,
100
- * getPreferredTagNameObject: GetPreferredTagNameObject,
101
- * pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith
102
- * isNameOrNamepathDefiningTag: IsNamepathX,
103
- * isNamepathReferencingTag: IsNamepathX,
104
- * isNamepathOrUrlReferencingTag: IsNamepathX,
105
- * tagMightHaveNameOrNamepath: IsNamepathX,
106
- * tagMightHaveName: IsNamepathX
107
- * }} BasicUtils
108
- */
109
-
110
- /**
111
- * @callback IsIteratingFunction
112
- * @returns {boolean}
113
- */
114
-
115
- /**
116
- * @callback IsVirtualFunction
117
- * @returns {boolean}
118
- */
119
-
120
- /**
121
- * @callback Stringify
122
- * @param {import('comment-parser').Block} tagBlock
123
- * @param {boolean} [specRewire]
124
- * @returns {string}
125
- */
126
-
127
- /**
128
- * @callback ReportJSDoc
129
- * @param {string} msg
130
- * @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag]
131
- * @param {((fixer: import('eslint').Rule.RuleFixer) => import('eslint').Rule.Fix|void)|null} [handler]
132
- * @param {boolean} [specRewire]
133
- * @param {undefined|{
134
- * [key: string]: string
135
- * }} [data]
136
- */
137
-
138
- /**
139
- * @callback GetRegexFromString
140
- * @param {string} str
141
- * @param {string} [requiredFlags]
142
- * @returns {RegExp}
143
- */
144
-
145
- /**
146
- * @callback GetTagDescription
147
- * @param {import('comment-parser').Spec} tg
148
- * @param {boolean} [returnArray]
149
- * @returns {string[]|string}
150
- */
151
-
152
- /**
153
- * @callback SetTagDescription
154
- * @param {import('comment-parser').Spec} tg
155
- * @param {RegExp} matcher
156
- * @param {(description: string) => string} setter
157
- * @returns {Integer}
158
- */
159
-
160
- /**
161
- * @callback GetDescription
162
- * @returns {{
163
- * description: string,
164
- * descriptions: string[],
165
- * lastDescriptionLine: Integer
166
- * }}
167
- */
168
-
169
- /**
170
- * @callback SetBlockDescription
171
- * @param {(
172
- * info: {
173
- * delimiter: string,
174
- * postDelimiter: string,
175
- * start: string
176
- * },
177
- * seedTokens: (
178
- * tokens?: Partial<import('comment-parser').Tokens>
179
- * ) => import('comment-parser').Tokens,
180
- * descLines: string[],
181
- * postDelims: string[]
182
- * ) => import('comment-parser').Line[]} setter
183
- * @returns {void}
184
- */
185
-
186
- /**
187
- * @callback SetDescriptionLines
188
- * @param {RegExp} matcher
189
- * @param {(description: string) => string} setter
190
- * @returns {Integer}
191
- */
192
-
193
- /**
194
- * @callback ChangeTag
195
- * @param {import('comment-parser').Spec} tag
196
- * @param {...Partial<import('comment-parser').Tokens>} tokens
197
- * @returns {void}
198
- */
199
-
200
- /**
201
- * @callback SetTag
202
- * @param {import('comment-parser').Spec & {
203
- * line: Integer
204
- * }} tag
205
- * @param {Partial<import('comment-parser').Tokens>} [tokens]
206
- * @returns {void}
207
- */
208
-
209
- /**
210
- * @callback RemoveTag
211
- * @param {Integer} tagIndex
212
- * @param {{
213
- * removeEmptyBlock?: boolean,
214
- * tagSourceOffset?: Integer
215
- * }} [cfg]
216
- * @returns {void}
217
- */
218
-
219
- /**
220
- * @callback AddTag
221
- * @param {string} targetTagName
222
- * @param {Integer} [number]
223
- * @param {Partial<import('comment-parser').Tokens>} [tokens]
224
- * @returns {void}
225
- */
226
-
227
- /**
228
- * @callback GetFirstLine
229
- * @returns {Integer|undefined}
230
- */
231
-
232
- /**
233
- * @typedef {(
234
- * tokens?: Partial<import('comment-parser').Tokens> | undefined
235
- * ) => import('comment-parser').Tokens} SeedTokens
236
- */
237
-
238
- /**
239
- * Sets tokens to empty string.
240
- * @callback EmptyTokens
241
- * @param {import('comment-parser').Tokens} tokens
242
- * @returns {void}
243
- */
244
-
245
- /**
246
- * @callback AddLine
247
- * @param {Integer} sourceIndex
248
- * @param {Partial<import('comment-parser').Tokens>} tokens
249
- * @returns {void}
250
- */
251
-
252
- /**
253
- * @callback AddLines
254
- * @param {Integer} tagIndex
255
- * @param {Integer} tagSourceOffset
256
- * @param {Integer} numLines
257
- * @returns {void}
258
- */
259
-
260
- /**
261
- * @callback MakeMultiline
262
- * @returns {void}
263
- */
264
-
265
- /**
266
- * @callback GetFunctionParameterNames
267
- * @param {boolean} [useDefaultObjectProperties]
268
- * @param {boolean} [ignoreInterfacedParameters]
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) => boolean}
337
- */
338
-
339
- /**
340
- * @callback DropPathSegmentQuotes
341
- * @param {string} name
342
- * @returns {string}
343
- */
344
-
345
- /**
346
- * @callback AvoidDocs
347
- * @param {boolean} [exemptSpecialMethods]
348
- * @returns {boolean}
349
- */
350
-
351
- /**
352
- * @callback TagMightHaveNamePositionTypePosition
353
- * @param {string} tagName
354
- * @param {import('./getDefaultTagStructureForMode.js').
355
- * TagStructure[]} [otherModeMaps]
356
- * @returns {boolean|{otherMode: true}}
357
- */
358
-
359
- /**
360
- * @callback TagMustHave
361
- * @param {string} tagName
362
- * @param {import('./getDefaultTagStructureForMode.js').
363
- * TagStructure[]} otherModeMaps
364
- * @returns {boolean|{
365
- * otherMode: false
366
- * }}
367
- */
368
-
369
- /**
370
- * @callback TagMissingRequiredTypeOrNamepath
371
- * @param {import('comment-parser').Spec} tag
372
- * @param {import('./getDefaultTagStructureForMode.js').
373
- * TagStructure[]} otherModeMaps
374
- * @returns {boolean|{
375
- * otherMode: false
376
- * }}
377
- */
378
-
379
- /**
380
- * @callback IsNamepathX
381
- * @param {string} tagName
382
- * @returns {boolean}
383
- */
384
-
385
- /**
386
- * @callback GetTagStructureForMode
387
- * @param {import('./jsdocUtils.js').ParserMode} mde
388
- * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
389
- */
390
-
391
- /**
392
- * @callback MayBeUndefinedTypeTag
393
- * @param {import('comment-parser').Spec} tag
394
- * @returns {boolean}
395
- */
396
-
397
- /**
398
- * @callback HasValueOrExecutorHasNonEmptyResolveValue
399
- * @param {boolean} anyPromiseAsReturn
400
- * @param {boolean} [allBranches]
401
- * @returns {boolean}
402
- */
403
-
404
- /**
405
- * @callback HasYieldValue
406
- * @returns {boolean}
407
- */
408
-
409
- /**
410
- * @callback HasYieldReturnValue
411
- * @returns {boolean}
412
- */
413
-
414
- /**
415
- * @callback HasThrowValue
416
- * @returns {boolean}
417
- */
418
-
419
- /**
420
- * @callback IsAsync
421
- * @returns {boolean|undefined}
422
- */
423
-
424
- /**
425
- * @callback GetTags
426
- * @param {string} tagName
427
- * @returns {import('comment-parser').Spec[]}
428
- */
429
-
430
- /**
431
- * @callback GetPresentTags
432
- * @param {string[]} tagList
433
- * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
434
- */
435
-
436
- /**
437
- * @callback FilterTags
438
- * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
439
- * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
440
- */
441
-
442
- /**
443
- * @callback FilterAllTags
444
- * @param {(tag: (import('comment-parser').Spec|
445
- * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter
446
- * @returns {(import('comment-parser').Spec|
447
- * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
448
- */
449
-
450
- /**
451
- * @callback getInlineTags
452
- * @returns {(import('comment-parser').Spec|
453
- * import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
454
- * line?: number | undefined; column?: number | undefined;
455
- * })[]}
456
- */
457
-
458
- /**
459
- * @callback GetTagsByType
460
- * @param {import('comment-parser').Spec[]} tags
461
- * @returns {{
462
- * tagsWithNames: import('comment-parser').Spec[],
463
- * tagsWithoutNames: import('comment-parser').Spec[]
464
- * }}
465
- */
466
-
467
- /**
468
- * @callback HasOptionTag
469
- * @param {string} tagName
470
- * @returns {boolean}
471
- */
472
-
473
- /**
474
- * @callback GetClassNode
475
- * @returns {Node|null}
476
- */
477
-
478
- /**
479
- * @callback GetClassJsdoc
480
- * @returns {null|JsdocBlockWithInline}
481
- */
482
-
483
- /**
484
- * @callback ClassHasTag
485
- * @param {string} tagName
486
- * @returns {boolean}
487
- */
488
-
489
- /**
490
- * @callback FindContext
491
- * @param {Context[]} contexts
492
- * @param {string|undefined} comment
493
- * @returns {{
494
- * foundContext: Context|undefined,
495
- * contextStr: string
496
- * }}
497
- */
498
-
499
- /**
500
- * @typedef {BasicUtils & {
501
- * isIteratingFunction: IsIteratingFunction,
502
- * isIteratingFunctionOrVariable: IsIteratingFunction,
503
- * isVirtualFunction: IsVirtualFunction,
504
- * stringify: Stringify,
505
- * reportJSDoc: ReportJSDoc,
506
- * getRegexFromString: GetRegexFromString,
507
- * getTagDescription: GetTagDescription,
508
- * setTagDescription: SetTagDescription,
509
- * getDescription: GetDescription,
510
- * setBlockDescription: SetBlockDescription,
511
- * setDescriptionLines: SetDescriptionLines,
512
- * changeTag: ChangeTag,
513
- * setTag: SetTag,
514
- * removeTag: RemoveTag,
515
- * addTag: AddTag,
516
- * getFirstLine: GetFirstLine,
517
- * seedTokens: SeedTokens,
518
- * emptyTokens: EmptyTokens,
519
- * addLine: AddLine,
520
- * addLines: AddLines,
521
- * makeMultiline: MakeMultiline,
522
- * flattenRoots: import('./jsdocUtils.js').FlattenRoots,
523
- * getFunctionParameterNames: GetFunctionParameterNames,
524
- * hasParams: HasParams,
525
- * isGenerator: IsGenerator,
526
- * isConstructor: IsConstructor,
527
- * getJsdocTagsDeep: GetJsdocTagsDeep,
528
- * getPreferredTagName: GetPreferredTagName,
529
- * isValidTag: IsValidTag,
530
- * hasATag: HasATag,
531
- * hasTag: HasTag,
532
- * comparePaths: ComparePaths,
533
- * dropPathSegmentQuotes: DropPathSegmentQuotes,
534
- * avoidDocs: AvoidDocs,
535
- * tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition,
536
- * tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition,
537
- * tagMustHaveNamePosition: TagMustHave,
538
- * tagMustHaveTypePosition: TagMustHave,
539
- * tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath,
540
- * isNameOrNamepathDefiningTag: IsNamepathX,
541
- * isNamepathReferencingTag: IsNamepathX,
542
- * isNamepathOrUrlReferencingTag: IsNamepathX,
543
- * tagMightHaveNameOrNamepath: IsNamepathX,
544
- * tagMightHaveName: IsNamepathX,
545
- * tagMightHaveNamepath: IsNamepathX,
546
- * getTagStructureForMode: GetTagStructureForMode,
547
- * mayBeUndefinedTypeTag: MayBeUndefinedTypeTag,
548
- * hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue,
549
- * hasYieldValue: HasYieldValue,
550
- * hasYieldReturnValue: HasYieldReturnValue,
551
- * hasThrowValue: HasThrowValue,
552
- * isAsync: IsAsync,
553
- * getTags: GetTags,
554
- * getPresentTags: GetPresentTags,
555
- * filterTags: FilterTags,
556
- * filterAllTags: FilterAllTags,
557
- * getInlineTags: getInlineTags,
558
- * getTagsByType: GetTagsByType,
559
- * hasOptionTag: HasOptionTag,
560
- * getClassNode: GetClassNode,
561
- * getClassJsdoc: GetClassJsdoc,
562
- * classHasTag: ClassHasTag,
563
- * findContext: FindContext
564
- * }} Utils
565
- */
566
-
567
- const {
568
- rewireSpecs,
569
- seedTokens
570
- } = _commentParser.util;
571
-
572
- /**
573
- * Should use ESLint rule's typing.
574
- * @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta
575
- */
576
-
577
- /**
578
- * A plain object for tracking state as needed by rules across iterations.
579
- * @typedef {{
580
- * globalTags: boolean,
581
- * hasDuplicates: {
582
- * [key: string]: boolean
583
- * },
584
- * selectorMap: {
585
- * [selector: string]: {
586
- * [comment: string]: Integer
587
- * }
588
- * },
589
- * hasTag: {
590
- * [key: string]: boolean
591
- * },
592
- * hasNonComment: number,
593
- * hasNonCommentBeforeTag: {
594
- * [key: string]: boolean|number
595
- * },
596
- * foundTypedefValues: string[]
597
- * }} StateObject
598
- */
599
-
600
- /**
601
- * The Node AST as supplied by the parser.
602
- * @typedef {import('eslint').Rule.Node} Node
603
- */
604
-
605
- /*
606
- const {
607
- align as commentAlign,
608
- flow: commentFlow,
609
- indent: commentIndent,
610
- } = transforms;
611
- */
612
-
613
- const globalState = new Map();
614
- /**
615
- * @param {import('eslint').Rule.RuleContext} context
616
- * @param {{
617
- * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference,
618
- * mode?: import('./jsdocUtils.js').ParserMode
619
- * }} cfg
620
- * @returns {BasicUtils}
621
- */
622
- const getBasicUtils = (context, {
623
- mode,
624
- tagNamePreference
625
- }) => {
626
- /** @type {BasicUtils} */
627
- const utils = {};
628
- for (const method of ['isNameOrNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNameOrNamepath', 'tagMightHaveName', 'tagMightHaveNamepath']) {
629
- /** @type {IsNamepathX} */
630
- utils[(/** @type {"isNameOrNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNameOrNamepath"|"tagMightHaveName"} */
631
- method)] = tagName => {
632
- return jsdocUtils[(/** @type {"isNameOrNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNameOrNamepath"|"tagMightHaveName"} */
633
- method)](tagName);
634
- };
635
- }
636
-
637
- /** @type {ReportSettings} */
638
- utils.reportSettings = message => {
639
- context.report({
640
- loc: {
641
- end: {
642
- column: 1,
643
- line: 1
644
- },
645
- start: {
646
- column: 1,
647
- line: 1
648
- }
649
- },
650
- message
651
- });
652
- };
653
-
654
- /** @type {ParseClosureTemplateTag} */
655
- utils.parseClosureTemplateTag = tag => {
656
- return jsdocUtils.parseClosureTemplateTag(tag);
657
- };
658
- utils.pathDoesNotBeginWith = jsdocUtils.pathDoesNotBeginWith;
659
-
660
- /** @type {GetPreferredTagNameObject} */
661
- utils.getPreferredTagNameObject = ({
662
- tagName
663
- }) => {
664
- const ret = jsdocUtils.getPreferredTagNameSimple(tagName, /** @type {import('./jsdocUtils.js').ParserMode} */mode, tagNamePreference, context);
665
- const isObject = ret && typeof ret === 'object';
666
- if (ret === false || isObject && !ret.replacement) {
667
- return {
668
- blocked: true,
669
- tagName
670
- };
671
- }
672
- return ret;
673
- };
674
- return utils;
675
- };
676
-
677
- /**
678
- * @callback Report
679
- * @param {string} message
680
- * @param {import('@eslint/core').RuleFixer|null} [fix]
681
- * @param {null|
682
- * {line?: Integer, column?: Integer}|
683
- * import('comment-parser').Spec & {line?: Integer}
684
- * } [jsdocLoc]
685
- * @param {undefined|{
686
- * [key: string]: string
687
- * }} [data]
688
- * @returns {void}
689
- */
690
-
691
- /**
692
- * @param {Node|null} node
693
- * @param {JsdocBlockWithInline} jsdoc
694
- * @param {import('eslint').AST.Token} jsdocNode
695
- * @param {Settings} settings
696
- * @param {Report} report
697
- * @param {import('eslint').Rule.RuleContext} context
698
- * @param {import('eslint').SourceCode} sc
699
- * @param {boolean|undefined} iteratingAll
700
- * @param {RuleConfig} ruleConfig
701
- * @param {string} indent
702
- * @returns {Utils}
703
- */
704
- const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iteratingAll, ruleConfig, indent) => {
705
- const ancestors = /** @type {import('eslint').Rule.Node[]} */node ? sc.getAncestors ? sc.getAncestors(node)
706
- /* c8 ignore next 5 */ :
707
- // @ts-expect-error ESLint 8
708
- context.getAncestors() : [];
709
-
710
- /* c8 ignore next -- Fallback to deprecated method */
711
- const {
712
- // @ts-expect-error ESLint < 10
713
- sourceCode = context.getSourceCode()
714
- } = context;
715
- const utils = /** @type {Utils} */getBasicUtils(context, settings);
716
- const {
717
- augmentsExtendsReplacesDocs,
718
- ignoreReplacesDocs,
719
- implementsReplacesDocs,
720
- maxLines,
721
- minLines,
722
- mode,
723
- overrideReplacesDocs,
724
- tagNamePreference
725
- } = settings;
726
- const functionTypes = ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'MethodDefinition'];
727
-
728
- /** @type {IsIteratingFunction} */
729
- utils.isIteratingFunction = () => {
730
- return !iteratingAll || functionTypes.includes(String(node?.type));
731
- };
732
-
733
- /** @type {IsIteratingFunction} */
734
- utils.isIteratingFunctionOrVariable = () => {
735
- if (utils.isIteratingFunction()) {
736
- return true;
737
- }
738
-
739
- /** @type {import('estree').VariableDeclarator[]} */
740
- const declarations = node?.type === 'VariableDeclaration' ? node.declarations : node?.type === 'ExportNamedDeclaration' && node.declaration?.type === 'VariableDeclaration' ? node.declaration.declarations : [];
741
- return declarations.some(({
742
- init
743
- }) => {
744
- return functionTypes.includes(String(init?.type));
745
- });
746
- };
747
-
748
- /** @type {IsVirtualFunction} */
749
- utils.isVirtualFunction = () => {
750
- return Boolean(iteratingAll) && utils.hasATag(['callback', 'function', 'func', 'method']);
751
- };
752
-
753
- /** @type {Stringify} */
754
- utils.stringify = (tagBlock, specRewire) => {
755
- let block;
756
- if (specRewire) {
757
- block = rewireSpecs(tagBlock);
758
- }
759
- return (0, _commentParser.stringify)(/** @type {import('comment-parser').Block} */
760
- specRewire ? block : tagBlock);
761
- };
762
-
763
- /** @type {ReportJSDoc} */
764
- utils.reportJSDoc = (msg, tag, handler, specRewire, data) => {
765
- report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => {
766
- const extraFix = handler(fixer);
767
- const replacement = utils.stringify(jsdoc, specRewire);
768
- if (!replacement) {
769
- const text = sourceCode.getText();
770
- const lastLineBreakPos = text.slice(0, jsdocNode.range[0]).search(/\n[ \t]*$/v);
771
- if (lastLineBreakPos > -1) {
772
- return [fixer.removeRange([lastLineBreakPos, jsdocNode.range[1]]), /* c8 ignore next 2 -- Guard */
773
- ...(extraFix ? [extraFix] : [])];
774
- }
775
- return [fixer.removeRange(/\s/v.test(text.charAt(jsdocNode.range[1])) ? [jsdocNode.range[0], jsdocNode.range[1] + 1] : jsdocNode.range), /* c8 ignore next 2 -- Guard */
776
- ...(extraFix ? [extraFix] : [])];
777
- }
778
- return [fixer.replaceText(jsdocNode, replacement), ...(extraFix ? [extraFix] : [])];
779
- } : null, tag, data);
780
- };
781
-
782
- /** @type {GetRegexFromString} */
783
- utils.getRegexFromString = (str, requiredFlags) => {
784
- return jsdocUtils.getRegexFromString(str, requiredFlags);
785
- };
786
-
787
- /** @type {GetTagDescription} */
788
- utils.getTagDescription = (tg, returnArray) => {
789
- return jsdocUtils.getTagDescription(tg, returnArray);
790
- };
791
-
792
- /** @type {SetTagDescription} */
793
- utils.setTagDescription = (tg, matcher, setter) => {
794
- let finalIdx = 0;
795
- tg.source.some(({
796
- tokens: {
797
- description
798
- }
799
- }, idx) => {
800
- if (description && matcher.test(description)) {
801
- tg.source[idx].tokens.description = setter(description);
802
- finalIdx = idx;
803
- return true;
804
- }
805
- return false;
806
- });
807
- return finalIdx;
808
- };
809
-
810
- /** @type {GetDescription} */
811
- utils.getDescription = () => {
812
- /** @type {string[]} */
813
- const descriptions = [];
814
- let lastDescriptionLine = 0;
815
- let tagsBegun = false;
816
- jsdoc.source.some(({
817
- tokens: {
818
- description,
819
- end,
820
- tag
821
- }
822
- }, idx) => {
823
- if (tag) {
824
- tagsBegun = true;
825
- }
826
- if (idx && (tag || end)) {
827
- lastDescriptionLine = idx - 1;
828
- if (!tagsBegun && description) {
829
- descriptions.push(description);
830
- }
831
- return true;
832
- }
833
- if (!tagsBegun && (idx || description)) {
834
- descriptions.push(description || (descriptions.length ? '' : '\n'));
835
- }
836
- return false;
837
- });
838
- return {
839
- description: descriptions.join('\n'),
840
- descriptions,
841
- lastDescriptionLine
842
- };
843
- };
844
-
845
- /** @type {SetBlockDescription} */
846
- utils.setBlockDescription = setter => {
847
- /** @type {string[]} */
848
- const descLines = [];
849
- /** @type {string[]} */
850
- const postDelims = [];
851
- /**
852
- * @type {undefined|Integer}
853
- */
854
- let startIdx;
855
- /**
856
- * @type {undefined|Integer}
857
- */
858
- let endIdx;
859
-
860
- /**
861
- * @type {undefined|{
862
- * delimiter: string,
863
- * postDelimiter: string,
864
- * start: string
865
- * }}
866
- */
867
- let info;
868
- jsdoc.source.some(({
869
- tokens: {
870
- delimiter,
871
- description,
872
- end,
873
- postDelimiter,
874
- start,
875
- tag
876
- }
877
- }, idx) => {
878
- if (delimiter === '/**') {
879
- return false;
880
- }
881
- if (startIdx === undefined) {
882
- startIdx = idx;
883
- info = {
884
- delimiter,
885
- postDelimiter,
886
- start
887
- };
888
- }
889
- if (tag || end) {
890
- endIdx = idx;
891
- return true;
892
- }
893
- postDelims.push(postDelimiter);
894
- descLines.push(description);
895
- return false;
896
- });
897
-
898
- /* c8 ignore else -- Won't be called if missing */
899
- if (descLines.length) {
900
- jsdoc.source.splice(/** @type {Integer} */startIdx, /** @type {Integer} */endIdx - (/** @type {Integer} */startIdx), ...setter(
901
- /**
902
- * @type {{
903
- * delimiter: string,
904
- * postDelimiter: string,
905
- * start: string
906
- * }}
907
- */
908
- info, seedTokens, descLines, postDelims));
909
- }
910
- };
911
-
912
- /** @type {SetDescriptionLines} */
913
- utils.setDescriptionLines = (matcher, setter) => {
914
- let finalIdx = 0;
915
- jsdoc.source.some(({
916
- tokens: {
917
- description,
918
- end,
919
- tag
920
- }
921
- }, idx) => {
922
- /* c8 ignore next 3 -- Already checked */
923
- if (idx && (tag || end)) {
924
- return true;
925
- }
926
- if (description && matcher.test(description)) {
927
- jsdoc.source[idx].tokens.description = setter(description);
928
- finalIdx = idx;
929
- return true;
930
- }
931
- return false;
932
- });
933
- return finalIdx;
934
- };
935
-
936
- /** @type {ChangeTag} */
937
- utils.changeTag = (tag, ...tokens) => {
938
- for (const [idx, src] of tag.source.entries()) {
939
- src.tokens = {
940
- ...src.tokens,
941
- ...tokens[idx]
942
- };
943
- }
944
- };
945
-
946
- /** @type {SetTag} */
947
- utils.setTag = (tag, tokens) => {
948
- tag.source = [{
949
- number: tag.line,
950
- // Or tag.source[0].number?
951
- source: '',
952
- tokens: seedTokens({
953
- delimiter: '*',
954
- postDelimiter: ' ',
955
- start: indent + ' ',
956
- tag: '@' + tag.tag,
957
- ...tokens
958
- })
959
- }];
960
- };
961
-
962
- /** @type {RemoveTag} */
963
- utils.removeTag = (tagIndex, {
964
- removeEmptyBlock = false,
965
- tagSourceOffset = 0
966
- } = {}) => {
967
- const {
968
- source: tagSource
969
- } = jsdoc.tags[tagIndex];
970
- /** @type {Integer|undefined} */
971
- let lastIndex;
972
- const firstNumber = jsdoc.source[0].number;
973
- tagSource.some(({
974
- number
975
- }, tagIdx) => {
976
- const sourceIndex = jsdoc.source.findIndex(({
977
- number: srcNumber
978
- }) => {
979
- return number === srcNumber;
980
- });
981
- // c8 ignore else
982
- if (sourceIndex > -1) {
983
- let spliceCount = 1;
984
- tagSource.slice(tagIdx + 1).some(({
985
- tokens: {
986
- end: ending,
987
- tag
988
- }
989
- }) => {
990
- if (!tag && !ending) {
991
- spliceCount++;
992
- return false;
993
- }
994
- return true;
995
- });
996
- const spliceIdx = sourceIndex + tagSourceOffset;
997
- const {
998
- delimiter,
999
- end
1000
- } = jsdoc.source[spliceIdx].tokens;
1001
- if (spliceIdx === 0 && jsdoc.tags.length >= 2 || !removeEmptyBlock && (end || delimiter === '/**')) {
1002
- const {
1003
- tokens
1004
- } = jsdoc.source[spliceIdx];
1005
- for (const item of ['postDelimiter', 'tag', 'postTag', 'type', 'postType', 'name', 'postName', 'description']) {
1006
- tokens[(
1007
- /**
1008
- * @type {"postDelimiter"|"tag"|"type"|"postType"|
1009
- * "postTag"|"name"|"postName"|"description"}
1010
- */
1011
- item)] = '';
1012
- }
1013
- } else {
1014
- jsdoc.source.splice(spliceIdx, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length));
1015
- tagSource.splice(tagIdx + tagSourceOffset, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length));
1016
- }
1017
- lastIndex = sourceIndex;
1018
- return true;
1019
- }
1020
- /* c8 ignore next 2 */
1021
- // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
1022
- return false;
1023
- });
1024
- for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
1025
- src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
1026
- }
1027
-
1028
- // Todo: Once rewiring of tags may be fixed in comment-parser to reflect
1029
- // missing tags, this step should be added here (so that, e.g.,
1030
- // if accessing `jsdoc.tags`, such as to add a new tag, the
1031
- // correct information will be available)
1032
- };
1033
-
1034
- /** @type {AddTag} */
1035
- utils.addTag = (targetTagName, number = (jsdoc.tags[jsdoc.tags.length - 1]?.source[0]?.number ?? jsdoc.source.findIndex(({
1036
- tokens: {
1037
- tag
1038
- }
1039
- }) => {
1040
- return tag;
1041
- }) - 1) + 1, tokens = {}) => {
1042
- jsdoc.source.splice(number, 0, {
1043
- number,
1044
- source: '',
1045
- tokens: seedTokens({
1046
- delimiter: '*',
1047
- postDelimiter: ' ',
1048
- start: indent + ' ',
1049
- tag: `@${targetTagName}`,
1050
- ...tokens
1051
- })
1052
- });
1053
- for (const src of jsdoc.source.slice(number + 1)) {
1054
- src.number++;
1055
- }
1056
- };
1057
-
1058
- /** @type {GetFirstLine} */
1059
- utils.getFirstLine = () => {
1060
- let firstLine;
1061
- for (const {
1062
- number,
1063
- tokens: {
1064
- tag
1065
- }
1066
- } of jsdoc.source) {
1067
- if (tag) {
1068
- firstLine = number;
1069
- break;
1070
- }
1071
- }
1072
- return firstLine;
1073
- };
1074
-
1075
- /** @type {SeedTokens} */
1076
- utils.seedTokens = seedTokens;
1077
-
1078
- /** @type {EmptyTokens} */
1079
- utils.emptyTokens = tokens => {
1080
- for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) {
1081
- tokens[(
1082
- /**
1083
- * @type {"start"|"postDelimiter"|"tag"|"type"|"postType"|
1084
- * "postTag"|"name"|"postName"|"description"|"end"|"lineEnd"}
1085
- */
1086
- prop)] = '';
1087
- }
1088
- };
1089
-
1090
- /** @type {AddLine} */
1091
- utils.addLine = (sourceIndex, tokens) => {
1092
- const number = (jsdoc.source[sourceIndex - 1]?.number || 0) + 1;
1093
- jsdoc.source.splice(sourceIndex, 0, {
1094
- number,
1095
- source: '',
1096
- tokens: seedTokens(tokens)
1097
- });
1098
- for (const src of jsdoc.source.slice(number + 1)) {
1099
- src.number++;
1100
- }
1101
- // If necessary, we can rewire the tags (misnamed method)
1102
- // rewireSource(jsdoc);
1103
- };
1104
-
1105
- /** @type {AddLines} */
1106
- utils.addLines = (tagIndex, tagSourceOffset, numLines) => {
1107
- const {
1108
- source: tagSource
1109
- } = jsdoc.tags[tagIndex];
1110
- /** @type {Integer|undefined} */
1111
- let lastIndex;
1112
- const firstNumber = jsdoc.source[0].number;
1113
- tagSource.some(({
1114
- number
1115
- }) => {
1116
- const makeLine = () => {
1117
- return {
1118
- number,
1119
- source: '',
1120
- tokens: seedTokens({
1121
- delimiter: '*',
1122
- start: indent + ' '
1123
- })
1124
- };
1125
- };
1126
- const makeLines = () => {
1127
- return Array.from({
1128
- length: numLines
1129
- }, makeLine);
1130
- };
1131
- const sourceIndex = jsdoc.source.findIndex(({
1132
- number: srcNumber,
1133
- tokens: {
1134
- end
1135
- }
1136
- }) => {
1137
- return number === srcNumber && !end;
1138
- });
1139
- // c8 ignore else
1140
- if (sourceIndex > -1) {
1141
- const lines = makeLines();
1142
- jsdoc.source.splice(sourceIndex + tagSourceOffset, 0, ...lines);
1143
-
1144
- // tagSource.splice(tagIdx + 1, 0, ...makeLines());
1145
- lastIndex = sourceIndex;
1146
- return true;
1147
- }
1148
- /* c8 ignore next 2 */
1149
- // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
1150
- return false;
1151
- });
1152
- for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
1153
- src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
1154
- }
1155
- };
1156
-
1157
- /** @type {MakeMultiline} */
1158
- utils.makeMultiline = () => {
1159
- const {
1160
- source: [{
1161
- tokens
1162
- }]
1163
- } = jsdoc;
1164
- const {
1165
- description,
1166
- lineEnd,
1167
- name,
1168
- postDelimiter,
1169
- tag,
1170
- type
1171
- } = tokens;
1172
- let {
1173
- tokens: {
1174
- postName,
1175
- postTag,
1176
- postType
1177
- }
1178
- } = jsdoc.source[0];
1179
-
1180
- // Strip trailing leftovers from single line ending
1181
- if (!description) {
1182
- if (postName) {
1183
- postName = '';
1184
- } else if (postType) {
1185
- postType = '';
1186
- } else /* c8 ignore else -- `comment-parser` prevents empty blocks currently per https://github.com/syavorsky/comment-parser/issues/128 */if (postTag) {
1187
- postTag = '';
1188
- }
1189
- }
1190
- utils.emptyTokens(tokens);
1191
- utils.addLine(1, {
1192
- delimiter: '*',
1193
- // If a description were present, it may have whitespace attached
1194
- // due to being at the end of the single line
1195
- description: description.trimEnd(),
1196
- name,
1197
- postDelimiter,
1198
- postName,
1199
- postTag,
1200
- postType,
1201
- start: indent + ' ',
1202
- tag,
1203
- type
1204
- });
1205
- utils.addLine(2, {
1206
- end: '*/',
1207
- lineEnd,
1208
- start: indent + ' '
1209
- });
1210
- };
1211
-
1212
- /**
1213
- * @type {import('./jsdocUtils.js').FlattenRoots}
1214
- */
1215
- utils.flattenRoots = jsdocUtils.flattenRoots;
1216
-
1217
- /** @type {GetFunctionParameterNames} */
1218
- utils.getFunctionParameterNames = (useDefaultObjectProperties, ignoreInterfacedParameters) => {
1219
- return jsdocUtils.getFunctionParameterNames(node, useDefaultObjectProperties, ignoreInterfacedParameters);
1220
- };
1221
-
1222
- /** @type {HasParams} */
1223
- utils.hasParams = () => {
1224
- return jsdocUtils.hasParams(/** @type {Node} */node);
1225
- };
1226
-
1227
- /** @type {IsGenerator} */
1228
- utils.isGenerator = () => {
1229
- return node !== null && Boolean(
1230
- /**
1231
- * @type {import('estree').FunctionDeclaration|
1232
- * import('estree').FunctionExpression}
1233
- */
1234
- node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(node.type) && /** @type {import('estree').FunctionDeclaration} */
1235
- (
1236
- /**
1237
- * @type {import('estree').ExportNamedDeclaration|
1238
- * import('estree').ExportDefaultDeclaration}
1239
- */
1240
- node.declaration)?.generator);
1241
- };
1242
-
1243
- /** @type {IsConstructor} */
1244
- utils.isConstructor = () => {
1245
- return jsdocUtils.isConstructor(/** @type {Node} */node);
1246
- };
1247
-
1248
- /** @type {GetJsdocTagsDeep} */
1249
- utils.getJsdocTagsDeep = tagName => {
1250
- const name = /** @type {string|false} */utils.getPreferredTagName({
1251
- tagName
1252
- });
1253
- if (!name) {
1254
- return false;
1255
- }
1256
- return jsdocUtils.getJsdocTagsDeep(jsdoc, name);
1257
- };
1258
-
1259
- /** @type {GetPreferredTagName} */
1260
- utils.getPreferredTagName = args => {
1261
- return jsdocUtils.getPreferredTagName(jsdoc, {
1262
- ...args,
1263
- context,
1264
- mode,
1265
- report,
1266
- tagNamePreference
1267
- });
1268
- };
1269
-
1270
- /** @type {IsValidTag} */
1271
- utils.isValidTag = (name, definedTags) => {
1272
- return jsdocUtils.isValidTag(context, mode, name, definedTags);
1273
- };
1274
-
1275
- /** @type {HasATag} */
1276
- utils.hasATag = names => {
1277
- return jsdocUtils.hasATag(jsdoc, names);
1278
- };
1279
-
1280
- /** @type {HasTag} */
1281
- utils.hasTag = name => {
1282
- return jsdocUtils.hasTag(jsdoc, name);
1283
- };
1284
-
1285
- /** @type {ComparePaths} */
1286
- utils.comparePaths = name => {
1287
- return jsdocUtils.comparePaths(name);
1288
- };
1289
-
1290
- /** @type {DropPathSegmentQuotes} */
1291
- utils.dropPathSegmentQuotes = name => {
1292
- return jsdocUtils.dropPathSegmentQuotes(name);
1293
- };
1294
-
1295
- /** @type {AvoidDocs} */
1296
- utils.avoidDocs = (exemptSpecialMethods = true) => {
1297
- 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'))) {
1298
- return true;
1299
- }
1300
- if (exemptSpecialMethods && jsdocUtils.exemptSpeciaMethods(jsdoc, node, context, /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */
1301
- ruleConfig.meta.schema)) {
1302
- return true;
1303
- }
1304
- const exemptedBy = context.options[0]?.exemptedBy ?? ['inheritDoc', ...(mode === 'closure' ? [] : ['inheritdoc'])];
1305
- if (exemptedBy.length && utils.getPresentTags(exemptedBy).length) {
1306
- return true;
1307
- }
1308
- return false;
1309
- };
1310
- for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
1311
- /** @type {TagMightHaveNamePositionTypePosition} */
1312
- utils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1313
- method)] = (tagName, otherModeMaps) => {
1314
- const result = jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1315
- method)](tagName);
1316
- if (result) {
1317
- return true;
1318
- }
1319
- if (!otherModeMaps) {
1320
- return false;
1321
- }
1322
- const otherResult = otherModeMaps.some(otherModeMap => {
1323
- return jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1324
- method)](tagName, otherModeMap);
1325
- });
1326
- return otherResult ? {
1327
- otherMode: true
1328
- } : false;
1329
- };
1330
- }
1331
-
1332
- /** @type {TagMissingRequiredTypeOrNamepath} */
1333
- utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => {
1334
- const result = jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName);
1335
- if (!result) {
1336
- return false;
1337
- }
1338
- const otherResult = otherModeMaps.every(otherModeMap => {
1339
- return jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap);
1340
- });
1341
- return otherResult ? true : {
1342
- otherMode: false
1343
- };
1344
- };
1345
- for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) {
1346
- /** @type {TagMustHave} */
1347
- utils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1348
- method)] = (tagName, otherModeMaps) => {
1349
- const result = jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1350
- method)](tagName);
1351
- if (!result) {
1352
- return false;
1353
- }
1354
-
1355
- // if (!otherModeMaps) { return true; }
1356
-
1357
- const otherResult = otherModeMaps.every(otherModeMap => {
1358
- return jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1359
- method)](tagName, otherModeMap);
1360
- });
1361
- return otherResult ? true : {
1362
- otherMode: false
1363
- };
1364
- };
1365
- }
1366
-
1367
- /** @type {GetTagStructureForMode} */
1368
- utils.getTagStructureForMode = mde => {
1369
- return jsdocUtils.getTagStructureForMode(mde, settings.structuredTags);
1370
- };
1371
-
1372
- /** @type {MayBeUndefinedTypeTag} */
1373
- utils.mayBeUndefinedTypeTag = tag => {
1374
- return jsdocUtils.mayBeUndefinedTypeTag(tag, settings.mode);
1375
- };
1376
-
1377
- /** @type {HasValueOrExecutorHasNonEmptyResolveValue} */
1378
- utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
1379
- return jsdocUtils.hasValueOrExecutorHasNonEmptyResolveValue(/** @type {Node} */node, anyPromiseAsReturn, allBranches);
1380
- };
1381
-
1382
- /** @type {HasYieldValue} */
1383
- utils.hasYieldValue = () => {
1384
- if (['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(/** @type {Node} */node.type)) {
1385
- return jsdocUtils.hasYieldValue(/** @type {import('estree').Declaration|import('estree').Expression} */
1386
- /** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */
1387
- node.declaration);
1388
- }
1389
- return jsdocUtils.hasYieldValue(/** @type {Node} */node);
1390
- };
1391
-
1392
- /** @type {HasYieldReturnValue} */
1393
- utils.hasYieldReturnValue = () => {
1394
- return jsdocUtils.hasYieldValue(/** @type {Node} */node, true);
1395
- };
1396
-
1397
- /** @type {HasThrowValue} */
1398
- utils.hasThrowValue = () => {
1399
- return jsdocUtils.hasThrowValue(node);
1400
- };
1401
-
1402
- /** @type {IsAsync} */
1403
- utils.isAsync = () => {
1404
- return Boolean(node && 'async' in node && node.async);
1405
- };
1406
-
1407
- /** @type {GetTags} */
1408
- utils.getTags = tagName => {
1409
- return jsdocUtils.getTags(jsdoc, tagName);
1410
- };
1411
-
1412
- /** @type {GetPresentTags} */
1413
- utils.getPresentTags = tagList => {
1414
- return jsdocUtils.filterTags(jsdoc, tag => {
1415
- return tagList.includes(tag.tag);
1416
- });
1417
- };
1418
-
1419
- /** @type {FilterTags} */
1420
- utils.filterTags = filter => {
1421
- return jsdocUtils.filterTags(jsdoc, tag => {
1422
- return filter(tag);
1423
- });
1424
- };
1425
-
1426
- /** @type {FilterAllTags} */
1427
- utils.filterAllTags = filter => {
1428
- const tags = jsdocUtils.getAllTags(jsdoc);
1429
- return tags.filter(tag => {
1430
- return filter(tag);
1431
- });
1432
- };
1433
- utils.getInlineTags = () => {
1434
- return jsdocUtils.getInlineTags(jsdoc);
1435
- };
1436
-
1437
- /** @type {GetTagsByType} */
1438
- utils.getTagsByType = tags => {
1439
- return jsdocUtils.getTagsByType(context, mode, tags);
1440
- };
1441
-
1442
- /** @type {HasOptionTag} */
1443
- utils.hasOptionTag = tagName => {
1444
- const {
1445
- tags
1446
- } = context.options[0] ?? {};
1447
- return Boolean(tags && tags.includes(tagName));
1448
- };
1449
-
1450
- /** @type {GetClassNode} */
1451
- utils.getClassNode = () => {
1452
- return [...ancestors, node].toReversed().find(parent => {
1453
- return parent && ['ClassDeclaration', 'ClassExpression'].includes(parent.type);
1454
- }) ?? null;
1455
- };
1456
-
1457
- /** @type {GetClassJsdoc} */
1458
- utils.getClassJsdoc = () => {
1459
- const classNode = utils.getClassNode();
1460
- if (!classNode) {
1461
- return null;
1462
- }
1463
- const classJsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, classNode, {
1464
- maxLines,
1465
- minLines
1466
- });
1467
- if (classJsdocNode) {
1468
- return (0, _jsdoccomment.parseComment)(classJsdocNode, '');
1469
- }
1470
- return null;
1471
- };
1472
-
1473
- /** @type {ClassHasTag} */
1474
- utils.classHasTag = tagName => {
1475
- const classJsdoc = utils.getClassJsdoc();
1476
- return classJsdoc !== null && jsdocUtils.hasTag(classJsdoc, tagName);
1477
- };
1478
-
1479
- /** @type {ForEachPreferredTag} */
1480
- utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag) => {
1481
- return jsdocUtils.forEachPreferredTag(jsdoc, tagName, arrayHandler, {
1482
- context,
1483
- mode,
1484
- report,
1485
- skipReportingBlockedTag,
1486
- tagNamePreference
1487
- });
1488
- };
1489
-
1490
- /** @type {FindContext} */
1491
- utils.findContext = (contexts, comment) => {
1492
- const foundContext = contexts.find(cntxt => {
1493
- return typeof cntxt === 'string' ? _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt), undefined, {
1494
- visitorKeys: sourceCode.visitorKeys
1495
- }) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt.context), undefined, {
1496
- visitorKeys: sourceCode.visitorKeys
1497
- })) && comment === cntxt.comment;
1498
- });
1499
- const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : String(foundContext);
1500
- return {
1501
- contextStr,
1502
- foundContext
1503
- };
1504
- };
1505
- return utils;
1506
- };
1507
-
1508
- /**
1509
- * @typedef {{
1510
- * [key: string]: false|string|{
1511
- * message: string,
1512
- * replacement?: false|string
1513
- * skipRootChecking?: boolean
1514
- * unifyParentAndChildTypeChecks?: boolean
1515
- * }
1516
- * }} PreferredTypes
1517
- */
1518
- /**
1519
- * @typedef {{
1520
- * [key: string]: {
1521
- * name?: "text"|"name-defining"|"namepath-defining"|"namepath-referencing"|false,
1522
- * type?: boolean|string[],
1523
- * required?: ("name"|"type"|"typeOrNameRequired")[]
1524
- * }
1525
- * }} StructuredTags
1526
- */
1527
- /**
1528
- * Settings from ESLint types.
1529
- * @typedef {{
1530
- * maxLines: Integer,
1531
- * minLines: Integer,
1532
- * tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
1533
- * mode: import('./jsdocUtils.js').ParserMode,
1534
- * preferredTypes: PreferredTypes,
1535
- * structuredTags: StructuredTags,
1536
- * contexts?: Context[],
1537
- * augmentsExtendsReplacesDocs?: boolean,
1538
- * ignoreReplacesDocs?: boolean,
1539
- * implementsReplacesDocs?: boolean,
1540
- * overrideReplacesDocs?: boolean,
1541
- * ignoreInternal?: boolean,
1542
- * ignorePrivate?: boolean,
1543
- * exemptDestructuredRootsFromChecks?: boolean,
1544
- * skipInvokedExpressionsForCommentFinding?: boolean
1545
- * }} Settings
1546
- */
1547
-
1548
- /**
1549
- * @typedef {{
1550
- * settings?: {
1551
- * jsdoc?: {
1552
- * ignorePrivate: boolean,
1553
- * ignoreInternal: boolean,
1554
- * maxLines: Integer,
1555
- * minLines: Integer,
1556
- * tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
1557
- * preferredTypes: PreferredTypes,
1558
- * structuredTags: StructuredTags,
1559
- * overrideReplacesDocs: boolean,
1560
- * ignoreReplacesDocs: boolean,
1561
- * implementsReplacesDocs: boolean,
1562
- * augmentsExtendsReplacesDocs: boolean,
1563
- * exemptDestructuredRootsFromChecks: boolean,
1564
- * skipInvokedExpressionsForCommentFinding: boolean,
1565
- * mode: import('./jsdocUtils.js').ParserMode,
1566
- * contexts: Context[],
1567
- * }
1568
- * }
1569
- * }} JSDocSettings
1570
- */
1571
-
1572
- /**
1573
- * @param {import('eslint').Rule.RuleContext & JSDocSettings} context
1574
- * @returns {Settings|false}
1575
- */
1576
- const getSettings = context => {
1577
- /* eslint-disable perfectionist/sort-objects */
1578
- const settings = {
1579
- // All rules
1580
- ignorePrivate: Boolean(context.settings.jsdoc?.ignorePrivate),
1581
- ignoreInternal: Boolean(context.settings.jsdoc?.ignoreInternal),
1582
- maxLines: Number(context.settings.jsdoc?.maxLines ?? 1),
1583
- minLines: Number(context.settings.jsdoc?.minLines ?? 0),
1584
- skipInvokedExpressionsForCommentFinding: Boolean(context.settings.jsdoc?.skipInvokedExpressionsForCommentFinding),
1585
- // `check-tag-names` and many returns/param rules
1586
- tagNamePreference: context.settings.jsdoc?.tagNamePreference ?? {},
1587
- // `check-types` and `no-undefined-types`
1588
- preferredTypes: context.settings.jsdoc?.preferredTypes ?? {},
1589
- // `check-types`, `no-undefined-types`, `valid-types`
1590
- structuredTags: context.settings.jsdoc?.structuredTags ?? {},
1591
- // `require-param`, `require-description`, `require-example`,
1592
- // `require-returns`, `require-throw`, `require-yields`
1593
- overrideReplacesDocs: context.settings.jsdoc?.overrideReplacesDocs,
1594
- ignoreReplacesDocs: context.settings.jsdoc?.ignoreReplacesDocs,
1595
- implementsReplacesDocs: context.settings.jsdoc?.implementsReplacesDocs,
1596
- augmentsExtendsReplacesDocs: context.settings.jsdoc?.augmentsExtendsReplacesDocs,
1597
- // `require-param-type`, `require-param-description`
1598
- exemptDestructuredRootsFromChecks: context.settings.jsdoc?.exemptDestructuredRootsFromChecks,
1599
- // Many rules, e.g., `check-tag-names`
1600
- mode: context.settings.jsdoc?.mode ?? 'typescript',
1601
- // Many rules
1602
- contexts: context.settings.jsdoc?.contexts
1603
- };
1604
- /* eslint-enable perfectionist/sort-objects */
1605
-
1606
- jsdocUtils.setTagStructure(settings.mode);
1607
- try {
1608
- jsdocUtils.overrideTagStructure(settings.structuredTags);
1609
- } catch (error) {
1610
- context.report({
1611
- loc: {
1612
- end: {
1613
- column: 1,
1614
- line: 1
1615
- },
1616
- start: {
1617
- column: 1,
1618
- line: 1
1619
- }
1620
- },
1621
- message: /** @type {Error} */error.message
1622
- });
1623
- return false;
1624
- }
1625
- return settings;
1626
- };
1627
-
1628
- /**
1629
- * Create the report function
1630
- * @callback MakeReport
1631
- * @param {import('eslint').Rule.RuleContext} context
1632
- * @param {import('estree').Node} commentNode
1633
- * @returns {Report}
1634
- */
1635
-
1636
- /** @type {MakeReport} */
1637
- exports.getSettings = getSettings;
1638
- const makeReport = (context, commentNode) => {
1639
- /** @type {Report} */
1640
- const report = (message, fix = null, jsdocLoc = null, data = undefined) => {
1641
- let loc;
1642
- if (jsdocLoc) {
1643
- if (!('line' in jsdocLoc)) {
1644
- jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number;
1645
- }
1646
- const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + (/** @type {Integer} */jsdocLoc.line);
1647
- loc = {
1648
- end: {
1649
- column: 0,
1650
- line: lineNumber
1651
- },
1652
- start: {
1653
- column: 0,
1654
- line: lineNumber
1655
- }
1656
- };
1657
- if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') {
1658
- const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column;
1659
- loc.end.column = colNumber;
1660
- loc.start.column = colNumber;
1661
- }
1662
- }
1663
- context.report({
1664
- data,
1665
- fix,
1666
- loc,
1667
- message,
1668
- node: commentNode
1669
- });
1670
- };
1671
- return report;
1672
- };
1673
-
1674
- /**
1675
- * @typedef {(
1676
- * arg: {
1677
- * context: import('eslint').Rule.RuleContext,
1678
- * sourceCode: import('eslint').SourceCode,
1679
- * indent?: string,
1680
- * info?: {
1681
- * comment?: string|undefined,
1682
- * lastIndex?: Integer|undefined
1683
- * },
1684
- * state?: StateObject,
1685
- * globalState?: Map<string, Map<string, string>>,
1686
- * jsdoc?: JsdocBlockWithInline,
1687
- * jsdocNode?: import('eslint').Rule.Node & {
1688
- * range: [number, number]
1689
- * },
1690
- * node?: Node,
1691
- * allComments?: import('estree').Node[]
1692
- * report?: Report,
1693
- * makeReport?: MakeReport,
1694
- * settings: Settings,
1695
- * utils: BasicUtils,
1696
- * }
1697
- * ) => void } JsdocVisitorBasic
1698
- */
1699
- /**
1700
- * @typedef {(
1701
- * arg: {
1702
- * context: import('eslint').Rule.RuleContext,
1703
- * sourceCode: import('eslint').SourceCode,
1704
- * indent: string,
1705
- * info: {
1706
- * comment?: string|undefined,
1707
- * lastIndex?: Integer|undefined
1708
- * },
1709
- * state: StateObject,
1710
- * globalState: Map<string, Map<string, string>>,
1711
- * jsdoc: JsdocBlockWithInline,
1712
- * jsdocNode: import('eslint').Rule.Node & {
1713
- * range: [number, number]
1714
- * },
1715
- * node: Node|null,
1716
- * allComments?: import('estree').Node[]
1717
- * report: Report,
1718
- * makeReport?: MakeReport,
1719
- * settings: Settings,
1720
- * utils: Utils,
1721
- * }
1722
- * ) => void } JsdocVisitor
1723
- */
1724
-
1725
- /**
1726
- * @param {{
1727
- * comment?: string,
1728
- * lastIndex?: Integer,
1729
- * selector?: string,
1730
- * isFunctionContext?: boolean,
1731
- * }} info
1732
- * @param {string} indent
1733
- * @param {JsdocBlockWithInline} jsdoc
1734
- * @param {RuleConfig} ruleConfig
1735
- * @param {import('eslint').Rule.RuleContext} context
1736
- * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
1737
- * @param {Node|null} node
1738
- * @param {Settings} settings
1739
- * @param {import('eslint').SourceCode} sourceCode
1740
- * @param {JsdocVisitor} iterator
1741
- * @param {StateObject} state
1742
- * @param {boolean} [iteratingAll]
1743
- * @returns {void}
1744
- */
1745
- const iterate = (info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => {
1746
- const jsdocNde = /** @type {unknown} */jsdocNode;
1747
- const report = makeReport(context, /** @type {import('estree').Node} */
1748
- jsdocNde);
1749
- const utils = getUtils(node, jsdoc, /** @type {import('eslint').AST.Token} */
1750
- jsdocNode, settings, report, context, sourceCode, iteratingAll, ruleConfig, indent);
1751
- if (!ruleConfig.checkInternal && settings.ignoreInternal && utils.hasTag('internal')) {
1752
- return;
1753
- }
1754
- if (!ruleConfig.checkPrivate && settings.ignorePrivate && (utils.hasTag('private') || jsdocUtils.filterTags(jsdoc, ({
1755
- tag
1756
- }) => {
1757
- return tag === 'access';
1758
- }).some(({
1759
- description
1760
- }) => {
1761
- return description === 'private';
1762
- }))) {
1763
- return;
1764
- }
1765
- iterator({
1766
- context,
1767
- globalState,
1768
- indent,
1769
- info,
1770
- jsdoc,
1771
- jsdocNode: (
1772
- /**
1773
- * @type {import('eslint').Rule.Node & {
1774
- * range: [number, number];}}
1775
- */
1776
- jsdocNde),
1777
- node,
1778
- report,
1779
- settings,
1780
- sourceCode,
1781
- state,
1782
- utils
1783
- });
1784
- };
1785
-
1786
- /**
1787
- * @param {string[]} lines
1788
- * @param {import('estree').Comment} jsdocNode
1789
- * @returns {[indent: string, jsdoc: JsdocBlockWithInline]}
1790
- */
1791
- const getIndentAndJSDoc = function (lines, jsdocNode) {
1792
- const sourceLine = lines[/** @type {import('estree').SourceLocation} */
1793
- jsdocNode.loc.start.line - 1];
1794
- let indentChar = sourceLine.charAt(0);
1795
- if (indentChar !== ' ' && indentChar !== '\t') {
1796
- indentChar = ' ';
1797
- }
1798
- const indnt = indentChar.repeat(/** @type {import('estree').SourceLocation} */
1799
- jsdocNode.loc.start.column);
1800
- const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, '');
1801
- return [indnt, jsdc];
1802
- };
1803
-
1804
- /**
1805
- *
1806
- * @typedef {{node: Node, state: StateObject}} NonCommentArgs
1807
- */
1808
-
1809
- /**
1810
- * @typedef {object} RuleConfig
1811
- * @property {EslintRuleMeta} meta ESLint rule meta
1812
- * @property {import('./jsdocUtils.js').DefaultContexts} [contextDefaults] Any default contexts
1813
- * @property {true} [contextSelected] Whether to force a `contexts` check
1814
- * @property {(context: import('eslint').Rule.RuleContext) => import('eslint').Rule.RuleContext} [modifyContext] Modify the rule's context object
1815
- * @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default
1816
- * regardless of context
1817
- * @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted)
1818
- * @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted)
1819
- * @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment
1820
- * @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts
1821
- * @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as
1822
- * non-tracked may conduct further actions)
1823
- * @property {true} [matchContext] Whether the rule expects contexts to be based on a match option
1824
- * @property {(args: {
1825
- * context: import('eslint').Rule.RuleContext,
1826
- * state: StateObject,
1827
- * settings: Settings,
1828
- * utils: BasicUtils
1829
- * }) => void} [exit] Handler to be executed upon exiting iteration of program AST
1830
- * @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes
1831
- * to be supplied nodes without comments
1832
- */
1833
-
1834
- /**
1835
- * Create an eslint rule that iterates over all JSDocs, regardless of whether
1836
- * they are attached to a function-like node.
1837
- * @param {JsdocVisitor} iterator
1838
- * @param {RuleConfig} ruleConfig The rule's configuration
1839
- * @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info.
1840
- * @param {boolean} [additiveCommentContexts] If true, will have a separate
1841
- * iteration for each matching comment context. Otherwise, will iterate
1842
- * once if there is a single matching comment context.
1843
- * @returns {import('eslint').Rule.RuleModule}
1844
- */
1845
- const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => {
1846
- /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
1847
- let handler;
1848
-
1849
- /** @type {Settings|false} */
1850
- let settings;
1851
-
1852
- /**
1853
- * @param {import('eslint').Rule.RuleContext} context
1854
- * @param {Node|null} node
1855
- * @param {import('estree').Comment[]} jsdocNodes
1856
- * @param {StateObject} state
1857
- * @param {boolean} [lastCall]
1858
- * @returns {void}
1859
- */
1860
- const callIterator = (context, node, jsdocNodes, state, lastCall) => {
1861
- /* c8 ignore next -- Fallback to deprecated method */
1862
- const {
1863
- // @ts-expect-error ESLint < 10
1864
- sourceCode = context.getSourceCode()
1865
- } = context;
1866
- const {
1867
- lines
1868
- } = sourceCode;
1869
- const utils = getBasicUtils(context, /** @type {Settings} */settings);
1870
- for (const jsdocNode of jsdocNodes) {
1871
- const jsdocNde = /** @type {unknown} */jsdocNode;
1872
- if (!/^\/\*\*\s/v.test(sourceCode.getText(/** @type {import('estree').Node} */
1873
- jsdocNde))) {
1874
- continue;
1875
- }
1876
- const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode);
1877
- if (additiveCommentContexts) {
1878
- for (const [idx, {
1879
- comment
1880
- }] of /** @type {ContextObject[]} */contexts.entries()) {
1881
- if (comment && handler(comment, jsdoc) === false) {
1882
- continue;
1883
- }
1884
- iterate({
1885
- comment,
1886
- lastIndex: idx,
1887
- selector: node?.type
1888
- }, indent, jsdoc, ruleConfig, context, jsdocNode, /** @type {Node} */
1889
- node, /** @type {Settings} */
1890
- settings, sourceCode, iterator, state, true);
1891
- }
1892
- continue;
1893
- }
1894
- let lastComment;
1895
- let lastIndex;
1896
- // eslint-disable-next-line no-loop-func
1897
- if (contexts && contexts.every(({
1898
- comment
1899
- }, idx) => {
1900
- lastComment = comment;
1901
- lastIndex = idx;
1902
- return comment && handler(comment, jsdoc) === false;
1903
- })) {
1904
- continue;
1905
- }
1906
- iterate(lastComment ? {
1907
- comment: lastComment,
1908
- lastIndex,
1909
- selector: node?.type
1910
- } : {
1911
- lastIndex,
1912
- selector: node?.type
1913
- }, indent, jsdoc, ruleConfig, context, jsdocNode, node, /** @type {Settings} */
1914
- settings, sourceCode, iterator, state, true);
1915
- }
1916
- const settngs = /** @type {Settings} */settings;
1917
- if (lastCall && ruleConfig.exit) {
1918
- ruleConfig.exit({
1919
- context,
1920
- settings: settngs,
1921
- state,
1922
- utils
1923
- });
1924
- }
1925
- };
1926
- return {
1927
- create(context) {
1928
- /* c8 ignore next -- Fallback to deprecated method */
1929
- const {
1930
- // @ts-expect-error ESLint < 10
1931
- sourceCode = context.getSourceCode()
1932
- } = context;
1933
- settings = getSettings(context);
1934
- if (!settings) {
1935
- return {};
1936
- }
1937
- if (contexts) {
1938
- handler = (0, _jsdoccomment.commentHandler)({
1939
- ...settings,
1940
- mode: settings.mode === 'permissive' ? 'typescript' : settings.mode
1941
- });
1942
- }
1943
- const trackedJsdocs = new Set();
1944
- const state = {};
1945
- return {
1946
- /**
1947
- * @param {import('eslint').Rule.Node} node
1948
- * @returns {void}
1949
- */
1950
- '*:not(Program)'(node) {
1951
- const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, /** @type {Settings} */settings);
1952
- if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) {
1953
- return;
1954
- }
1955
- if (!commentNode) {
1956
- if (ruleConfig.nonComment) {
1957
- const ste = /** @type {StateObject} */state;
1958
- ruleConfig.nonComment({
1959
- node,
1960
- state: ste
1961
- });
1962
- }
1963
- return;
1964
- }
1965
- trackedJsdocs.add(commentNode);
1966
- callIterator(context, node, [(/** @type {import('estree').Comment} */
1967
- commentNode)], /** @type {StateObject} */state);
1968
- },
1969
- 'Program:exit'() {
1970
- const allComments = /** @type {import('estree').Comment[]} */
1971
- sourceCode.getAllComments();
1972
- const untrackedJSdoc = allComments.filter(node => {
1973
- return !trackedJsdocs.has(node);
1974
- });
1975
- callIterator(context, null, untrackedJSdoc, /** @type {StateObject} */
1976
- state, true);
1977
- }
1978
- };
1979
- },
1980
- meta: ruleConfig.meta
1981
- };
1982
- };
1983
-
1984
- /**
1985
- * Create an eslint rule that iterates over all JSDocs, regardless of whether
1986
- * they are attached to a function-like node.
1987
- * @param {JsdocVisitorBasic} iterator
1988
- * @param {RuleConfig} ruleConfig
1989
- * @returns {import('eslint').Rule.RuleModule}
1990
- */
1991
- const checkFile = (iterator, ruleConfig) => {
1992
- return {
1993
- create(context) {
1994
- /* c8 ignore next -- Fallback to deprecated method */
1995
- const {
1996
- // @ts-expect-error ESLint < 10
1997
- sourceCode = context.getSourceCode()
1998
- } = context;
1999
- const settings = getSettings(context);
2000
- if (!settings) {
2001
- return {};
2002
- }
2003
- return {
2004
- 'Program:exit'() {
2005
- const allComms = /** @type {unknown} */sourceCode.getAllComments();
2006
- const utils = getBasicUtils(context, settings);
2007
- iterator({
2008
- allComments: (/** @type {import('estree').Node[]} */allComms),
2009
- context,
2010
- makeReport,
2011
- settings,
2012
- sourceCode,
2013
- utils
2014
- });
2015
- }
2016
- };
2017
- },
2018
- meta: ruleConfig.meta
2019
- };
2020
- };
2021
- /**
2022
- * @param {JsdocVisitor} iterator
2023
- * @param {RuleConfig} ruleConfig
2024
- * @returns {import('eslint').Rule.RuleModule}
2025
- */
2026
- function iterateJsdoc(iterator, ruleConfig) {
2027
- const metaType = ruleConfig?.meta?.type;
2028
- if (!metaType || !['layout', 'problem', 'suggestion'].includes(metaType)) {
2029
- throw new TypeError('Rule must include `meta.type` option (with value "problem", "suggestion", or "layout")');
2030
- }
2031
- if (typeof iterator !== 'function') {
2032
- throw new TypeError('The iterator argument must be a function.');
2033
- }
2034
- if (ruleConfig.checkFile) {
2035
- return checkFile(/** @type {JsdocVisitorBasic} */iterator, ruleConfig);
2036
- }
2037
- if (ruleConfig.iterateAllJsdocs) {
2038
- return iterateAllJsdocs(iterator, ruleConfig);
2039
- }
2040
-
2041
- /** @type {import('eslint').Rule.RuleModule} */
2042
- return {
2043
- /**
2044
- * The entrypoint for the JSDoc rule.
2045
- * @param {import('eslint').Rule.RuleContext} ctx
2046
- * a reference to the context which hold all important information
2047
- * like settings and the sourcecode to check.
2048
- * @returns {import('eslint').Rule.RuleListener}
2049
- * a listener with parser callback function.
2050
- */
2051
- create(ctx) {
2052
- const context = ruleConfig.modifyContext ? ruleConfig.modifyContext(ctx) : ctx;
2053
- const settings = getSettings(context);
2054
- if (!settings) {
2055
- return {};
2056
- }
2057
-
2058
- /**
2059
- * @type {Context[]|undefined}
2060
- */
2061
- let contexts;
2062
- if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) {
2063
- contexts = ruleConfig.matchContext && context.options[0]?.match ? context.options[0].match : jsdocUtils.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings);
2064
- if (contexts) {
2065
- contexts = contexts.map(obj => {
2066
- if (typeof obj === 'object' && !obj.context) {
2067
- return {
2068
- ...obj,
2069
- context: 'any'
2070
- };
2071
- }
2072
- return obj;
2073
- });
2074
- }
2075
- const hasPlainAny = contexts?.includes('any');
2076
- const hasObjectAny = !hasPlainAny && contexts?.find(ctxt => {
2077
- if (typeof ctxt === 'string') {
2078
- return false;
2079
- }
2080
- return ctxt?.context === 'any';
2081
- });
2082
- if (hasPlainAny || hasObjectAny) {
2083
- return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? (/** @type {ContextObject[]} */contexts) : null, ruleConfig.matchContext).create(context);
2084
- }
2085
- }
2086
-
2087
- /* c8 ignore next -- Fallback to deprecated method */
2088
- const {
2089
- // @ts-expect-error ESLint < 10
2090
- sourceCode = context.getSourceCode()
2091
- } = context;
2092
- const {
2093
- lines
2094
- } = sourceCode;
2095
-
2096
- /** @type {Partial<StateObject>} */
2097
- const state = {};
2098
-
2099
- /** @type {CheckJsdoc} */
2100
- const checkJsdoc = (info, handler, node) => {
2101
- const jsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
2102
- if (!jsdocNode) {
2103
- return;
2104
- }
2105
- const [indent, jsdoc] = getIndentAndJSDoc(lines, /** @type {import('estree').Comment} */
2106
- jsdocNode);
2107
- if (
2108
- // Note, `handler` should already be bound in its first argument
2109
- // with these only to be called after the value of
2110
- // `comment`
2111
- handler && handler(jsdoc) === false) {
2112
- return;
2113
- }
2114
- iterate(info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, /** @type {StateObject} */
2115
- state);
2116
- };
2117
-
2118
- /** @type {import('eslint').Rule.RuleListener} */
2119
- let contextObject = {};
2120
- if (contexts && (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext)) {
2121
- contextObject = jsdocUtils.getContextObject(contexts, checkJsdoc, (0, _jsdoccomment.commentHandler)({
2122
- ...settings,
2123
- mode: settings.mode === 'permissive' ? 'typescript' : settings.mode
2124
- }));
2125
- } else {
2126
- for (const prop of ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction']) {
2127
- contextObject[prop] = checkJsdoc.bind(null, {
2128
- selector: prop
2129
- }, null);
2130
- }
2131
- }
2132
- if (typeof ruleConfig.exit === 'function') {
2133
- contextObject['Program:exit'] = () => {
2134
- const ste = /** @type {StateObject} */state;
2135
-
2136
- // @ts-expect-error `utils` not needed at this point
2137
- /** @type {Required<RuleConfig>} */
2138
- ruleConfig.exit({
2139
- context,
2140
- settings,
2141
- state: ste
2142
- });
2143
- };
2144
- }
2145
- return contextObject;
2146
- },
2147
- meta: ruleConfig.meta
2148
- };
2149
- }
2150
- //# sourceMappingURL=iterateJsdoc.cjs.map