eslint-plugin-jsdoc 50.6.17 → 50.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/alignTransform.cjs +10 -10
  2. package/dist/alignTransform.cjs.map +1 -1
  3. package/dist/exportParser.cjs +141 -135
  4. package/dist/exportParser.cjs.map +1 -1
  5. package/dist/generateRule.cjs +10 -12
  6. package/dist/generateRule.cjs.map +1 -1
  7. package/dist/getDefaultTagStructureForMode.cjs +73 -73
  8. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  9. package/dist/getJsdocProcessorPlugin.cjs +121 -110
  10. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  11. package/dist/index.cjs +17 -12
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +4 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/iterateJsdoc.cjs +87 -66
  16. package/dist/iterateJsdoc.cjs.map +1 -1
  17. package/dist/jsdocUtils.cjs +144 -142
  18. package/dist/jsdocUtils.cjs.map +1 -1
  19. package/dist/rules/checkAlignment.cjs +2 -2
  20. package/dist/rules/checkAlignment.cjs.map +1 -1
  21. package/dist/rules/checkExamples.cjs +22 -28
  22. package/dist/rules/checkExamples.cjs.map +1 -1
  23. package/dist/rules/checkIndentation.cjs +2 -2
  24. package/dist/rules/checkIndentation.cjs.map +1 -1
  25. package/dist/rules/checkLineAlignment.cjs +14 -14
  26. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  27. package/dist/rules/checkParamNames.cjs +21 -15
  28. package/dist/rules/checkParamNames.cjs.map +1 -1
  29. package/dist/rules/checkPropertyNames.cjs +2 -2
  30. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  31. package/dist/rules/checkTagNames.cjs +11 -11
  32. package/dist/rules/checkTagNames.cjs.map +1 -1
  33. package/dist/rules/checkTemplateNames.cjs +21 -22
  34. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  35. package/dist/rules/checkTypes.cjs +10 -10
  36. package/dist/rules/checkTypes.cjs.map +1 -1
  37. package/dist/rules/checkValues.cjs +11 -14
  38. package/dist/rules/checkValues.cjs.map +1 -1
  39. package/dist/rules/convertToJsdocComments.cjs +26 -27
  40. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  41. package/dist/rules/emptyTags.cjs +6 -6
  42. package/dist/rules/emptyTags.cjs.map +1 -1
  43. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  44. package/dist/rules/informativeDocs.cjs +12 -12
  45. package/dist/rules/informativeDocs.cjs.map +1 -1
  46. package/dist/rules/linesBeforeBlock.cjs +12 -12
  47. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  48. package/dist/rules/matchDescription.cjs +1 -1
  49. package/dist/rules/matchDescription.cjs.map +1 -1
  50. package/dist/rules/matchName.cjs +4 -4
  51. package/dist/rules/matchName.cjs.map +1 -1
  52. package/dist/rules/multilineBlocks.cjs +10 -10
  53. package/dist/rules/multilineBlocks.cjs.map +1 -1
  54. package/dist/rules/noBadBlocks.cjs +3 -3
  55. package/dist/rules/noBadBlocks.cjs.map +1 -1
  56. package/dist/rules/noMultiAsterisks.cjs +6 -6
  57. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  58. package/dist/rules/noRestrictedSyntax.cjs +2 -2
  59. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  60. package/dist/rules/noTypes.cjs.map +1 -1
  61. package/dist/rules/noUndefinedTypes.cjs +17 -20
  62. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  63. package/dist/rules/requireAsteriskPrefix.cjs +4 -4
  64. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  65. package/dist/rules/requireDescription.cjs +2 -2
  66. package/dist/rules/requireDescription.cjs.map +1 -1
  67. package/dist/rules/requireDescriptionCompleteSentence.cjs +8 -8
  68. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  69. package/dist/rules/requireFileOverview.cjs +6 -6
  70. package/dist/rules/requireFileOverview.cjs.map +1 -1
  71. package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -4
  72. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  73. package/dist/rules/requireJsdoc.cjs +19 -19
  74. package/dist/rules/requireJsdoc.cjs.map +1 -1
  75. package/dist/rules/requireParam.cjs +12 -12
  76. package/dist/rules/requireParam.cjs.map +1 -1
  77. package/dist/rules/requireProperty.cjs +1 -1
  78. package/dist/rules/requireProperty.cjs.map +1 -1
  79. package/dist/rules/requireReturns.cjs +3 -3
  80. package/dist/rules/requireReturns.cjs.map +1 -1
  81. package/dist/rules/requireReturnsCheck.cjs +1 -1
  82. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  83. package/dist/rules/requireReturnsDescription.cjs +1 -1
  84. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  85. package/dist/rules/requireTemplate.cjs +16 -15
  86. package/dist/rules/requireTemplate.cjs.map +1 -1
  87. package/dist/rules/requireYields.cjs +4 -4
  88. package/dist/rules/requireYields.cjs.map +1 -1
  89. package/dist/rules/requireYieldsCheck.cjs +6 -6
  90. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  91. package/dist/rules/sortTags.cjs +13 -13
  92. package/dist/rules/sortTags.cjs.map +1 -1
  93. package/dist/rules/tagLines.cjs +11 -11
  94. package/dist/rules/tagLines.cjs.map +1 -1
  95. package/dist/rules/textEscaping.cjs +2 -2
  96. package/dist/rules/textEscaping.cjs.map +1 -1
  97. package/dist/rules/validTypes.cjs +15 -15
  98. package/dist/rules/validTypes.cjs.map +1 -1
  99. package/dist/tagNames.cjs +1 -1
  100. package/dist/tagNames.cjs.map +1 -1
  101. package/dist/utils/hasReturnValue.cjs +176 -176
  102. package/dist/utils/hasReturnValue.cjs.map +1 -1
  103. package/eslint.config.js +36 -32
  104. package/package.json +29 -29
  105. package/pnpm-workspace.yaml +1 -0
  106. package/src/alignTransform.js +15 -15
  107. package/src/exportParser.js +386 -373
  108. package/src/getDefaultTagStructureForMode.js +45 -45
  109. package/src/getJsdocProcessorPlugin.js +175 -128
  110. package/src/index.js +66 -37
  111. package/src/iterateJsdoc.js +61 -28
  112. package/src/jsdocUtils.js +354 -338
  113. package/src/rules/checkAlignment.js +2 -2
  114. package/src/rules/checkExamples.js +16 -20
  115. package/src/rules/checkIndentation.js +2 -2
  116. package/src/rules/checkLineAlignment.js +10 -10
  117. package/src/rules/checkParamNames.js +22 -14
  118. package/src/rules/checkPropertyNames.js +1 -1
  119. package/src/rules/checkTagNames.js +7 -7
  120. package/src/rules/checkTemplateNames.js +52 -38
  121. package/src/rules/checkTypes.js +7 -7
  122. package/src/rules/checkValues.js +16 -17
  123. package/src/rules/convertToJsdocComments.js +47 -37
  124. package/src/rules/emptyTags.js +14 -7
  125. package/src/rules/importsAsDependencies.js +3 -1
  126. package/src/rules/informativeDocs.js +58 -58
  127. package/src/rules/linesBeforeBlock.js +25 -17
  128. package/src/rules/matchDescription.js +1 -1
  129. package/src/rules/matchName.js +2 -2
  130. package/src/rules/multilineBlocks.js +10 -10
  131. package/src/rules/noBadBlocks.js +3 -3
  132. package/src/rules/noMultiAsterisks.js +4 -4
  133. package/src/rules/noRestrictedSyntax.js +1 -1
  134. package/src/rules/noTypes.js +1 -1
  135. package/src/rules/noUndefinedTypes.js +29 -23
  136. package/src/rules/requireAsteriskPrefix.js +3 -3
  137. package/src/rules/requireDescription.js +1 -1
  138. package/src/rules/requireDescriptionCompleteSentence.js +6 -6
  139. package/src/rules/requireFileOverview.js +3 -3
  140. package/src/rules/requireHyphenBeforeParamDescription.js +2 -5
  141. package/src/rules/requireJsdoc.js +14 -14
  142. package/src/rules/requireParam.js +9 -9
  143. package/src/rules/requireProperty.js +1 -1
  144. package/src/rules/requireReturns.js +1 -1
  145. package/src/rules/requireReturnsCheck.js +1 -1
  146. package/src/rules/requireReturnsDescription.js +1 -1
  147. package/src/rules/requireTemplate.js +59 -38
  148. package/src/rules/requireYields.js +3 -3
  149. package/src/rules/requireYieldsCheck.js +1 -1
  150. package/src/rules/sortTags.js +7 -7
  151. package/src/rules/tagLines.js +8 -8
  152. package/src/rules/textEscaping.js +2 -0
  153. package/src/rules/validTypes.js +29 -29
  154. package/src/tagNames.js +2 -2
  155. package/src/utils/hasReturnValue.js +298 -283
@@ -1,17 +1,16 @@
1
- import iterateJsdoc from '../iterateJsdoc.js';
2
1
  import {
3
2
  getSettings,
4
3
  } from '../iterateJsdoc.js';
5
4
  import {
6
- getIndent,
7
- getContextObject,
8
5
  enforcedContexts,
6
+ getContextObject,
7
+ getIndent,
9
8
  } from '../jsdocUtils.js';
10
9
  import {
11
- getNonJsdocComment,
12
10
  getDecorator,
13
- getReducedASTNode,
14
11
  getFollowingComment,
12
+ getNonJsdocComment,
13
+ getReducedASTNode,
15
14
  } from '@es-joy/jsdoccomment';
16
15
 
17
16
  /** @type {import('eslint').Rule.RuleModule} */
@@ -44,15 +43,17 @@ export default {
44
43
  }
45
44
 
46
45
  const {
46
+ allowedPrefixes = [
47
+ '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',
48
+ ],
47
49
  contexts = settings.contexts || [],
48
50
  contextsAfter = /** @type {string[]} */ ([]),
49
51
  contextsBeforeAndAfter = [
50
- 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition'
52
+ 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',
51
53
  ],
52
54
  enableFixer = true,
53
55
  enforceJsdocLineStyle = 'multi',
54
56
  lineOrBlockStyle = 'both',
55
- allowedPrefixes = ['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-']
56
57
  } = context.options[0] ?? {};
57
58
 
58
59
  let reportingNonJsdoc = false;
@@ -75,7 +76,7 @@ export default {
75
76
  column: 0,
76
77
  /* c8 ignore next 2 -- Guard */
77
78
  // @ts-expect-error Ok
78
- line: (comment.loc?.start?.line ?? 1)
79
+ line: (comment.loc?.start?.line ?? 1),
79
80
  },
80
81
  };
81
82
 
@@ -110,7 +111,7 @@ export default {
110
111
 
111
112
  const decorator = getDecorator(
112
113
  /** @type {import('eslint').Rule.Node} */
113
- (baseNode)
114
+ (baseNode),
114
115
  );
115
116
  if (decorator) {
116
117
  baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (
@@ -169,6 +170,7 @@ export default {
169
170
  if (lineOrBlockStyle === 'line') {
170
171
  return;
171
172
  }
173
+
172
174
  report('blockCommentsJsdocStyle', comment, node, fixer);
173
175
  return;
174
176
  }
@@ -177,6 +179,7 @@ export default {
177
179
  if (lineOrBlockStyle === 'block') {
178
180
  return;
179
181
  }
182
+
180
183
  report('lineCommentsJsdocStyle', comment, node, fixer);
181
184
  }
182
185
  };
@@ -200,17 +203,18 @@ export default {
200
203
  reportingNonJsdoc = true;
201
204
 
202
205
  /** @type {AddComment} */
203
- const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => {
206
+ // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts
207
+ const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
204
208
  const insertion = (
205
- inlineCommentBlock || enforceJsdocLineStyle === 'single'
206
- ? `/** ${comment.value.trim()} `
207
- : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`
209
+ inlineCommentBlock || enforceJsdocLineStyle === 'single' ?
210
+ `/** ${commentToAdd.value.trim()} ` :
211
+ `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`
208
212
  ) +
209
213
  `*/${'\n'.repeat((lines || 1) - 1)}`;
210
214
 
211
215
  return fixer.replaceText(
212
216
  /** @type {import('eslint').AST.Token} */
213
- (comment),
217
+ (commentToAdd),
214
218
  insertion,
215
219
  );
216
220
  };
@@ -237,21 +241,23 @@ export default {
237
241
  }
238
242
 
239
243
  /** @type {AddComment} */
240
- const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => {
244
+ const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
241
245
  const insertion = (
242
- inlineCommentBlock || enforceJsdocLineStyle === 'single'
243
- ? `/** ${comment.value.trim()} `
244
- : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`
246
+ inlineCommentBlock || enforceJsdocLineStyle === 'single' ?
247
+ `/** ${commentToAdd.value.trim()} ` :
248
+ `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`
245
249
  ) +
246
250
  `*/${'\n'.repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : ' '}`;
247
251
 
248
- return [fixer.remove(
252
+ return [
253
+ fixer.remove(
249
254
  /** @type {import('eslint').AST.Token} */
250
- (comment)
251
- ), fixer.insertTextBefore(
252
- node.type === 'VariableDeclarator' ? node.parent : node,
253
- insertion,
254
- )];
255
+ (commentToAdd),
256
+ ), fixer.insertTextBefore(
257
+ node.type === 'VariableDeclarator' ? node.parent : node,
258
+ insertion,
259
+ ),
260
+ ];
255
261
  };
256
262
 
257
263
  reportings(comment, node, addComment, ctxts);
@@ -276,31 +282,31 @@ export default {
276
282
  if (!reportingNonJsdoc) {
277
283
  checkNonJsdocAfter(node, contextsBeforeAndAfter);
278
284
  }
279
- }
280
- )
285
+ },
286
+ ),
281
287
  };
282
288
  },
283
289
  meta: {
290
+ docs: {
291
+ description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',
292
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',
293
+ },
294
+
284
295
  fixable: 'code',
285
296
 
286
297
  messages: {
287
298
  blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',
288
299
  lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',
289
300
  },
290
-
291
- docs: {
292
- description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',
293
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',
294
- },
295
301
  schema: [
296
302
  {
297
303
  additionalProperties: false,
298
304
  properties: {
299
305
  allowedPrefixes: {
300
- type: 'array',
301
306
  items: {
302
- type: 'string'
303
- }
307
+ type: 'string',
308
+ },
309
+ type: 'array',
304
310
  },
305
311
  contexts: {
306
312
  items: {
@@ -369,15 +375,19 @@ export default {
369
375
  type: 'array',
370
376
  },
371
377
  enableFixer: {
372
- type: 'boolean'
378
+ type: 'boolean',
373
379
  },
374
380
  enforceJsdocLineStyle: {
381
+ enum: [
382
+ 'multi', 'single',
383
+ ],
375
384
  type: 'string',
376
- enum: ['multi', 'single']
377
385
  },
378
386
  lineOrBlockStyle: {
387
+ enum: [
388
+ 'block', 'line', 'both',
389
+ ],
379
390
  type: 'string',
380
- enum: ['block', 'line', 'both']
381
391
  },
382
392
  },
383
393
  type: 'object',
@@ -2,22 +2,26 @@ import iterateJsdoc from '../iterateJsdoc.js';
2
2
 
3
3
  const defaultEmptyTags = new Set([
4
4
  'abstract', 'async', 'generator', 'global', 'hideconstructor',
5
- 'ignore', 'inner', 'instance', 'override', 'readonly',
6
5
 
7
6
  // jsdoc doesn't use this form in its docs, but allow for compatibility with
8
7
  // TypeScript which allows and Closure which requires
9
- 'inheritDoc',
8
+ 'ignore',
10
9
 
11
10
  // jsdoc doesn't use but allow for TypeScript
11
+ 'inheritDoc', 'inner', 'instance',
12
12
  'internal',
13
+
13
14
  'overload',
15
+
16
+ 'override',
17
+ 'readonly',
14
18
  ]);
15
19
 
16
20
  const emptyIfNotClosure = new Set([
17
- 'package', 'private', 'protected', 'public', 'static',
18
-
19
21
  // Closure doesn't allow with this casing
20
- 'inheritdoc',
22
+ 'inheritdoc', 'package', 'private', 'protected', 'public',
23
+
24
+ 'static',
21
25
  ]);
22
26
 
23
27
  const emptyIfClosure = new Set([
@@ -25,8 +29,8 @@ const emptyIfClosure = new Set([
25
29
  ]);
26
30
 
27
31
  export default iterateJsdoc(({
28
- settings,
29
32
  jsdoc,
33
+ settings,
30
34
  utils,
31
35
  }) => {
32
36
  const emptyTags = utils.filterTags(({
@@ -42,7 +46,10 @@ export default iterateJsdoc(({
42
46
  settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);
43
47
  });
44
48
 
45
- for (const [key, tag] of emptyTags.entries()) {
49
+ for (const [
50
+ key,
51
+ tag,
52
+ ] of emptyTags.entries()) {
46
53
  const content = tag.name || tag.description || tag.type;
47
54
  if (content.trim() && (
48
55
  // Allow for JSDoc-block final asterisks
@@ -7,7 +7,9 @@ import {
7
7
  import {
8
8
  readFileSync,
9
9
  } from 'fs';
10
- import {isBuiltin as isBuiltinModule} from 'node:module';
10
+ import {
11
+ isBuiltin as isBuiltinModule,
12
+ } from 'node:module';
11
13
  import {
12
14
  join,
13
15
  } from 'path';
@@ -21,72 +21,72 @@ const defaultUselessWords = [
21
21
  */
22
22
  const getNamesFromNode = (node) => {
23
23
  switch (node?.type) {
24
- case 'AccessorProperty':
25
- case 'MethodDefinition':
26
- case 'PropertyDefinition':
27
- case 'TSAbstractAccessorProperty':
28
- case 'TSAbstractMethodDefinition':
29
- case 'TSAbstractPropertyDefinition':
30
- return [
31
- ...getNamesFromNode(
24
+ case 'AccessorProperty':
25
+ case 'MethodDefinition':
26
+ case 'PropertyDefinition':
27
+ case 'TSAbstractAccessorProperty':
28
+ case 'TSAbstractMethodDefinition':
29
+ case 'TSAbstractPropertyDefinition':
30
+ return [
31
+ ...getNamesFromNode(
32
32
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (
33
- node.parent
34
- ).parent,
35
- ),
36
- ...getNamesFromNode(
33
+ node.parent
34
+ ).parent,
35
+ ),
36
+ ...getNamesFromNode(
37
37
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */
38
- (node.key),
39
- ),
40
- ];
38
+ (node.key),
39
+ ),
40
+ ];
41
41
 
42
- case 'ExportDefaultDeclaration':
43
- case 'ExportNamedDeclaration':
44
- return getNamesFromNode(
45
- /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */
46
- (node).declaration
47
- );
48
- case 'ClassDeclaration':
49
- case 'ClassExpression':
50
- case 'FunctionDeclaration':
51
- case 'FunctionExpression':
52
- case 'TSModuleDeclaration':
53
- case 'TSMethodSignature':
54
- case 'TSDeclareFunction':
55
- case 'TSEnumDeclaration':
56
- case 'TSEnumMember':
57
- case 'TSInterfaceDeclaration':
58
- case 'TSTypeAliasDeclaration':
59
- return getNamesFromNode(
42
+ case 'ClassDeclaration':
43
+ case 'ClassExpression':
44
+ case 'FunctionDeclaration':
45
+ case 'FunctionExpression':
46
+ case 'TSDeclareFunction':
47
+ case 'TSEnumDeclaration':
48
+ case 'TSEnumMember':
49
+ case 'TSInterfaceDeclaration':
50
+ case 'TSMethodSignature':
51
+ case 'TSModuleDeclaration':
52
+ case 'TSTypeAliasDeclaration':
53
+ return getNamesFromNode(
60
54
  /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */
61
- (node).id,
62
- );
63
- case 'Identifier':
64
- return [
65
- node.name,
66
- ];
67
- case 'Property':
68
- return getNamesFromNode(
55
+ (node).id,
56
+ );
57
+ case 'ExportDefaultDeclaration':
58
+ case 'ExportNamedDeclaration':
59
+ return getNamesFromNode(
60
+ /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */
61
+ (node).declaration,
62
+ );
63
+ case 'Identifier':
64
+ return [
65
+ node.name,
66
+ ];
67
+ case 'Property':
68
+ return getNamesFromNode(
69
69
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */
70
- (node.key),
71
- );
72
- case 'VariableDeclaration':
73
- return getNamesFromNode(
70
+ (node.key),
71
+ );
72
+ case 'VariableDeclaration':
73
+ return getNamesFromNode(
74
74
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */
75
- (node.declarations[0]),
76
- );
77
- case 'VariableDeclarator':
78
- return [
79
- ...getNamesFromNode(
75
+ (node.declarations[0]),
76
+ );
77
+ case 'VariableDeclarator':
78
+ return [
79
+ ...getNamesFromNode(
80
80
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */
81
- (node.id),
82
- ),
83
- ...getNamesFromNode(
81
+ (node.id),
82
+ ),
83
+ ...getNamesFromNode(
84
84
  /** @type {import('@typescript-eslint/types').TSESTree.Node} */
85
- (node.init),
86
- ),
87
- ].filter(Boolean);
88
- default:
89
- return [];
85
+ (node.init),
86
+ ),
87
+ ].filter(Boolean);
88
+ default:
89
+ return [];
90
90
  }
91
91
  };
92
92
  /* eslint-enable complexity -- Temporary */
@@ -5,27 +5,33 @@ import iterateJsdoc from '../iterateJsdoc.js';
5
5
  * `[` starts an array, `{` starts an object or block, `(` starts a grouping, and `=` starts a
6
6
  * declaration (like a variable or a type alias).
7
7
  */
8
- const startPunctuators = new Set(['[', '{', '(', '=']);
8
+ const startPunctuators = new Set([
9
+ '(', '=', '[', '{',
10
+ ]);
9
11
 
10
12
  export default iterateJsdoc(({
11
13
  context,
12
14
  jsdocNode,
13
- sourceCode,
14
15
  report,
16
+ sourceCode,
15
17
  utils,
16
18
  }) => {
17
19
  const {
18
20
  checkBlockStarts,
19
- lines = 1,
21
+ excludedTags = [
22
+ 'type',
23
+ ],
20
24
  ignoreSameLine = true,
21
- excludedTags = ['type']
25
+ lines = 1,
22
26
  } = context.options[0] || {};
23
27
 
24
28
  if (utils.hasATag(excludedTags)) {
25
29
  return;
26
30
  }
27
31
 
28
- const tokensBefore = sourceCode.getTokensBefore(jsdocNode, {includeComments: true});
32
+ const tokensBefore = sourceCode.getTokensBefore(jsdocNode, {
33
+ includeComments: true,
34
+ });
29
35
  const tokenBefore = tokensBefore.at(-1);
30
36
  if (
31
37
  !tokenBefore || (
@@ -38,9 +44,9 @@ export default iterateJsdoc(({
38
44
  }
39
45
 
40
46
  if (tokenBefore.loc?.end?.line + lines >=
41
- /** @type {number} */
47
+ /** @type {number} */
42
48
  (jsdocNode.loc?.start?.line)
43
- ) {
49
+ ) {
44
50
  const startLine = jsdocNode.loc?.start?.line;
45
51
  const sameLine = tokenBefore.loc?.end?.line === startLine;
46
52
 
@@ -53,11 +59,11 @@ export default iterateJsdoc(({
53
59
  let indent = '';
54
60
  if (sameLine) {
55
61
  const spaceDiff = /** @type {number} */ (jsdocNode.loc?.start?.column) -
56
- /** @type {number} */ (tokenBefore.loc?.end?.column);
62
+ /** @type {number} */ (tokenBefore.loc?.end?.column);
57
63
  // @ts-expect-error Should be a comment
58
64
  indent = /** @type {import('estree').Comment} */ (
59
65
  jsdocNode
60
- ).value.match(/^\*\n([ \t]*) \*/)?.[1]?.slice(spaceDiff);
66
+ ).value.match(/^\*\n([\t ]*) \*/u)?.[1]?.slice(spaceDiff);
61
67
  if (!indent) {
62
68
  /** @type {import('eslint').AST.Token|import('estree').Comment|undefined} */
63
69
  let tokenPrior = tokenBefore;
@@ -66,9 +72,10 @@ export default iterateJsdoc(({
66
72
  startColumn = tokenPrior.loc?.start?.column;
67
73
  tokenPrior = tokensBefore.pop();
68
74
  }
75
+
69
76
  indent = ' '.repeat(
70
77
  /* c8 ignore next */
71
- /** @type {number} */ (startColumn ? startColumn - 1 : 0)
78
+ /** @type {number} */ (startColumn ? startColumn - 1 : 0),
72
79
  );
73
80
  }
74
81
  }
@@ -77,19 +84,20 @@ export default iterateJsdoc(({
77
84
  /** @type {import('eslint').AST.Token} */
78
85
  (tokenBefore),
79
86
  '\n'.repeat(lines) +
80
- (sameLine ? '\n' + indent : '')
87
+ (sameLine ? '\n' + indent : ''),
81
88
  );
82
89
  };
90
+
83
91
  report(`Required ${lines} line(s) before JSDoc block`, fix);
84
92
  }
85
93
  }, {
86
94
  iterateAllJsdocs: true,
87
95
  meta: {
88
- fixable: 'code',
89
96
  docs: {
90
97
  description: 'Enforces minimum number of newlines before JSDoc comment blocks',
91
98
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/lines-before-block.md#repos-sticky-header',
92
99
  },
100
+ fixable: 'code',
93
101
  schema: [
94
102
  {
95
103
  additionalProperties: false,
@@ -98,17 +106,17 @@ export default iterateJsdoc(({
98
106
  type: 'boolean',
99
107
  },
100
108
  excludedTags: {
101
- type: 'array',
102
109
  items: {
103
- type: 'string'
104
- }
110
+ type: 'string',
111
+ },
112
+ type: 'array',
105
113
  },
106
114
  ignoreSameLine: {
107
115
  type: 'boolean',
108
116
  },
109
117
  lines: {
110
- type: 'integer'
111
- }
118
+ type: 'integer',
119
+ },
112
120
  },
113
121
  type: 'object',
114
122
  },
@@ -16,9 +16,9 @@ const stringOrDefault = (value, userDefault) => {
16
16
  };
17
17
 
18
18
  export default iterateJsdoc(({
19
+ context,
19
20
  jsdoc,
20
21
  report,
21
- context,
22
22
  utils,
23
23
  }) => {
24
24
  const {
@@ -3,11 +3,11 @@ import iterateJsdoc from '../iterateJsdoc.js';
3
3
  // eslint-disable-next-line complexity
4
4
  export default iterateJsdoc(({
5
5
  context,
6
- jsdoc,
7
- report,
8
6
  info: {
9
7
  lastIndex,
10
8
  },
9
+ jsdoc,
10
+ report,
11
11
  utils,
12
12
  }) => {
13
13
  const {
@@ -7,17 +7,17 @@ export default iterateJsdoc(({
7
7
  }) => {
8
8
  const {
9
9
  allowMultipleTags = true,
10
+ minimumLengthForMultiline = Number.POSITIVE_INFINITY,
11
+ multilineTags = [
12
+ '*',
13
+ ],
10
14
  noFinalLineText = true,
11
- noZeroLineText = true,
15
+ noMultilineBlocks = false,
12
16
  noSingleLineBlocks = false,
17
+ noZeroLineText = true,
13
18
  singleLineTags = [
14
19
  'lends', 'type',
15
20
  ],
16
- noMultilineBlocks = false,
17
- minimumLengthForMultiline = Number.POSITIVE_INFINITY,
18
- multilineTags = [
19
- '*',
20
- ],
21
21
  } = context.options[0] || {};
22
22
 
23
23
  const {
@@ -209,13 +209,13 @@ export default iterateJsdoc(({
209
209
  tokens: jsdoc.source.reduce((obj, {
210
210
  tokens: {
211
211
  description: desc,
212
- tag: tg,
213
- type: typ,
214
- name: nme,
215
212
  lineEnd,
216
- postType,
213
+ name: nme,
217
214
  postName,
218
215
  postTag,
216
+ postType,
217
+ tag: tg,
218
+ type: typ,
219
219
  },
220
220
  }) => {
221
221
  if (typ) {
@@ -9,10 +9,10 @@ const commentRegexp = /^\/\*(?!\*)/u;
9
9
  const extraAsteriskCommentRegexp = /^\/\*{3,}/u;
10
10
 
11
11
  export default iterateJsdoc(({
12
- context,
13
- sourceCode,
14
12
  allComments,
13
+ context,
15
14
  makeReport,
15
+ sourceCode,
16
16
  }) => {
17
17
  const [
18
18
  {
@@ -34,7 +34,7 @@ export default iterateJsdoc(({
34
34
 
35
35
  const initialText = commentText.replace(commentRegexp, '').trimStart();
36
36
  if ([
37
- 'eslint'
37
+ 'eslint',
38
38
  ].some((directive) => {
39
39
  return initialText.startsWith(directive);
40
40
  })) {
@@ -24,17 +24,17 @@ export default iterateJsdoc(({
24
24
 
25
25
  // eslint-disable-next-line complexity -- Todo
26
26
  jsdoc.source.some(({
27
- tokens,
28
27
  number,
28
+ tokens,
29
29
  }) => {
30
30
  const {
31
31
  delimiter,
32
- tag,
33
- name,
34
- type,
35
32
  description,
36
33
  end,
34
+ name,
37
35
  postDelimiter,
36
+ tag,
37
+ type,
38
38
  } = tokens;
39
39
 
40
40
  if (
@@ -19,8 +19,8 @@ export default iterateJsdoc(({
19
19
  } = context.options[0];
20
20
 
21
21
  const {
22
- foundContext,
23
22
  contextStr,
23
+ foundContext,
24
24
  } = utils.findContext(contexts, comment);
25
25
 
26
26
  // We are not on the *particular* matching context/comment, so don't assume
@@ -34,7 +34,7 @@ export default iterateJsdoc(({
34
34
  contextDefaults: [
35
35
  'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
36
36
  // Add this to above defaults
37
- 'TSMethodSignature'
37
+ 'TSMethodSignature',
38
38
  ],
39
39
  meta: {
40
40
  docs: {