eslint-plugin-jsdoc 56.0.0 → 56.0.2

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 (79) hide show
  1. package/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -1
  2. package/dist/cjs/iterateJsdoc.d.cts +6 -2
  3. package/dist/getJsdocProcessorPlugin.cts +3 -1
  4. package/dist/iterateJsdoc.cts +9 -4
  5. package/package.json +4 -4
  6. package/src/getJsdocProcessorPlugin.cts +3 -1
  7. package/src/iterateJsdoc.cts +9 -4
  8. package/dist/cjs/WarnSettings.js +0 -30
  9. package/dist/cjs/alignTransform.js +0 -285
  10. package/dist/cjs/defaultTagOrder.js +0 -152
  11. package/dist/cjs/exportParser.js +0 -754
  12. package/dist/cjs/getDefaultTagStructureForMode.js +0 -840
  13. package/dist/cjs/getJsdocProcessorPlugin.cjs +0 -4
  14. package/dist/cjs/getJsdocProcessorPlugin.js +0 -553
  15. package/dist/cjs/index-cjs.js +0 -492
  16. package/dist/cjs/index.cjs.cjs +0 -6
  17. package/dist/cjs/iterateJsdoc.cjs +0 -38
  18. package/dist/cjs/iterateJsdoc.js +0 -1981
  19. package/dist/cjs/jsdocUtils.js +0 -1470
  20. package/dist/cjs/rules/checkAccess.js +0 -35
  21. package/dist/cjs/rules/checkAlignment.js +0 -63
  22. package/dist/cjs/rules/checkExamples.js +0 -486
  23. package/dist/cjs/rules/checkIndentation.js +0 -66
  24. package/dist/cjs/rules/checkLineAlignment.js +0 -297
  25. package/dist/cjs/rules/checkParamNames.js +0 -320
  26. package/dist/cjs/rules/checkPropertyNames.js +0 -105
  27. package/dist/cjs/rules/checkSyntax.js +0 -27
  28. package/dist/cjs/rules/checkTagNames.js +0 -252
  29. package/dist/cjs/rules/checkTemplateNames.js +0 -189
  30. package/dist/cjs/rules/checkTypes.js +0 -421
  31. package/dist/cjs/rules/checkValues.js +0 -163
  32. package/dist/cjs/rules/convertToJsdocComments.js +0 -313
  33. package/dist/cjs/rules/emptyTags.js +0 -79
  34. package/dist/cjs/rules/implementsOnClasses.js +0 -63
  35. package/dist/cjs/rules/importsAsDependencies.js +0 -105
  36. package/dist/cjs/rules/informativeDocs.js +0 -153
  37. package/dist/cjs/rules/linesBeforeBlock.js +0 -106
  38. package/dist/cjs/rules/matchDescription.js +0 -240
  39. package/dist/cjs/rules/matchName.js +0 -122
  40. package/dist/cjs/rules/multilineBlocks.js +0 -339
  41. package/dist/cjs/rules/noBadBlocks.js +0 -88
  42. package/dist/cjs/rules/noBlankBlockDescriptions.js +0 -56
  43. package/dist/cjs/rules/noBlankBlocks.js +0 -41
  44. package/dist/cjs/rules/noDefaults.js +0 -84
  45. package/dist/cjs/rules/noMissingSyntax.js +0 -164
  46. package/dist/cjs/rules/noMultiAsterisks.js +0 -83
  47. package/dist/cjs/rules/noRestrictedSyntax.js +0 -75
  48. package/dist/cjs/rules/noTypes.js +0 -88
  49. package/dist/cjs/rules/noUndefinedTypes.js +0 -451
  50. package/dist/cjs/rules/requireAsteriskPrefix.js +0 -144
  51. package/dist/cjs/rules/requireDescription.js +0 -136
  52. package/dist/cjs/rules/requireDescriptionCompleteSentence.js +0 -258
  53. package/dist/cjs/rules/requireExample.js +0 -103
  54. package/dist/cjs/rules/requireFileOverview.js +0 -117
  55. package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +0 -144
  56. package/dist/cjs/rules/requireJsdoc.js +0 -629
  57. package/dist/cjs/rules/requireParam.js +0 -480
  58. package/dist/cjs/rules/requireParamDescription.js +0 -77
  59. package/dist/cjs/rules/requireParamName.js +0 -52
  60. package/dist/cjs/rules/requireParamType.js +0 -77
  61. package/dist/cjs/rules/requireProperty.js +0 -44
  62. package/dist/cjs/rules/requirePropertyDescription.js +0 -22
  63. package/dist/cjs/rules/requirePropertyName.js +0 -22
  64. package/dist/cjs/rules/requirePropertyType.js +0 -22
  65. package/dist/cjs/rules/requireReturns.js +0 -197
  66. package/dist/cjs/rules/requireReturnsCheck.js +0 -108
  67. package/dist/cjs/rules/requireReturnsDescription.js +0 -58
  68. package/dist/cjs/rules/requireReturnsType.js +0 -52
  69. package/dist/cjs/rules/requireTemplate.js +0 -173
  70. package/dist/cjs/rules/requireThrows.js +0 -101
  71. package/dist/cjs/rules/requireYields.js +0 -172
  72. package/dist/cjs/rules/requireYieldsCheck.js +0 -164
  73. package/dist/cjs/rules/sortTags.js +0 -392
  74. package/dist/cjs/rules/tagLines.js +0 -259
  75. package/dist/cjs/rules/textEscaping.js +0 -125
  76. package/dist/cjs/rules/typeFormatting.js +0 -328
  77. package/dist/cjs/rules/validTypes.js +0 -333
  78. package/dist/cjs/tagNames.js +0 -209
  79. package/dist/cjs/utils/hasReturnValue.js +0 -469
@@ -1,313 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const iterateJsdoc_js_1 = require("../iterateJsdoc.js");
4
- const jsdocUtils_js_1 = require("../jsdocUtils.js");
5
- const jsdoccomment_1 = require("@es-joy/jsdoccomment");
6
- /** @type {import('eslint').Rule.RuleModule} */
7
- exports.default = {
8
- create(context) {
9
- /**
10
- * @typedef {import('eslint').AST.Token | import('estree').Comment | {
11
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
12
- * range: [number, number],
13
- * value: string
14
- * }} Token
15
- */
16
- /**
17
- * @callback AddComment
18
- * @param {boolean|undefined} inlineCommentBlock
19
- * @param {Token} comment
20
- * @param {string} indent
21
- * @param {number} lines
22
- * @param {import('eslint').Rule.RuleFixer} fixer
23
- */
24
- /* c8 ignore next -- Fallback to deprecated method */
25
- const { sourceCode = context.getSourceCode(), } = context;
26
- const settings = (0, iterateJsdoc_js_1.getSettings)(context);
27
- if (!settings) {
28
- return {};
29
- }
30
- const { allowedPrefixes = [
31
- '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',
32
- ], contexts = settings.contexts || [], contextsAfter = /** @type {string[]} */ ([]), contextsBeforeAndAfter = [
33
- 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',
34
- ], enableFixer = true, enforceJsdocLineStyle = 'multi', lineOrBlockStyle = 'both', } = context.options[0] ?? {};
35
- let reportingNonJsdoc = false;
36
- /**
37
- * @param {string} messageId
38
- * @param {import('estree').Comment|Token} comment
39
- * @param {import('eslint').Rule.Node} node
40
- * @param {import('eslint').Rule.ReportFixer} fixer
41
- */
42
- const report = (messageId, comment, node, fixer) => {
43
- const loc = {
44
- end: {
45
- column: 0,
46
- /* c8 ignore next 2 -- Guard */
47
- // @ts-expect-error Ok
48
- line: (comment.loc?.start?.line ?? 1),
49
- },
50
- start: {
51
- column: 0,
52
- /* c8 ignore next 2 -- Guard */
53
- // @ts-expect-error Ok
54
- line: (comment.loc?.start?.line ?? 1),
55
- },
56
- };
57
- context.report({
58
- fix: enableFixer ? fixer : null,
59
- loc,
60
- messageId,
61
- node,
62
- });
63
- };
64
- /**
65
- * @param {import('eslint').Rule.Node} node
66
- * @param {import('eslint').AST.Token | import('estree').Comment | {
67
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
68
- * range: [number, number],
69
- * value: string
70
- * }} comment
71
- * @param {AddComment} addComment
72
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
73
- */
74
- const getFixer = (node, comment, addComment, ctxts) => {
75
- return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
76
- // Default to one line break if the `minLines`/`maxLines` settings allow
77
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
78
- let baseNode =
79
- /**
80
- * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}
81
- */ ((0, jsdoccomment_1.getReducedASTNode)(node, sourceCode));
82
- const decorator = (0, jsdoccomment_1.getDecorator)(
83
- /** @type {import('eslint').Rule.Node} */
84
- (baseNode));
85
- if (decorator) {
86
- baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (decorator);
87
- }
88
- const indent = (0, jsdocUtils_js_1.getIndent)({
89
- text: sourceCode.getText(
90
- /** @type {import('eslint').Rule.Node} */ (baseNode),
91
- /** @type {import('eslint').AST.SourceLocation} */
92
- (
93
- /** @type {import('eslint').Rule.Node} */ (baseNode).loc).start.column),
94
- });
95
- const { inlineCommentBlock, } =
96
- /**
97
- * @type {{
98
- * context: string,
99
- * inlineCommentBlock: boolean,
100
- * minLineCount: import('../iterateJsdoc.js').Integer
101
- * }[]}
102
- */ (ctxts).find((contxt) => {
103
- if (typeof contxt === 'string') {
104
- return false;
105
- }
106
- const { context: ctxt, } = contxt;
107
- return ctxt === node.type;
108
- }) || {};
109
- return addComment(inlineCommentBlock, comment, indent, lines, fixer);
110
- };
111
- };
112
- /**
113
- * @param {import('eslint').AST.Token | import('estree').Comment | {
114
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
115
- * range: [number, number],
116
- * value: string
117
- * }} comment
118
- * @param {import('eslint').Rule.Node} node
119
- * @param {AddComment} addComment
120
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
121
- */
122
- const reportings = (comment, node, addComment, ctxts) => {
123
- const fixer = getFixer(node, comment, addComment, ctxts);
124
- if (comment.type === 'Block') {
125
- if (lineOrBlockStyle === 'line') {
126
- return;
127
- }
128
- report('blockCommentsJsdocStyle', comment, node, fixer);
129
- return;
130
- }
131
- if (comment.type === 'Line') {
132
- if (lineOrBlockStyle === 'block') {
133
- return;
134
- }
135
- report('lineCommentsJsdocStyle', comment, node, fixer);
136
- }
137
- };
138
- /**
139
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
140
- */
141
- const checkNonJsdoc = (_info, _handler, node) => {
142
- const comment = (0, jsdoccomment_1.getNonJsdocComment)(sourceCode, node, settings);
143
- if (!comment ||
144
- /** @type {string[]} */
145
- (allowedPrefixes).some((prefix) => {
146
- return comment.value.trimStart().startsWith(prefix);
147
- })) {
148
- return;
149
- }
150
- reportingNonJsdoc = true;
151
- /** @type {AddComment} */
152
- // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts
153
- const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
154
- const insertion = (inlineCommentBlock || enforceJsdocLineStyle === 'single' ?
155
- `/** ${commentToAdd.value.trim()} ` :
156
- `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`) +
157
- `*/${'\n'.repeat((lines || 1) - 1)}`;
158
- return fixer.replaceText(
159
- /** @type {import('eslint').AST.Token} */
160
- (commentToAdd), insertion);
161
- };
162
- reportings(comment, node, addComment, contexts);
163
- };
164
- /**
165
- * @param {import('eslint').Rule.Node} node
166
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
167
- */
168
- const checkNonJsdocAfter = (node, ctxts) => {
169
- const comment = (0, jsdoccomment_1.getFollowingComment)(sourceCode, node);
170
- if (!comment ||
171
- comment.value.startsWith('*') ||
172
- /** @type {string[]} */
173
- (allowedPrefixes).some((prefix) => {
174
- return comment.value.trimStart().startsWith(prefix);
175
- })) {
176
- return;
177
- }
178
- /** @type {AddComment} */
179
- const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
180
- const insertion = (inlineCommentBlock || enforceJsdocLineStyle === 'single' ?
181
- `/** ${commentToAdd.value.trim()} ` :
182
- `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`) +
183
- `*/${'\n'.repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : ' '}`;
184
- return [
185
- fixer.remove(
186
- /** @type {import('eslint').AST.Token} */
187
- (commentToAdd)), fixer.insertTextBefore(node.type === 'VariableDeclarator' ? node.parent : node, insertion),
188
- ];
189
- };
190
- reportings(comment, node, addComment, ctxts);
191
- };
192
- // Todo: add contexts to check after (and handle if want both before and after)
193
- return {
194
- ...(0, jsdocUtils_js_1.getContextObject)((0, jsdocUtils_js_1.enforcedContexts)(context, true, settings), checkNonJsdoc),
195
- ...(0, jsdocUtils_js_1.getContextObject)(contextsAfter, (_info, _handler, node) => {
196
- checkNonJsdocAfter(node, contextsAfter);
197
- }),
198
- ...(0, jsdocUtils_js_1.getContextObject)(contextsBeforeAndAfter, (_info, _handler, node) => {
199
- checkNonJsdoc({}, null, node);
200
- if (!reportingNonJsdoc) {
201
- checkNonJsdocAfter(node, contextsBeforeAndAfter);
202
- }
203
- }),
204
- };
205
- },
206
- meta: {
207
- docs: {
208
- description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',
209
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',
210
- },
211
- fixable: 'code',
212
- messages: {
213
- blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',
214
- lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',
215
- },
216
- schema: [
217
- {
218
- additionalProperties: false,
219
- properties: {
220
- allowedPrefixes: {
221
- items: {
222
- type: 'string',
223
- },
224
- type: 'array',
225
- },
226
- contexts: {
227
- items: {
228
- anyOf: [
229
- {
230
- type: 'string',
231
- },
232
- {
233
- additionalProperties: false,
234
- properties: {
235
- context: {
236
- type: 'string',
237
- },
238
- inlineCommentBlock: {
239
- type: 'boolean',
240
- },
241
- },
242
- type: 'object',
243
- },
244
- ],
245
- },
246
- type: 'array',
247
- },
248
- contextsAfter: {
249
- items: {
250
- anyOf: [
251
- {
252
- type: 'string',
253
- },
254
- {
255
- additionalProperties: false,
256
- properties: {
257
- context: {
258
- type: 'string',
259
- },
260
- inlineCommentBlock: {
261
- type: 'boolean',
262
- },
263
- },
264
- type: 'object',
265
- },
266
- ],
267
- },
268
- type: 'array',
269
- },
270
- contextsBeforeAndAfter: {
271
- items: {
272
- anyOf: [
273
- {
274
- type: 'string',
275
- },
276
- {
277
- additionalProperties: false,
278
- properties: {
279
- context: {
280
- type: 'string',
281
- },
282
- inlineCommentBlock: {
283
- type: 'boolean',
284
- },
285
- },
286
- type: 'object',
287
- },
288
- ],
289
- },
290
- type: 'array',
291
- },
292
- enableFixer: {
293
- type: 'boolean',
294
- },
295
- enforceJsdocLineStyle: {
296
- enum: [
297
- 'multi', 'single',
298
- ],
299
- type: 'string',
300
- },
301
- lineOrBlockStyle: {
302
- enum: [
303
- 'block', 'line', 'both',
304
- ],
305
- type: 'string',
306
- },
307
- },
308
- type: 'object',
309
- },
310
- ],
311
- type: 'suggestion',
312
- },
313
- };
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
7
- const defaultEmptyTags = new Set([
8
- 'abstract', 'async', 'generator', 'global', 'hideconstructor',
9
- // jsdoc doesn't use this form in its docs, but allow for compatibility with
10
- // TypeScript which allows and Closure which requires
11
- 'ignore',
12
- // jsdoc doesn't use but allow for TypeScript
13
- 'inheritDoc', 'inner', 'instance',
14
- 'internal',
15
- 'overload',
16
- 'override',
17
- 'readonly',
18
- ]);
19
- const emptyIfNotClosure = new Set([
20
- // Closure doesn't allow with this casing
21
- 'inheritdoc', 'package', 'private', 'protected', 'public',
22
- 'static',
23
- ]);
24
- const emptyIfClosure = new Set([
25
- 'interface',
26
- ]);
27
- exports.default = (0, iterateJsdoc_js_1.default)(({ jsdoc, settings, utils, }) => {
28
- const emptyTags = utils.filterTags(({ tag: tagName, }) => {
29
- return defaultEmptyTags.has(tagName) ||
30
- utils.hasOptionTag(tagName) && jsdoc.tags.some(({ tag, }) => {
31
- return tag === tagName;
32
- }) ||
33
- settings.mode === 'closure' && emptyIfClosure.has(tagName) ||
34
- settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);
35
- });
36
- for (const [key, tag,] of emptyTags.entries()) {
37
- const content = tag.name || tag.description || tag.type;
38
- if (content.trim() && (
39
- // Allow for JSDoc-block final asterisks
40
- key !== emptyTags.length - 1 || !(/^\s*\*+$/v).test(content))) {
41
- const fix = () => {
42
- // By time of call in fixer, `tag` will have `line` added
43
- utils.setTag(
44
- /**
45
- * @type {import('comment-parser').Spec & {
46
- * line: import('../iterateJsdoc.js').Integer
47
- * }}
48
- */ (tag));
49
- };
50
- utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true);
51
- }
52
- }
53
- }, {
54
- checkInternal: true,
55
- checkPrivate: true,
56
- iterateAllJsdocs: true,
57
- meta: {
58
- docs: {
59
- description: 'Expects specific tags to be empty of any content.',
60
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header',
61
- },
62
- fixable: 'code',
63
- schema: [
64
- {
65
- additionalProperties: false,
66
- properties: {
67
- tags: {
68
- items: {
69
- type: 'string',
70
- },
71
- type: 'array',
72
- },
73
- },
74
- type: 'object',
75
- },
76
- ],
77
- type: 'suggestion',
78
- },
79
- });
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
7
- exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
8
- const iteratingFunction = utils.isIteratingFunctionOrVariable();
9
- if (iteratingFunction) {
10
- if (utils.hasATag([
11
- 'class',
12
- 'constructor',
13
- ]) ||
14
- utils.isConstructor()) {
15
- return;
16
- }
17
- }
18
- else if (!utils.isVirtualFunction()) {
19
- return;
20
- }
21
- utils.forEachPreferredTag('implements', (tag) => {
22
- report('@implements used on a non-constructor function', null, tag);
23
- });
24
- }, {
25
- contextDefaults: true,
26
- meta: {
27
- docs: {
28
- description: 'Reports an issue with any non-constructor function using `@implements`.',
29
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md#repos-sticky-header',
30
- },
31
- schema: [
32
- {
33
- additionalProperties: false,
34
- properties: {
35
- contexts: {
36
- items: {
37
- anyOf: [
38
- {
39
- type: 'string',
40
- },
41
- {
42
- additionalProperties: false,
43
- properties: {
44
- comment: {
45
- type: 'string',
46
- },
47
- context: {
48
- type: 'string',
49
- },
50
- },
51
- type: 'object',
52
- },
53
- ],
54
- },
55
- type: 'array',
56
- },
57
- },
58
- type: 'object',
59
- },
60
- ],
61
- type: 'suggestion',
62
- },
63
- });
@@ -1,105 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
7
- const jsdoccomment_1 = require("@es-joy/jsdoccomment");
8
- const fs_1 = require("fs");
9
- const node_module_1 = require("node:module");
10
- const path_1 = require("path");
11
- /**
12
- * @type {Set<string>|null}
13
- */
14
- let deps;
15
- const setDeps = function () {
16
- try {
17
- const pkg = JSON.parse(
18
- // @ts-expect-error It's ok
19
- (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), './package.json')));
20
- deps = new Set([
21
- ...(pkg.dependencies ?
22
- /* c8 ignore next 2 */
23
- Object.keys(pkg.dependencies) :
24
- []),
25
- ...(pkg.devDependencies ?
26
- /* c8 ignore next 2 */
27
- Object.keys(pkg.devDependencies) :
28
- []),
29
- ]);
30
- /* c8 ignore next -- our package.json exists */
31
- }
32
- catch (error) {
33
- /* c8 ignore next -- our package.json exists */
34
- deps = null;
35
- /* c8 ignore next 4 -- our package.json exists */
36
- /* eslint-disable no-console -- Inform user */
37
- console.log(error);
38
- /* eslint-enable no-console -- Inform user */
39
- }
40
- };
41
- const moduleCheck = new Map();
42
- exports.default = (0, iterateJsdoc_js_1.default)(({ jsdoc, settings, utils, }) => {
43
- if (deps === undefined) {
44
- setDeps();
45
- }
46
- /* c8 ignore next 3 -- our package.json exists */
47
- if (deps === null) {
48
- return;
49
- }
50
- const { mode, } = settings;
51
- for (const tag of jsdoc.tags) {
52
- let typeAst;
53
- try {
54
- typeAst = mode === 'permissive' ? (0, jsdoccomment_1.tryParse)(tag.type) : (0, jsdoccomment_1.parse)(tag.type, mode);
55
- }
56
- catch {
57
- continue;
58
- }
59
- // eslint-disable-next-line no-loop-func -- Safe
60
- (0, jsdoccomment_1.traverse)(typeAst, (nde) => {
61
- /* c8 ignore next 3 -- TS guard */
62
- if (deps === null) {
63
- return;
64
- }
65
- if (nde.type === 'JsdocTypeImport') {
66
- let mod = nde.element.value.replace(/^(@[^\/]+\/[^\/]+|[^\/]+).*$/v, '$1');
67
- if ((/^[.\/]/v).test(mod)) {
68
- return;
69
- }
70
- if ((0, node_module_1.isBuiltin)(mod)) {
71
- // mod = '@types/node';
72
- // moduleCheck.set(mod, !deps.has(mod));
73
- return;
74
- }
75
- else if (!moduleCheck.has(mod)) {
76
- let pkg;
77
- try {
78
- pkg = JSON.parse(
79
- // @ts-expect-error It's ok
80
- (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), 'node_modules', mod, './package.json')));
81
- }
82
- catch {
83
- // Ignore
84
- }
85
- if (!pkg || (!pkg.types && !pkg.typings)) {
86
- mod = `@types/${mod}`;
87
- }
88
- moduleCheck.set(mod, !deps.has(mod));
89
- }
90
- if (moduleCheck.get(mod)) {
91
- utils.reportJSDoc('import points to package which is not found in dependencies', tag);
92
- }
93
- }
94
- });
95
- }
96
- }, {
97
- iterateAllJsdocs: true,
98
- meta: {
99
- docs: {
100
- description: 'Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies`',
101
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md#repos-sticky-header',
102
- },
103
- type: 'suggestion',
104
- },
105
- });