@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,362 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireWildcard(require("../iterateJsdoc.cjs"));
8
- var _jsdoccomment = require("@es-joy/jsdoccomment");
9
- var _eslint = require("eslint");
10
- var _parseImportsExports = require("parse-imports-exports");
11
- var _semver = _interopRequireDefault(require("semver"));
12
- var _toValidIdentifier = _interopRequireDefault(require("../to-valid-identifier.cjs"));
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- 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); }
15
- var _default = exports.default = (0, _iterateJsdoc.default)(({
16
- context,
17
- indent,
18
- jsdoc,
19
- settings,
20
- sourceCode,
21
- utils
22
- }) => {
23
- const {
24
- mode
25
- } = settings;
26
- const {
27
- enableFixer = true,
28
- exemptTypedefs = true,
29
- outputType = 'namespaced-import'
30
- } = context.options[0] || {};
31
- const allComments = sourceCode.getAllComments();
32
- const comments = allComments.filter(comment => {
33
- return /^\*(?!\*)/v.test(comment.value);
34
- }).map(commentNode => {
35
- return (0, _jsdoccomment.commentParserToESTree)((0, _iterateJsdoc.parseComment)(commentNode, ''), mode === 'permissive' ? 'typescript' : mode);
36
- });
37
- const typedefs = comments.flatMap(doc => {
38
- return doc.tags.filter(({
39
- tag
40
- }) => {
41
- return utils.isNameOrNamepathDefiningTag(tag);
42
- });
43
- });
44
- const imports = comments.flatMap(doc => {
45
- return doc.tags.filter(({
46
- tag
47
- }) => {
48
- return tag === 'import';
49
- });
50
- }).map(tag => {
51
- // Causes problems with stringification otherwise
52
- tag.delimiter = '';
53
- return tag;
54
- });
55
-
56
- /**
57
- * Helper to insert an import statement at the top of the file.
58
- * @param {string} importText - The import statement text (without newline)
59
- * @returns {((fixer: import('eslint').Rule.RuleFixer) => import('eslint').Rule.Fix|void)} - Fixer function for ESLint
60
- */
61
- const createImportInserter = importText => {
62
- return fixer => {
63
- const programNode = sourceCode.ast;
64
- const commentNodes = sourceCode.getCommentsBefore(programNode);
65
-
66
- /* c8 ignore start -- ESLint < 10 */
67
- if (commentNodes[0]) {
68
- return fixer.insertTextBefore(
69
- // @ts-expect-error - Comment is compatible with Node in practice
70
- commentNodes[0], `${importText}\n${indent}`);
71
- }
72
-
73
- // For ESLint < 10, use the simple approach of inserting before programNode
74
- if (_semver.default.lt(_eslint.Linter.version, '10.0.0')) {
75
- return fixer.insertTextBefore(programNode, importText);
76
- }
77
-
78
- // For ESLint 10+, handle the changed Program node range
79
- const sourceText = sourceCode.getText();
80
- const hasCode = programNode.body && programNode.body.length > 0;
81
- const leadingMatch = hasCode ? sourceText.match(/^(\n[ \t]*)/v) : null;
82
- if (leadingMatch) {
83
- const leading = leadingMatch[1];
84
- return fixer.replaceTextRange([leading.length, leading.length], `${importText}\n${leading.slice(1)}`);
85
- }
86
- const startsWithNewline = sourceText[0] === '\n';
87
- return fixer.replaceTextRange(startsWithNewline ? [0, 1] : [0, 0], `${importText}\n`);
88
- /* c8 ignore end -- ESLint < 10 */
89
- };
90
- };
91
-
92
- /**
93
- * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} tag
94
- */
95
- const iterateInlineImports = tag => {
96
- const potentialType = tag.type;
97
- let parsedType;
98
- try {
99
- parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)(/** @type {string} */potentialType) : (0, _jsdoccomment.parse)(/** @type {string} */potentialType, mode);
100
- } catch {
101
- return;
102
- }
103
- (0, _jsdoccomment.traverse)(parsedType, (nde, parentNode) => {
104
- // @ts-expect-error Adding our own property for use below
105
- nde.parentNode = parentNode;
106
- });
107
- (0, _jsdoccomment.traverse)(parsedType, nde => {
108
- const {
109
- element,
110
- type
111
- } = /** @type {import('jsdoc-type-pratt-parser').ImportResult} */nde;
112
- if (type !== 'JsdocTypeImport') {
113
- return;
114
- }
115
- let currentNode = nde;
116
-
117
- /** @type {string[]} */
118
- const pathSegments = [];
119
-
120
- /** @type {import('jsdoc-type-pratt-parser').NamePathResult[]} */
121
- const nodes = [];
122
-
123
- /** @type {string[]} */
124
- const extraPathSegments = [];
125
-
126
- /** @type {(import('jsdoc-type-pratt-parser').QuoteStyle|undefined)[]} */
127
- const quotes = [];
128
- const propertyOrBrackets = /** @type {import('jsdoc-type-pratt-parser').NamePathResult['pathType'][]} */[];
129
-
130
- // @ts-expect-error Referencing our own property added above
131
- while (currentNode && currentNode.parentNode) {
132
- // @ts-expect-error Referencing our own property added above
133
- currentNode = currentNode.parentNode;
134
- /* c8 ignore next 3 -- Guard */
135
- if (currentNode.type !== 'JsdocTypeNamePath') {
136
- break;
137
- }
138
- pathSegments.unshift(currentNode.right.type === 'JsdocTypeIndexedAccessIndex' ? (0, _jsdoccomment.stringify)(currentNode.right.right) : currentNode.right.value);
139
- nodes.unshift(currentNode);
140
- propertyOrBrackets.unshift(currentNode.pathType);
141
- quotes.unshift(currentNode.right.type === 'JsdocTypeIndexedAccessIndex' ? undefined : currentNode.right.meta.quote);
142
- }
143
-
144
- /**
145
- * @param {string} name
146
- * @param {string[]} extrPathSegments
147
- */
148
- const getFixer = (name, extrPathSegments) => {
149
- const matchingName = (0, _toValidIdentifier.default)(name);
150
- return () => {
151
- /** @type {import('jsdoc-type-pratt-parser').NamePathResult|undefined} */
152
- let node = nodes.at(0);
153
- if (!node) {
154
- // Not really a NamePathResult, but will be converted later anyways
155
- node = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */
156
- /** @type {unknown} */
157
- nde;
158
- }
159
- const keys = /** @type {(keyof import('jsdoc-type-pratt-parser').NamePathResult)[]} */
160
- Object.keys(node);
161
- for (const key of keys) {
162
- delete node[key];
163
- }
164
- if (extrPathSegments.length) {
165
- let newNode = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */
166
- /** @type {unknown} */
167
- node;
168
- while (extrPathSegments.length && newNode) {
169
- newNode.type = 'JsdocTypeNamePath';
170
- newNode.right = {
171
- meta: {
172
- quote: quotes.shift()
173
- },
174
- type: 'JsdocTypeProperty',
175
- value: (/** @type {string} */extrPathSegments.shift())
176
- };
177
- newNode.pathType = /** @type {import('jsdoc-type-pratt-parser').NamePathResult['pathType']} */
178
- propertyOrBrackets.shift();
179
- // @ts-expect-error Temporary
180
- newNode.left = {};
181
- newNode = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */
182
- newNode.left;
183
- }
184
- const nameNode = /** @type {import('jsdoc-type-pratt-parser').NameResult} */
185
- /** @type {unknown} */
186
- newNode;
187
- nameNode.type = 'JsdocTypeName';
188
- nameNode.value = matchingName;
189
- } else {
190
- const newNode = /** @type {import('jsdoc-type-pratt-parser').NameResult} */
191
- /** @type {unknown} */
192
- node;
193
- newNode.type = 'JsdocTypeName';
194
- newNode.value = matchingName;
195
- }
196
- for (const src of tag.source) {
197
- if (src.tokens.type) {
198
- src.tokens.type = `{${(0, _jsdoccomment.stringify)(parsedType)}}`;
199
- break;
200
- }
201
- }
202
- };
203
- };
204
-
205
- /** @type {string[]} */
206
- let unusedPathSegments = [];
207
- const findMatchingTypedef = () => {
208
- // Don't want typedefs to find themselves
209
- if (!exemptTypedefs) {
210
- return undefined;
211
- }
212
- const pthSegments = [...pathSegments];
213
- return typedefs.find(typedef => {
214
- let typedefNode = typedef.parsedType;
215
- let namepathMatch;
216
- while (typedefNode && typedefNode.type === 'JsdocTypeNamePath') {
217
- const pathSegment = pthSegments.shift();
218
- if (!pathSegment) {
219
- namepathMatch = false;
220
- break;
221
- }
222
- if (typedefNode.right.type === 'JsdocTypeIndexedAccessIndex' && (0, _jsdoccomment.stringify)(typedefNode.right.right) !== pathSegment || typedefNode.right.type !== 'JsdocTypeIndexedAccessIndex' && typedefNode.right.value !== pathSegment) {
223
- if (namepathMatch === true) {
224
- // It stopped matching, so stop
225
- break;
226
- }
227
- extraPathSegments.push(pathSegment);
228
- namepathMatch = false;
229
- continue;
230
- }
231
- namepathMatch = true;
232
- unusedPathSegments = pthSegments;
233
- typedefNode = typedefNode.left;
234
- }
235
- return namepathMatch &&
236
- // `import('eslint')` matches
237
- typedefNode && typedefNode.type === 'JsdocTypeImport' && typedefNode.element.value === element.value;
238
- });
239
- };
240
-
241
- // Check @typedef's first as should be longest match, allowing
242
- // for shorter abbreviations
243
- const matchingTypedef = findMatchingTypedef();
244
- if (matchingTypedef) {
245
- utils.reportJSDoc('Inline `import()` found; using `@typedef`', tag, enableFixer ? getFixer(matchingTypedef.name, [...extraPathSegments, ...unusedPathSegments.slice(-1), ...unusedPathSegments.slice(0, -1)]) : null);
246
- return;
247
- }
248
- const findMatchingImport = () => {
249
- for (const imprt of imports) {
250
- const parsedImport = (0, _parseImportsExports.parseImportsExports)((0, _jsdoccomment.estreeToString)(imprt).replace(/^\s*@/v, '').trim());
251
- const namedImportsModuleSpecifier = Object.keys(parsedImport.namedImports || {})[0];
252
- const namedImports = Object.values(parsedImport.namedImports || {})[0]?.[0];
253
- const namedImportNames = (namedImports && namedImports.names && Object.keys(namedImports.names)) ?? [];
254
- const namespaceImports = Object.values(parsedImport.namespaceImports || {})[0]?.[0];
255
- const namespaceImportsDefault = namespaceImports && namespaceImports.default;
256
- const namespaceImportsNamespace = namespaceImports && namespaceImports.namespace;
257
- const namespaceImportsModuleSpecifier = Object.keys(parsedImport.namespaceImports || {})[0];
258
- const lastPathSegment = pathSegments.at(-1);
259
- if (namespaceImportsDefault && namespaceImportsModuleSpecifier === element.value || element.value === namedImportsModuleSpecifier && (lastPathSegment && namedImportNames.includes(lastPathSegment) || lastPathSegment === 'default') || namespaceImportsNamespace && namespaceImportsModuleSpecifier === element.value) {
260
- return {
261
- namedImportNames,
262
- namedImports,
263
- namedImportsModuleSpecifier,
264
- namespaceImports,
265
- namespaceImportsDefault,
266
- namespaceImportsModuleSpecifier,
267
- namespaceImportsNamespace
268
- };
269
- }
270
- }
271
- return undefined;
272
- };
273
- const matchingImport = findMatchingImport();
274
- if (matchingImport) {
275
- const {
276
- namedImportNames,
277
- namedImports,
278
- namedImportsModuleSpecifier,
279
- namespaceImportsNamespace
280
- } = matchingImport;
281
- if (!namedImportNames.length && namedImportsModuleSpecifier && namedImports.default) {
282
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? getFixer(namedImports.default, []) : null);
283
- return;
284
- }
285
- const lastPthSegment = pathSegments.at(-1);
286
- if (lastPthSegment && namedImportNames.includes(lastPthSegment)) {
287
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? getFixer(lastPthSegment, pathSegments.slice(0, -1)) : null);
288
- return;
289
- }
290
- if (namespaceImportsNamespace) {
291
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? getFixer(namespaceImportsNamespace, [...pathSegments]) : null);
292
- return;
293
- }
294
- }
295
- if (!pathSegments.length) {
296
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? fixer => {
297
- getFixer(element.value, [])();
298
- return createImportInserter(`/** @import * as ${(0, _toValidIdentifier.default)(element.value)} from '${element.value}'; */`)(fixer);
299
- } : null);
300
- return;
301
- }
302
- const lstPathSegment = pathSegments.at(-1);
303
- if (lstPathSegment && lstPathSegment === 'default') {
304
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? fixer => {
305
- getFixer(element.value, [])();
306
- return createImportInserter(`/** @import ${element.value} from '${element.value}'; */`)(fixer);
307
- } : null);
308
- return;
309
- }
310
- utils.reportJSDoc('Inline `import()` found; prefer `@import`', tag, enableFixer ? fixer => {
311
- if (outputType === 'namespaced-import') {
312
- getFixer(element.value, [...pathSegments])();
313
- } else {
314
- getFixer(/** @type {string} */pathSegments.at(-1), pathSegments.slice(0, -1))();
315
- }
316
- const importText = outputType === 'namespaced-import' ? `/** @import * as ${(0, _toValidIdentifier.default)(element.value)} from '${element.value}'; */` : `/** @import { ${(0, _toValidIdentifier.default)(/* c8 ignore next -- TS */
317
- pathSegments.at(-1) ?? '')} } from '${element.value}'; */`;
318
- return createImportInserter(importText)(fixer);
319
- } : null);
320
- });
321
- };
322
- for (const tag of jsdoc.tags) {
323
- const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag);
324
- const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);
325
- if (hasTypePosition && (!exemptTypedefs || !utils.isNameOrNamepathDefiningTag(tag.tag))) {
326
- iterateInlineImports(tag);
327
- }
328
- }
329
- }, {
330
- iterateAllJsdocs: true,
331
- meta: {
332
- docs: {
333
- description: 'Prefer `@import` tags to inline `import()` statements.',
334
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/prefer-import-tag.md#repos-sticky-header'
335
- },
336
- fixable: 'code',
337
- schema: [{
338
- additionalProperties: false,
339
- properties: {
340
- enableFixer: {
341
- description: 'Whether or not to enable the fixer to add `@import` tags.',
342
- type: 'boolean'
343
- },
344
- exemptTypedefs: {
345
- description: 'Whether to allow `import()` statements within `@typedef`',
346
- type: 'boolean'
347
- },
348
- // We might add `typedef` and `typedef-local-only`, but also raises
349
- // question of how deep the generated typedef should be
350
- outputType: {
351
- description: 'What kind of `@import` to generate when no matching `@typedef` or `@import` is found',
352
- enum: ['named-import', 'namespaced-import'],
353
- type: 'string'
354
- }
355
- },
356
- type: 'object'
357
- }],
358
- type: 'suggestion'
359
- }
360
- });
361
- module.exports = exports.default;
362
- //# sourceMappingURL=preferImportTag.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preferImportTag.cjs","names":["iterateJsdoc","commentParserToESTree","parseComment","semver","Linter","tryParseType","parseType","traverse","stringify","toValidIdentifier","parseImportsExports","estreeToString"],"sources":["../../src/rules/preferImportTag.js"],"sourcesContent":["import iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc.js';\nimport {\n commentParserToESTree,\n estreeToString,\n // getJSDocComment,\n parse as parseType,\n stringify,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport {\n Linter,\n} from 'eslint';\nimport {\n parseImportsExports,\n} from 'parse-imports-exports';\nimport semver from 'semver';\nimport toValidIdentifier from 'to-valid-identifier';\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n mode,\n } = settings;\n\n const {\n enableFixer = true,\n exemptTypedefs = true,\n outputType = 'namespaced-import',\n } = context.options[0] || {};\n\n const allComments = sourceCode.getAllComments();\n const comments = allComments\n .filter((comment) => {\n return (/^\\*(?!\\*)/v).test(comment.value);\n })\n .map((commentNode) => {\n return commentParserToESTree(\n parseComment(commentNode, ''), mode === 'permissive' ? 'typescript' : mode,\n );\n });\n\n const typedefs = comments\n .flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag);\n });\n });\n\n const imports = comments\n .flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return tag === 'import';\n });\n }).map((tag) => {\n // Causes problems with stringification otherwise\n tag.delimiter = '';\n return tag;\n });\n\n /**\n * Helper to insert an import statement at the top of the file.\n * @param {string} importText - The import statement text (without newline)\n * @returns {((fixer: import('eslint').Rule.RuleFixer) => import('eslint').Rule.Fix|void)} - Fixer function for ESLint\n */\n const createImportInserter = (importText) => {\n return (fixer) => {\n const programNode = sourceCode.ast;\n const commentNodes = sourceCode.getCommentsBefore(programNode);\n\n /* c8 ignore start -- ESLint < 10 */\n if (commentNodes[0]) {\n return fixer.insertTextBefore(\n // @ts-expect-error - Comment is compatible with Node in practice\n commentNodes[0],\n `${importText}\\n${indent}`,\n );\n }\n\n // For ESLint < 10, use the simple approach of inserting before programNode\n if (semver.lt(Linter.version, '10.0.0')) {\n return fixer.insertTextBefore(\n programNode,\n importText,\n );\n }\n\n // For ESLint 10+, handle the changed Program node range\n const sourceText = sourceCode.getText();\n const hasCode = programNode.body && programNode.body.length > 0;\n const leadingMatch = hasCode ? sourceText.match(/^(\\n[ \\t]*)/v) : null;\n if (leadingMatch) {\n const leading = leadingMatch[1];\n return fixer.replaceTextRange(\n [\n leading.length, leading.length,\n ],\n `${importText}\\n${leading.slice(1)}`,\n );\n }\n\n const startsWithNewline = sourceText[0] === '\\n';\n return fixer.replaceTextRange(\n startsWithNewline ? [\n 0, 1,\n ] : [\n 0, 0,\n ],\n `${importText}\\n`,\n );\n /* c8 ignore end -- ESLint < 10 */\n };\n };\n\n /**\n * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} tag\n */\n const iterateInlineImports = (tag) => {\n const potentialType = tag.type;\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde, parentNode) => {\n // @ts-expect-error Adding our own property for use below\n nde.parentNode = parentNode;\n });\n\n traverse(parsedType, (nde) => {\n const {\n element,\n type,\n } = /** @type {import('jsdoc-type-pratt-parser').ImportResult} */ (nde);\n if (type !== 'JsdocTypeImport') {\n return;\n }\n\n let currentNode = nde;\n\n /** @type {string[]} */\n const pathSegments = [];\n\n /** @type {import('jsdoc-type-pratt-parser').NamePathResult[]} */\n const nodes = [];\n\n /** @type {string[]} */\n const extraPathSegments = [];\n\n /** @type {(import('jsdoc-type-pratt-parser').QuoteStyle|undefined)[]} */\n const quotes = [];\n\n const propertyOrBrackets = /** @type {import('jsdoc-type-pratt-parser').NamePathResult['pathType'][]} */ ([]);\n\n // @ts-expect-error Referencing our own property added above\n while (currentNode && currentNode.parentNode) {\n // @ts-expect-error Referencing our own property added above\n currentNode = currentNode.parentNode;\n /* c8 ignore next 3 -- Guard */\n if (currentNode.type !== 'JsdocTypeNamePath') {\n break;\n }\n\n pathSegments.unshift(\n currentNode.right.type === 'JsdocTypeIndexedAccessIndex' ?\n stringify(currentNode.right.right) :\n currentNode.right.value,\n );\n nodes.unshift(currentNode);\n propertyOrBrackets.unshift(currentNode.pathType);\n quotes.unshift(\n currentNode.right.type === 'JsdocTypeIndexedAccessIndex' ?\n undefined :\n currentNode.right.meta.quote,\n );\n }\n\n /**\n * @param {string} name\n * @param {string[]} extrPathSegments\n */\n const getFixer = (name, extrPathSegments) => {\n const matchingName = toValidIdentifier(name);\n return () => {\n /** @type {import('jsdoc-type-pratt-parser').NamePathResult|undefined} */\n let node = nodes.at(0);\n if (!node) {\n // Not really a NamePathResult, but will be converted later anyways\n node = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */ (\n /** @type {unknown} */\n (nde)\n );\n }\n\n const keys = /** @type {(keyof import('jsdoc-type-pratt-parser').NamePathResult)[]} */ (\n Object.keys(node)\n );\n\n for (const key of keys) {\n delete node[key];\n }\n\n if (extrPathSegments.length) {\n let newNode = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */ (\n /** @type {unknown} */\n (node)\n );\n while (extrPathSegments.length && newNode) {\n newNode.type = 'JsdocTypeNamePath';\n newNode.right = {\n meta: {\n quote: quotes.shift(),\n },\n type: 'JsdocTypeProperty',\n value: /** @type {string} */ (extrPathSegments.shift()),\n };\n\n newNode.pathType = /** @type {import('jsdoc-type-pratt-parser').NamePathResult['pathType']} */ (\n propertyOrBrackets.shift()\n );\n // @ts-expect-error Temporary\n newNode.left = {};\n newNode = /** @type {import('jsdoc-type-pratt-parser').NamePathResult} */ (\n newNode.left\n );\n }\n\n const nameNode = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n /** @type {unknown} */\n (newNode)\n );\n nameNode.type = 'JsdocTypeName';\n nameNode.value = matchingName;\n } else {\n const newNode = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (\n /** @type {unknown} */\n (node)\n );\n newNode.type = 'JsdocTypeName';\n newNode.value = matchingName;\n }\n\n for (const src of tag.source) {\n if (src.tokens.type) {\n src.tokens.type = `{${stringify(parsedType)}}`;\n break;\n }\n }\n };\n };\n\n /** @type {string[]} */\n let unusedPathSegments = [];\n\n const findMatchingTypedef = () => {\n // Don't want typedefs to find themselves\n if (!exemptTypedefs) {\n return undefined;\n }\n\n const pthSegments = [\n ...pathSegments,\n ];\n return typedefs.find((typedef) => {\n let typedefNode = typedef.parsedType;\n let namepathMatch;\n while (typedefNode && typedefNode.type === 'JsdocTypeNamePath') {\n const pathSegment = pthSegments.shift();\n if (!pathSegment) {\n namepathMatch = false;\n break;\n }\n\n if (\n (typedefNode.right.type === 'JsdocTypeIndexedAccessIndex' &&\n stringify(typedefNode.right.right) !== pathSegment) ||\n (typedefNode.right.type !== 'JsdocTypeIndexedAccessIndex' &&\n typedefNode.right.value !== pathSegment)\n ) {\n if (namepathMatch === true) {\n // It stopped matching, so stop\n break;\n }\n\n extraPathSegments.push(pathSegment);\n namepathMatch = false;\n continue;\n }\n\n namepathMatch = true;\n\n unusedPathSegments = pthSegments;\n\n typedefNode = typedefNode.left;\n }\n\n return namepathMatch &&\n // `import('eslint')` matches\n typedefNode &&\n typedefNode.type === 'JsdocTypeImport' &&\n typedefNode.element.value === element.value;\n });\n };\n\n // Check @typedef's first as should be longest match, allowing\n // for shorter abbreviations\n const matchingTypedef = findMatchingTypedef();\n if (matchingTypedef) {\n utils.reportJSDoc(\n 'Inline `import()` found; using `@typedef`',\n tag,\n enableFixer ? getFixer(matchingTypedef.name, [\n ...extraPathSegments,\n ...unusedPathSegments.slice(-1),\n ...unusedPathSegments.slice(0, -1),\n ]) : null,\n );\n return;\n }\n\n const findMatchingImport = () => {\n for (const imprt of imports) {\n const parsedImport = parseImportsExports(\n estreeToString(imprt).replace(/^\\s*@/v, '').trim(),\n );\n\n const namedImportsModuleSpecifier = Object.keys(parsedImport.namedImports || {})[0];\n\n const namedImports = Object.values(parsedImport.namedImports || {})[0]?.[0];\n const namedImportNames = (namedImports && namedImports.names && Object.keys(namedImports.names)) ?? [];\n\n const namespaceImports = Object.values(parsedImport.namespaceImports || {})[0]?.[0];\n\n const namespaceImportsDefault = namespaceImports && namespaceImports.default;\n const namespaceImportsNamespace = namespaceImports && namespaceImports.namespace;\n const namespaceImportsModuleSpecifier = Object.keys(parsedImport.namespaceImports || {})[0];\n\n const lastPathSegment = pathSegments.at(-1);\n\n if (\n (namespaceImportsDefault &&\n namespaceImportsModuleSpecifier === element.value) ||\n (element.value === namedImportsModuleSpecifier && (\n (lastPathSegment && namedImportNames.includes(lastPathSegment)) ||\n lastPathSegment === 'default'\n )) ||\n (namespaceImportsNamespace &&\n namespaceImportsModuleSpecifier === element.value)\n ) {\n return {\n namedImportNames,\n namedImports,\n namedImportsModuleSpecifier,\n namespaceImports,\n namespaceImportsDefault,\n namespaceImportsModuleSpecifier,\n namespaceImportsNamespace,\n };\n }\n }\n\n return undefined;\n };\n\n const matchingImport = findMatchingImport();\n if (matchingImport) {\n const {\n namedImportNames,\n namedImports,\n namedImportsModuleSpecifier,\n namespaceImportsNamespace,\n } = matchingImport;\n if (!namedImportNames.length && namedImportsModuleSpecifier && namedImports.default) {\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? getFixer(namedImports.default, []) : null,\n );\n return;\n }\n\n const lastPthSegment = pathSegments.at(-1);\n if (lastPthSegment && namedImportNames.includes(lastPthSegment)) {\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? getFixer(lastPthSegment, pathSegments.slice(0, -1)) : null,\n );\n return;\n }\n\n if (namespaceImportsNamespace) {\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? getFixer(namespaceImportsNamespace, [\n ...pathSegments,\n ]) : null,\n );\n return;\n }\n }\n\n if (!pathSegments.length) {\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? (fixer) => {\n getFixer(element.value, [])();\n return createImportInserter(\n `/** @import * as ${toValidIdentifier(element.value)} from '${element.value}'; */`,\n )(fixer);\n } : null,\n );\n return;\n }\n\n const lstPathSegment = pathSegments.at(-1);\n if (lstPathSegment && lstPathSegment === 'default') {\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? (fixer) => {\n getFixer(element.value, [])();\n return createImportInserter(\n `/** @import ${element.value} from '${element.value}'; */`,\n )(fixer);\n } : null,\n );\n return;\n }\n\n utils.reportJSDoc(\n 'Inline `import()` found; prefer `@import`',\n tag,\n enableFixer ? (fixer) => {\n if (outputType === 'namespaced-import') {\n getFixer(element.value, [\n ...pathSegments,\n ])();\n } else {\n getFixer(\n /** @type {string} */ (pathSegments.at(-1)),\n pathSegments.slice(0, -1),\n )();\n }\n\n const importText = outputType === 'namespaced-import' ?\n `/** @import * as ${toValidIdentifier(element.value)} from '${element.value}'; */` :\n `/** @import { ${toValidIdentifier(\n /* c8 ignore next -- TS */\n pathSegments.at(-1) ?? '',\n )} } from '${element.value}'; */`;\n\n return createImportInserter(importText)(fixer);\n } : null,\n );\n });\n };\n\n for (const tag of jsdoc.tags) {\n const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag);\n const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);\n if (hasTypePosition && (!exemptTypedefs || !utils.isNameOrNamepathDefiningTag(tag.tag))) {\n iterateInlineImports(tag);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Prefer `@import` tags to inline `import()` statements.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/prefer-import-tag.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n enableFixer: {\n description: 'Whether or not to enable the fixer to add `@import` tags.',\n type: 'boolean',\n },\n exemptTypedefs: {\n description: 'Whether to allow `import()` statements within `@typedef`',\n type: 'boolean',\n },\n\n // We might add `typedef` and `typedef-local-only`, but also raises\n // question of how deep the generated typedef should be\n outputType: {\n description: 'What kind of `@import` to generate when no matching `@typedef` or `@import` is found',\n enum: [\n 'named-import',\n 'namespaced-import',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AAGA;AASA;AAGA;AAGA;AACA;AAAoD;AAAA;AAAA,iCAErC,IAAAA,qBAAY,EAAC,CAAC;EAC3B,OAAO;EACP,MAAM;EACN,KAAK;EACL,QAAQ;EACR,UAAU;EACV;AACF,CAAC,KAAK;EACJ,MAAM;IACJ;EACF,CAAC,GAAG,QAAQ;EAEZ,MAAM;IACJ,WAAW,GAAG,IAAI;IAClB,cAAc,GAAG,IAAI;IACrB,UAAU,GAAG;EACf,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM,WAAW,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;EAC/C,MAAM,QAAQ,GAAG,WAAW,CACzB,MAAM,CAAE,OAAO,IAAK;IACnB,OAAQ,YAAY,CAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;EAC3C,CAAC,CAAC,CACD,GAAG,CAAE,WAAW,IAAK;IACpB,OAAO,IAAAC,cAAA,qBAAqB,EAC1B,IAAAC,cAAA,YAAY,EAAC,WAAW,EAAE,EAAE,CAAC,EAAE,IAAI,KAAK,YAAY,GAAG,YAAY,GAAG,IACxE,CAAC;EACH,CAAC,CAAC;EAEJ,MAAM,QAAQ,GAAG,QAAQ,CACtB,OAAO,CAAE,GAAG,IAAK;IAChB,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;MACtB;IACF,CAAC,KAAK;MACJ,OAAO,KAAK,CAAC,2BAA2B,CAAC,GAAG,CAAC;IAC/C,CAAC,CAAC;EACJ,CAAC,CAAC;EAEJ,MAAM,OAAO,GAAG,QAAQ,CACrB,OAAO,CAAE,GAAG,IAAK;IAChB,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;MACtB;IACF,CAAC,KAAK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c,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;MACvF,oBAAoB,CAAC,GAAG,CAAC;IAC3B;EACF;AACF,CAAC,EAAE;EACD,gBAAgB,EAAE,IAAI;EACtB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,wDAAwD;MACrE,GAAG,EAAE;IACP,CAAC;IACD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,WAAW,EAAE;UACX,WAAW,EAAE,2DAA2D;UACxE,IAAI,EAAE;QACR,CAAC;QACD,cAAc,EAAE;UACd,WAAW,EAAE,0DAA0D;UACvE,IAAI,EAAE;QACR,CAAC;QAED;QACA;QACA,UAAU,EAAE;UACV,WAAW,EAAE,sFAAsF;UACnG,IAAI,EAAE,CACJ,cAAc,EACd,mBAAmB,CACpB;UACD,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA","ignoreList":[]}
@@ -1,190 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- var _default = exports.default = (0, _iterateJsdoc.default)(({
10
- context,
11
- indent,
12
- jsdoc,
13
- utils
14
- }) => {
15
- const [defaultRequireValue = 'always', {
16
- tags: tagMap = {}
17
- } = {}] = context.options;
18
- const {
19
- source
20
- } = jsdoc;
21
- const always = defaultRequireValue === 'always';
22
- const never = defaultRequireValue === 'never';
23
-
24
- /** @type {string} */
25
- let currentTag;
26
- source.some(({
27
- number,
28
- tokens
29
- }) => {
30
- const {
31
- delimiter,
32
- description,
33
- end,
34
- tag
35
- } = tokens;
36
-
37
- /**
38
- * @returns {void}
39
- */
40
- const neverFix = () => {
41
- tokens.delimiter = '';
42
- tokens.postDelimiter = '';
43
- };
44
-
45
- /**
46
- * @param {string} checkValue
47
- * @returns {boolean}
48
- */
49
- const checkNever = checkValue => {
50
- if (delimiter && delimiter !== '/**' && (never && !tagMap.always?.includes(checkValue) || tagMap.never?.includes(checkValue))) {
51
- utils.reportJSDoc('Expected JSDoc line to have no prefix.', {
52
- column: 0,
53
- line: number
54
- }, neverFix);
55
- return true;
56
- }
57
- return false;
58
- };
59
-
60
- /**
61
- * @returns {void}
62
- */
63
- const alwaysFix = () => {
64
- if (!tokens.start) {
65
- tokens.start = indent + ' ';
66
- }
67
- tokens.delimiter = '*';
68
- tokens.postDelimiter = tag || description ? ' ' : '';
69
- };
70
-
71
- /**
72
- * @param {string} checkValue
73
- * @returns {boolean}
74
- */
75
- const checkAlways = checkValue => {
76
- if (!delimiter && (always && !tagMap.never?.includes(checkValue) || tagMap.always?.includes(checkValue))) {
77
- utils.reportJSDoc('Expected JSDoc line to have the prefix.', {
78
- column: 0,
79
- line: number
80
- }, alwaysFix);
81
- return true;
82
- }
83
- return false;
84
- };
85
- if (tag) {
86
- // Remove at sign
87
- currentTag = tag.slice(1);
88
- }
89
- if (
90
- // If this is the end but has a tag, the delimiter will also be
91
- // populated and will be safely ignored later
92
- end && !tag) {
93
- return false;
94
- }
95
- if (!currentTag) {
96
- if (tagMap.any?.includes('*description')) {
97
- return false;
98
- }
99
- if (checkNever('*description')) {
100
- return true;
101
- }
102
- if (checkAlways('*description')) {
103
- return true;
104
- }
105
- return false;
106
- }
107
- if (tagMap.any?.includes(currentTag)) {
108
- return false;
109
- }
110
- if (checkNever(currentTag)) {
111
- return true;
112
- }
113
- if (checkAlways(currentTag)) {
114
- return true;
115
- }
116
- return false;
117
- });
118
- }, {
119
- iterateAllJsdocs: true,
120
- meta: {
121
- docs: {
122
- description: 'Requires that each JSDoc line starts with an `*`.',
123
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header'
124
- },
125
- fixable: 'code',
126
- schema: [{
127
- description: `If it is \`"always"\` then a problem is raised when there is no asterisk
128
- prefix on a given JSDoc line. If it is \`"never"\` then a problem is raised
129
- when there is an asterisk present.
130
-
131
- The default value is \`"always"\`. You may also set the default to \`"any"\`
132
- and use the \`tags\` option to apply to specific tags only.`,
133
- enum: ['always', 'never', 'any'],
134
- type: 'string'
135
- }, {
136
- additionalProperties: false,
137
- properties: {
138
- tags: {
139
- additionalProperties: false,
140
- description: `If you want different values to apply to specific tags, you may use
141
- the \`tags\` option object. The keys are \`always\`, \`never\`, or \`any\` and
142
- the values are arrays of tag names or the special value \`*description\`
143
- which applies to the main JSDoc block description.
144
-
145
- \`\`\`js
146
- {
147
- 'jsdoc/require-asterisk-prefix': ['error', 'always', {
148
- tags: {
149
- always: ['*description'],
150
- any: ['example', 'license'],
151
- never: ['copyright']
152
- }
153
- }]
154
- }
155
- \`\`\``,
156
- properties: {
157
- always: {
158
- description: `If it is \`"always"\` then a problem is raised when there is no asterisk
159
- prefix on a given JSDoc line.`,
160
- items: {
161
- type: 'string'
162
- },
163
- type: 'array'
164
- },
165
- any: {
166
- description: 'No problem is raised regardless of asterisk presence or non-presence.',
167
- items: {
168
- type: 'string'
169
- },
170
- type: 'array'
171
- },
172
- never: {
173
- description: `If it is \`"never"\` then a problem is raised
174
- when there is an asterisk present.`,
175
- items: {
176
- type: 'string'
177
- },
178
- type: 'array'
179
- }
180
- },
181
- type: 'object'
182
- }
183
- },
184
- type: 'object'
185
- }],
186
- type: 'layout'
187
- }
188
- });
189
- module.exports = exports.default;
190
- //# sourceMappingURL=requireAsteriskPrefix.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requireAsteriskPrefix.cjs","names":["iterateJsdoc"],"sources":["../../src/rules/requireAsteriskPrefix.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n utils,\n}) => {\n const [\n defaultRequireValue = 'always',\n {\n tags: tagMap = {},\n } = {},\n ] = context.options;\n\n const {\n source,\n } = jsdoc;\n\n const always = defaultRequireValue === 'always';\n const never = defaultRequireValue === 'never';\n\n /** @type {string} */\n let currentTag;\n source.some(({\n number,\n tokens,\n }) => {\n const {\n delimiter,\n description,\n end,\n tag,\n } = tokens;\n\n /**\n * @returns {void}\n */\n const neverFix = () => {\n tokens.delimiter = '';\n tokens.postDelimiter = '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkNever = (checkValue) => {\n if (delimiter && delimiter !== '/**' && (\n never && !tagMap.always?.includes(checkValue) ||\n tagMap.never?.includes(checkValue)\n )) {\n utils.reportJSDoc('Expected JSDoc line to have no prefix.', {\n column: 0,\n line: number,\n }, neverFix);\n\n return true;\n }\n\n return false;\n };\n\n /**\n * @returns {void}\n */\n const alwaysFix = () => {\n if (!tokens.start) {\n tokens.start = indent + ' ';\n }\n\n tokens.delimiter = '*';\n tokens.postDelimiter = tag || description ? ' ' : '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkAlways = (checkValue) => {\n if (\n !delimiter && (\n always && !tagMap.never?.includes(checkValue) ||\n tagMap.always?.includes(checkValue)\n )\n ) {\n utils.reportJSDoc('Expected JSDoc line to have the prefix.', {\n column: 0,\n line: number,\n }, alwaysFix);\n\n return true;\n }\n\n return false;\n };\n\n if (tag) {\n // Remove at sign\n currentTag = tag.slice(1);\n }\n\n if (\n // If this is the end but has a tag, the delimiter will also be\n // populated and will be safely ignored later\n end && !tag\n ) {\n return false;\n }\n\n if (!currentTag) {\n if (tagMap.any?.includes('*description')) {\n return false;\n }\n\n if (checkNever('*description')) {\n return true;\n }\n\n if (checkAlways('*description')) {\n return true;\n }\n\n return false;\n }\n\n if (tagMap.any?.includes(currentTag)) {\n return false;\n }\n\n if (checkNever(currentTag)) {\n return true;\n }\n\n if (checkAlways(currentTag)) {\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'Requires that each JSDoc line starts with an `*`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `If it is \\`\"always\"\\` then a problem is raised when there is no asterisk\nprefix on a given JSDoc line. If it is \\`\"never\"\\` then a problem is raised\nwhen there is an asterisk present.\n\nThe default value is \\`\"always\"\\`. You may also set the default to \\`\"any\"\\`\nand use the \\`tags\\` option to apply to specific tags only.`,\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n tags: {\n additionalProperties: false,\n description: `If you want different values to apply to specific tags, you may use\nthe \\`tags\\` option object. The keys are \\`always\\`, \\`never\\`, or \\`any\\` and\nthe values are arrays of tag names or the special value \\`*description\\`\nwhich applies to the main JSDoc block description.\n\n\\`\\`\\`js\n{\n 'jsdoc/require-asterisk-prefix': ['error', 'always', {\n tags: {\n always: ['*description'],\n any: ['example', 'license'],\n never: ['copyright']\n }\n }]\n}\n\\`\\`\\``,\n properties: {\n always: {\n description: `If it is \\`\"always\"\\` then a problem is raised when there is no asterisk\nprefix on a given JSDoc line.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n any: {\n description: 'No problem is raised regardless of asterisk presence or non-presence.',\n items: {\n type: 'string',\n },\n type: 'array',\n },\n never: {\n description: `If it is \\`\"never\"\\` then a problem is raised\nwhen there is an asterisk present.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA;AAA8C;AAAA,iCAE/B,IAAAA,qBAAY,EAAC,CAAC;EAC3B,OAAO;EACP,MAAM;EACN,KAAK;EACL;AACF,CAAC,KAAK;EACJ,MAAM,CACJ,mBAAmB,GAAG,QAAQ,EAC9B;IACE,IA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