eslint-plugin-jsdoc 39.3.6 → 39.3.13

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 (124) hide show
  1. package/README.md +281 -52
  2. package/dist/WarnSettings.js +0 -5
  3. package/dist/WarnSettings.js.map +1 -1
  4. package/dist/alignTransform.js +69 -61
  5. package/dist/alignTransform.js.map +1 -1
  6. package/dist/bin/generateRule.js +7 -26
  7. package/dist/bin/generateRule.js.map +1 -1
  8. package/dist/defaultTagOrder.js +30 -14
  9. package/dist/defaultTagOrder.js.map +1 -1
  10. package/dist/exportParser.js +34 -143
  11. package/dist/exportParser.js.map +1 -1
  12. package/dist/generateRule.js +7 -26
  13. package/dist/generateRule.js.map +1 -1
  14. package/dist/getDefaultTagStructureForMode.js +189 -93
  15. package/dist/getDefaultTagStructureForMode.js.map +1 -1
  16. package/dist/index.js +0 -51
  17. package/dist/index.js.map +1 -1
  18. package/dist/iterateJsdoc.js +43 -206
  19. package/dist/iterateJsdoc.js.map +1 -1
  20. package/dist/jsdocUtils.js +71 -220
  21. package/dist/jsdocUtils.js.map +1 -1
  22. package/dist/rules/checkAccess.js +0 -8
  23. package/dist/rules/checkAccess.js.map +1 -1
  24. package/dist/rules/checkAlignment.js +0 -8
  25. package/dist/rules/checkAlignment.js.map +1 -1
  26. package/dist/rules/checkExamples.js +25 -63
  27. package/dist/rules/checkExamples.js.map +1 -1
  28. package/dist/rules/checkIndentation.js +0 -7
  29. package/dist/rules/checkIndentation.js.map +1 -1
  30. package/dist/rules/checkLineAlignment.js +9 -30
  31. package/dist/rules/checkLineAlignment.js.map +1 -1
  32. package/dist/rules/checkParamNames.js +11 -47
  33. package/dist/rules/checkParamNames.js.map +1 -1
  34. package/dist/rules/checkPropertyNames.js +1 -18
  35. package/dist/rules/checkPropertyNames.js.map +1 -1
  36. package/dist/rules/checkSyntax.js +2 -5
  37. package/dist/rules/checkSyntax.js.map +1 -1
  38. package/dist/rules/checkTagNames.js +0 -18
  39. package/dist/rules/checkTagNames.js.map +1 -1
  40. package/dist/rules/checkTypes.js +17 -46
  41. package/dist/rules/checkTypes.js.map +1 -1
  42. package/dist/rules/checkValues.js +0 -18
  43. package/dist/rules/checkValues.js.map +1 -1
  44. package/dist/rules/emptyTags.js +6 -11
  45. package/dist/rules/emptyTags.js.map +1 -1
  46. package/dist/rules/implementsOnClasses.js +0 -6
  47. package/dist/rules/implementsOnClasses.js.map +1 -1
  48. package/dist/rules/matchDescription.js +0 -20
  49. package/dist/rules/matchDescription.js.map +1 -1
  50. package/dist/rules/matchName.js +2 -17
  51. package/dist/rules/matchName.js.map +1 -1
  52. package/dist/rules/multilineBlocks.js +10 -34
  53. package/dist/rules/multilineBlocks.js.map +1 -1
  54. package/dist/rules/newlineAfterDescription.js +0 -8
  55. package/dist/rules/newlineAfterDescription.js.map +1 -1
  56. package/dist/rules/noBadBlocks.js +2 -16
  57. package/dist/rules/noBadBlocks.js.map +1 -1
  58. package/dist/rules/noDefaults.js +0 -7
  59. package/dist/rules/noDefaults.js.map +1 -1
  60. package/dist/rules/noMissingSyntax.js +2 -16
  61. package/dist/rules/noMissingSyntax.js.map +1 -1
  62. package/dist/rules/noMultiAsterisks.js +2 -16
  63. package/dist/rules/noMultiAsterisks.js.map +1 -1
  64. package/dist/rules/noRestrictedSyntax.js +3 -9
  65. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  66. package/dist/rules/noTypes.js +0 -7
  67. package/dist/rules/noTypes.js.map +1 -1
  68. package/dist/rules/noUndefinedTypes.js +13 -34
  69. package/dist/rules/noUndefinedTypes.js.map +1 -1
  70. package/dist/rules/requireAsteriskPrefix.js +2 -26
  71. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  72. package/dist/rules/requireDescription.js +0 -17
  73. package/dist/rules/requireDescription.js.map +1 -1
  74. package/dist/rules/requireDescriptionCompleteSentence.js +13 -34
  75. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  76. package/dist/rules/requireExample.js +0 -9
  77. package/dist/rules/requireExample.js.map +1 -1
  78. package/dist/rules/requireFileOverview.js +0 -16
  79. package/dist/rules/requireFileOverview.js.map +1 -1
  80. package/dist/rules/requireHyphenBeforeParamDescription.js +2 -16
  81. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  82. package/dist/rules/requireJsdoc.js +13 -58
  83. package/dist/rules/requireJsdoc.js.map +1 -1
  84. package/dist/rules/requireParam.js +6 -53
  85. package/dist/rules/requireParam.js.map +1 -1
  86. package/dist/rules/requireParamDescription.js +0 -4
  87. package/dist/rules/requireParamDescription.js.map +1 -1
  88. package/dist/rules/requireParamName.js +0 -4
  89. package/dist/rules/requireParamName.js.map +1 -1
  90. package/dist/rules/requireParamType.js +0 -4
  91. package/dist/rules/requireParamType.js.map +1 -1
  92. package/dist/rules/requireProperty.js +0 -9
  93. package/dist/rules/requireProperty.js.map +1 -1
  94. package/dist/rules/requirePropertyDescription.js +0 -4
  95. package/dist/rules/requirePropertyDescription.js.map +1 -1
  96. package/dist/rules/requirePropertyName.js +0 -4
  97. package/dist/rules/requirePropertyName.js.map +1 -1
  98. package/dist/rules/requirePropertyType.js +0 -4
  99. package/dist/rules/requirePropertyType.js.map +1 -1
  100. package/dist/rules/requireReturns.js +13 -23
  101. package/dist/rules/requireReturns.js.map +1 -1
  102. package/dist/rules/requireReturnsCheck.js +12 -20
  103. package/dist/rules/requireReturnsCheck.js.map +1 -1
  104. package/dist/rules/requireReturnsDescription.js +0 -6
  105. package/dist/rules/requireReturnsDescription.js.map +1 -1
  106. package/dist/rules/requireReturnsType.js +0 -4
  107. package/dist/rules/requireReturnsType.js.map +1 -1
  108. package/dist/rules/requireThrows.js +6 -15
  109. package/dist/rules/requireThrows.js.map +1 -1
  110. package/dist/rules/requireYields.js +13 -29
  111. package/dist/rules/requireYields.js.map +1 -1
  112. package/dist/rules/requireYieldsCheck.js +8 -29
  113. package/dist/rules/requireYieldsCheck.js.map +1 -1
  114. package/dist/rules/sortTags.js +17 -30
  115. package/dist/rules/sortTags.js.map +1 -1
  116. package/dist/rules/tagLines.js +0 -26
  117. package/dist/rules/tagLines.js.map +1 -1
  118. package/dist/rules/validTypes.js +22 -53
  119. package/dist/rules/validTypes.js.map +1 -1
  120. package/dist/tagNames.js +7 -4
  121. package/dist/tagNames.js.map +1 -1
  122. package/dist/utils/hasReturnValue.js +22 -66
  123. package/dist/utils/hasReturnValue.js.map +1 -1
  124. package/package.json +16 -16
@@ -4,30 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _WarnSettings = _interopRequireDefault(require("./WarnSettings"));
9
-
10
8
  var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode"));
11
-
12
9
  var _tagNames = require("./tagNames");
13
-
14
10
  var _hasReturnValue = require("./utils/hasReturnValue");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  /* eslint-disable jsdoc/no-undefined-types */
19
13
 
20
14
  /**
21
15
  * @typedef {"jsdoc"|"typescript"|"closure"} ParserMode
22
16
  */
23
- let tagStructure;
24
17
 
18
+ let tagStructure;
25
19
  const setTagStructure = mode => {
26
20
  tagStructure = (0, _getDefaultTagStructureForMode.default)(mode);
27
- }; // Given a nested array of property names, reduce them to a single array,
28
- // appending the name of the root element along the way if present.
29
-
21
+ };
30
22
 
23
+ // Given a nested array of property names, reduce them to a single array,
24
+ // appending the name of the root element along the way if present.
31
25
  const flattenRoots = (params, root = '') => {
32
26
  let hasRestElement = false;
33
27
  let hasPropertyRest = false;
@@ -35,36 +29,28 @@ const flattenRoots = (params, root = '') => {
35
29
  const names = params.reduce((acc, cur) => {
36
30
  if (Array.isArray(cur)) {
37
31
  let nms;
38
-
39
32
  if (Array.isArray(cur[1])) {
40
33
  nms = cur[1];
41
34
  } else {
42
35
  if (cur[1].hasRestElement) {
43
36
  hasRestElement = true;
44
37
  }
45
-
46
38
  if (cur[1].hasPropertyRest) {
47
39
  hasPropertyRest = true;
48
40
  }
49
-
50
41
  nms = cur[1].names;
51
42
  }
52
-
53
43
  const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]);
54
-
55
44
  if (flattened.hasRestElement) {
56
45
  hasRestElement = true;
57
46
  }
58
-
59
47
  if (flattened.hasPropertyRest) {
60
48
  hasPropertyRest = true;
61
49
  }
62
-
63
50
  const inner = [root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
64
51
  rests.push(false, ...flattened.rests);
65
52
  return acc.concat(inner);
66
53
  }
67
-
68
54
  if (typeof cur === 'object') {
69
55
  if (cur.isRestProperty) {
70
56
  hasPropertyRest = true;
@@ -72,17 +58,14 @@ const flattenRoots = (params, root = '') => {
72
58
  } else {
73
59
  rests.push(false);
74
60
  }
75
-
76
61
  if (cur.restElement) {
77
62
  hasRestElement = true;
78
63
  }
79
-
80
64
  acc.push(root ? `${root}.${cur.name}` : cur.name);
81
65
  } else if (typeof cur !== 'undefined') {
82
66
  rests.push(false);
83
67
  acc.push(root ? `${root}.${cur}` : cur);
84
68
  }
85
-
86
69
  return acc;
87
70
  }, []);
88
71
  return {
@@ -92,79 +75,65 @@ const flattenRoots = (params, root = '') => {
92
75
  rests
93
76
  };
94
77
  };
78
+
95
79
  /**
96
80
  * @param {object} propSignature
97
81
  * @returns {undefined|Array|string}
98
82
  */
99
-
100
-
101
83
  const getPropertiesFromPropertySignature = propSignature => {
102
84
  if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
103
85
  return undefined;
104
86
  }
105
-
106
87
  if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
107
88
  return [propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => {
108
89
  return getPropertiesFromPropertySignature(member);
109
90
  })];
110
91
  }
111
-
112
92
  return propSignature.key.name;
113
93
  };
94
+
114
95
  /**
115
96
  * @param {object} functionNode
116
97
  * @param {boolean} checkDefaultObjects
117
98
  * @returns {Array}
118
99
  */
119
-
120
-
121
100
  const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
122
101
  var _functionNode$value;
123
-
124
102
  // eslint-disable-next-line complexity
125
103
  const getParamName = (param, isProperty) => {
126
104
  var _param$left, _param$left3;
127
-
128
105
  const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left;
129
-
130
106
  if ('typeAnnotation' in param || hasLeftTypeAnnotation) {
131
107
  const typeAnnotation = hasLeftTypeAnnotation ? param.left.typeAnnotation : param.typeAnnotation;
132
-
133
108
  if (typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
134
109
  const propertyNames = typeAnnotation.typeAnnotation.members.map(member => {
135
110
  return getPropertiesFromPropertySignature(member);
136
111
  });
137
- const flattened = { ...flattenRoots(propertyNames),
112
+ const flattened = {
113
+ ...flattenRoots(propertyNames),
138
114
  annotationParamName: param.name
139
115
  };
140
116
  const hasLeftName = 'left' in param && 'name' in param.left;
141
-
142
117
  if ('name' in param || hasLeftName) {
143
118
  return [hasLeftName ? param.left.name : param.name, flattened];
144
119
  }
145
-
146
120
  return [undefined, flattened];
147
121
  }
148
122
  }
149
-
150
123
  if ('name' in param) {
151
124
  return param.name;
152
125
  }
153
-
154
126
  if ('left' in param && 'name' in param.left) {
155
127
  return param.left.name;
156
128
  }
157
-
158
129
  if (param.type === 'ObjectPattern' || ((_param$left = param.left) === null || _param$left === void 0 ? void 0 : _param$left.type) === 'ObjectPattern') {
159
130
  var _param$left2;
160
-
161
131
  const properties = param.properties || ((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.properties);
162
132
  const roots = properties.map(prop => {
163
133
  return getParamName(prop, true);
164
134
  });
165
135
  return [undefined, flattenRoots(roots)];
166
136
  }
167
-
168
137
  if (param.type === 'Property') {
169
138
  // eslint-disable-next-line default-case
170
139
  switch (param.value.type) {
@@ -175,12 +144,10 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
175
144
  restElement: prop.type === 'RestElement'
176
145
  };
177
146
  })];
178
-
179
147
  case 'ObjectPattern':
180
148
  return [param.key.name, param.value.properties.map(prop => {
181
149
  return getParamName(prop, isProperty);
182
150
  })];
183
-
184
151
  case 'AssignmentPattern':
185
152
  {
186
153
  // eslint-disable-next-line default-case
@@ -192,14 +159,11 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
192
159
  return getParamName(prop, isProperty);
193
160
  })];
194
161
  }
195
-
196
162
  break;
197
-
198
163
  case 'ObjectPattern':
199
164
  return [param.key.name, param.value.left.properties.map(prop => {
200
165
  return getParamName(prop, isProperty);
201
166
  })];
202
-
203
167
  case 'ArrayPattern':
204
168
  return [param.key.name, param.value.left.elements.map((prop, idx) => {
205
169
  return {
@@ -210,17 +174,17 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
210
174
  }
211
175
  }
212
176
  }
213
-
214
177
  switch (param.key.type) {
215
178
  case 'Identifier':
216
179
  return param.key.name;
217
- // The key of an object could also be a string or number
218
180
 
181
+ // The key of an object could also be a string or number
219
182
  case 'Literal':
220
- return param.key.raw || // istanbul ignore next -- `raw` may not be present in all parsers
183
+ return param.key.raw ||
184
+ // istanbul ignore next -- `raw` may not be present in all parsers
221
185
  param.key.value;
222
- // case 'MemberExpression':
223
186
 
187
+ // case 'MemberExpression':
224
188
  default:
225
189
  // Todo: We should really create a structure (and a corresponding
226
190
  // option analogous to `checkRestProperty`) which allows for
@@ -229,10 +193,8 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
229
193
  return undefined;
230
194
  }
231
195
  }
232
-
233
196
  if (param.type === 'ArrayPattern' || ((_param$left3 = param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.type) === 'ArrayPattern') {
234
197
  var _param$left4;
235
-
236
198
  const elements = param.elements || ((_param$left4 = param.left) === null || _param$left4 === void 0 ? void 0 : _param$left4.elements);
237
199
  const roots = elements.map((prop, idx) => {
238
200
  return {
@@ -242,7 +204,6 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
242
204
  });
243
205
  return [undefined, flattenRoots(roots)];
244
206
  }
245
-
246
207
  if (['RestElement', 'ExperimentalRestProperty'].includes(param.type)) {
247
208
  return {
248
209
  isRestProperty: isProperty,
@@ -250,32 +211,28 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
250
211
  restElement: true
251
212
  };
252
213
  }
253
-
254
214
  if (param.type === 'TSParameterProperty') {
255
215
  return getParamName(param.parameter, true);
256
216
  }
257
-
258
217
  throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
259
218
  };
260
-
261
219
  if (!functionNode) {
262
220
  return [];
263
221
  }
264
-
265
222
  return (functionNode.params || ((_functionNode$value = functionNode.value) === null || _functionNode$value === void 0 ? void 0 : _functionNode$value.params) || []).map(param => {
266
223
  return getParamName(param);
267
224
  });
268
225
  };
226
+
269
227
  /**
270
228
  * @param {Node} functionNode
271
229
  * @returns {Integer}
272
230
  */
273
-
274
-
275
231
  const hasParams = functionNode => {
276
232
  // Should also check `functionNode.value.params` if supporting `MethodDefinition`
277
233
  return functionNode.params.length;
278
234
  };
235
+
279
236
  /**
280
237
  * Gets all names of the target type, including those that refer to a path, e.g.
281
238
  * "@param foo; @param foo.bar".
@@ -284,11 +241,8 @@ const hasParams = functionNode => {
284
241
  * @param {string} targetTagName
285
242
  * @returns {Array<object>}
286
243
  */
287
-
288
-
289
244
  const getJsdocTagsDeep = (jsdoc, targetTagName) => {
290
245
  const ret = [];
291
-
292
246
  for (const [idx, {
293
247
  name,
294
248
  tag,
@@ -297,35 +251,29 @@ const getJsdocTagsDeep = (jsdoc, targetTagName) => {
297
251
  if (tag !== targetTagName) {
298
252
  continue;
299
253
  }
300
-
301
254
  ret.push({
302
255
  idx,
303
256
  name,
304
257
  type
305
258
  });
306
259
  }
307
-
308
260
  return ret;
309
261
  };
310
-
311
262
  const modeWarnSettings = (0, _WarnSettings.default)();
263
+
312
264
  /**
313
265
  * @param {string} mode
314
266
  * @param context
315
267
  */
316
-
317
268
  const getTagNamesForMode = (mode, context) => {
318
269
  switch (mode) {
319
270
  case 'jsdoc':
320
271
  return _tagNames.jsdocTags;
321
-
322
272
  case 'typescript':
323
273
  return _tagNames.typeScriptTags;
324
-
325
274
  case 'closure':
326
275
  case 'permissive':
327
276
  return _tagNames.closureTags;
328
-
329
277
  default:
330
278
  if (!modeWarnSettings.hasBeenWarned(context, 'mode')) {
331
279
  context.report({
@@ -338,12 +286,13 @@ const getTagNamesForMode = (mode, context) => {
338
286
  message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.`
339
287
  });
340
288
  modeWarnSettings.markSettingAsWarned(context, 'mode');
341
- } // We'll avoid breaking too many other rules
342
-
289
+ }
343
290
 
291
+ // We'll avoid breaking too many other rules
344
292
  return _tagNames.jsdocTags;
345
293
  }
346
294
  };
295
+
347
296
  /**
348
297
  * @param context
349
298
  * @param {ParserMode} mode
@@ -351,43 +300,36 @@ const getTagNamesForMode = (mode, context) => {
351
300
  * @param {object} tagPreference
352
301
  * @returns {string|object}
353
302
  */
354
-
355
-
356
303
  const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
357
304
  var _Object$entries$find;
358
-
359
305
  const prefValues = Object.values(tagPreference);
360
-
361
306
  if (prefValues.includes(name) || prefValues.some(prefVal => {
362
307
  return prefVal && typeof prefVal === 'object' && prefVal.replacement === name;
363
308
  })) {
364
309
  return name;
365
- } // Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint
310
+ }
311
+
312
+ // Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint
366
313
  // that disallows keys that conflict with Object.prototype,
367
314
  // e.g. 'tag constructor' for 'constructor':
368
315
  // https://github.com/eslint/eslint/issues/13289
369
316
  // https://github.com/gajus/eslint-plugin-jsdoc/issues/537
370
-
371
-
372
317
  const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => {
373
318
  return [key.replace(/^tag /u, ''), value];
374
319
  }));
375
-
376
320
  if (Object.prototype.hasOwnProperty.call(tagPreferenceFixed, name)) {
377
321
  return tagPreferenceFixed[name];
378
322
  }
379
-
380
323
  const tagNames = getTagNamesForMode(mode, context);
381
324
  const preferredTagName = (_Object$entries$find = Object.entries(tagNames).find(([, aliases]) => {
382
325
  return aliases.includes(name);
383
326
  })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
384
-
385
327
  if (preferredTagName) {
386
328
  return preferredTagName;
387
329
  }
388
-
389
330
  return name;
390
331
  };
332
+
391
333
  /**
392
334
  * @param context
393
335
  * @param {ParserMode} mode
@@ -395,8 +337,6 @@ const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
395
337
  * @param {Array} definedTags
396
338
  * @returns {boolean}
397
339
  */
398
-
399
-
400
340
  const isValidTag = (context, mode, name, definedTags) => {
401
341
  const tagNames = getTagNamesForMode(mode, context);
402
342
  const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
@@ -404,31 +344,30 @@ const isValidTag = (context, mode, name, definedTags) => {
404
344
  const allTags = validTagNames.concat(additionalTags);
405
345
  return allTags.includes(name);
406
346
  };
347
+
407
348
  /**
408
349
  * @param {object} jsdoc
409
350
  * @param {string} targetTagName
410
351
  * @returns {boolean}
411
352
  */
412
-
413
-
414
353
  const hasTag = (jsdoc, targetTagName) => {
415
354
  const targetTagLower = targetTagName.toLowerCase();
416
355
  return jsdoc.tags.some(doc => {
417
356
  return doc.tag.toLowerCase() === targetTagLower;
418
357
  });
419
358
  };
359
+
420
360
  /**
421
361
  * @param {object} jsdoc
422
362
  * @param {Array} targetTagNames
423
363
  * @returns {boolean}
424
364
  */
425
-
426
-
427
365
  const hasATag = (jsdoc, targetTagNames) => {
428
366
  return targetTagNames.some(targetTagName => {
429
367
  return hasTag(jsdoc, targetTagName);
430
368
  });
431
369
  };
370
+
432
371
  /**
433
372
  * Checks if the JSDoc comment declares a defined type.
434
373
  *
@@ -437,44 +376,38 @@ const hasATag = (jsdoc, targetTagNames) => {
437
376
  * @returns {boolean}
438
377
  * true in case a defined type is declared; otherwise false.
439
378
  */
440
-
441
-
442
379
  const hasDefinedTypeTag = tag => {
443
380
  // The function should not continue in the event the type is not defined...
444
381
  if (typeof tag === 'undefined' || tag === null) {
445
382
  return false;
446
- } // .. same applies if it declares an `{undefined}` or `{void}` type
447
-
383
+ }
448
384
 
385
+ // .. same applies if it declares an `{undefined}` or `{void}` type
449
386
  const tagType = tag.type.trim();
450
-
451
387
  if (tagType === 'undefined' || tagType === 'void') {
452
388
  return false;
453
- } // In any other case, a type is present
454
-
389
+ }
455
390
 
391
+ // In any other case, a type is present
456
392
  return true;
457
393
  };
394
+
458
395
  /**
459
396
  * @param map
460
397
  * @param tag
461
398
  * @returns {Map}
462
399
  */
463
-
464
-
465
400
  const ensureMap = (map, tag) => {
466
401
  if (!map.has(tag)) {
467
402
  map.set(tag, new Map());
468
403
  }
469
-
470
404
  return map.get(tag);
471
405
  };
406
+
472
407
  /**
473
408
  * @param structuredTags
474
409
  * @param tagMap
475
410
  */
476
-
477
-
478
411
  const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
479
412
  for (const [tag, {
480
413
  name,
@@ -485,150 +418,131 @@ const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
485
418
  tagStruct.set('nameContents', name);
486
419
  tagStruct.set('typeAllowed', type);
487
420
  const requiredName = required.includes('name');
488
-
489
421
  if (requiredName && name === false) {
490
422
  throw new Error('Cannot add "name" to `require` with the tag\'s `name` set to `false`');
491
423
  }
492
-
493
424
  tagStruct.set('nameRequired', requiredName);
494
425
  const requiredType = required.includes('type');
495
-
496
426
  if (requiredType && type === false) {
497
427
  throw new Error('Cannot add "type" to `require` with the tag\'s `type` set to `false`');
498
428
  }
499
-
500
429
  tagStruct.set('typeRequired', requiredType);
501
430
  const typeOrNameRequired = required.includes('typeOrNameRequired');
502
-
503
431
  if (typeOrNameRequired && name === false) {
504
432
  throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `name` set to `false`');
505
433
  }
506
-
507
434
  if (typeOrNameRequired && type === false) {
508
435
  throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `type` set to `false`');
509
436
  }
510
-
511
437
  tagStruct.set('typeOrNameRequired', typeOrNameRequired);
512
438
  }
513
439
  };
440
+
514
441
  /**
515
442
  * @param mode
516
443
  * @param structuredTags
517
444
  * @returns {Map}
518
445
  */
519
-
520
-
521
446
  const getTagStructureForMode = (mode, structuredTags) => {
522
447
  const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode);
523
-
524
448
  try {
525
449
  overrideTagStructure(structuredTags, tagStruct);
526
- } catch {//
450
+ } catch {
451
+ //
527
452
  }
528
-
529
453
  return tagStruct;
530
454
  };
455
+
531
456
  /**
532
457
  * @param tag
533
458
  * @param {Map} tagMap
534
459
  * @returns {boolean}
535
460
  */
536
-
537
-
538
461
  const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
539
462
  const tagStruct = ensureMap(tagMap, tag);
540
463
  return tagStruct.get('nameContents') === 'namepath-defining';
541
464
  };
465
+
542
466
  /**
543
467
  * @param tag
544
468
  * @param {Map} tagMap
545
469
  * @returns {boolean}
546
470
  */
547
-
548
-
549
471
  const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
550
472
  const tagStruct = ensureMap(tagMap, tag);
551
473
  return tagStruct.get('typeRequired');
552
474
  };
475
+
553
476
  /**
554
477
  * @param tag
555
478
  * @param {Map} tagMap
556
479
  * @returns {boolean}
557
480
  */
558
-
559
-
560
481
  const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
561
482
  if (tagMustHaveTypePosition(tag, tagMap)) {
562
483
  return true;
563
484
  }
564
-
565
485
  const tagStruct = ensureMap(tagMap, tag);
566
486
  const ret = tagStruct.get('typeAllowed');
567
487
  return ret === undefined ? true : ret;
568
488
  };
569
-
570
489
  const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
490
+
571
491
  /**
572
492
  * @param tag
573
493
  * @param {Map} tagMap
574
494
  * @returns {boolean}
575
495
  */
576
-
577
496
  const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
578
497
  const tagStruct = ensureMap(tagMap, tag);
579
498
  const ret = tagStruct.get('nameContents');
580
499
  return ret === undefined ? true : Boolean(ret);
581
500
  };
501
+
582
502
  /**
583
503
  * @param tag
584
504
  * @param {Map} tagMap
585
505
  * @returns {boolean}
586
506
  */
587
-
588
-
589
507
  const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
590
508
  const tagStruct = ensureMap(tagMap, tag);
591
509
  return namepathTypes.has(tagStruct.get('nameContents'));
592
510
  };
511
+
593
512
  /**
594
513
  * @param tag
595
514
  * @param {Map} tagMap
596
515
  * @returns {boolean}
597
516
  */
598
-
599
-
600
517
  const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
601
518
  const tagStruct = ensureMap(tagMap, tag);
602
519
  return tagStruct.get('nameRequired');
603
520
  };
521
+
604
522
  /**
605
523
  * @param tag
606
524
  * @param {Map} tagMap
607
525
  * @returns {boolean}
608
526
  */
609
-
610
-
611
527
  const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
612
528
  return tagMightHaveTypePosition(tag, tagMap) || tagMightHaveNamepath(tag, tagMap);
613
529
  };
530
+
614
531
  /**
615
532
  * @param tag
616
533
  * @param {Map} tagMap
617
534
  * @returns {boolean}
618
535
  */
619
-
620
-
621
536
  const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
622
537
  const tagStruct = ensureMap(tagMap, tag);
623
538
  return tagStruct.get('typeOrNameRequired');
624
539
  };
540
+
625
541
  /**
626
542
  * @param tag
627
543
  * @param {Map} tagMap
628
544
  * @returns {boolean}
629
545
  */
630
-
631
-
632
546
  const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
633
547
  const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
634
548
  const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap);
@@ -637,14 +551,13 @@ const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
637
551
  const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap);
638
552
  const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && (hasTypePosition || hasNameOrNamepathPosition);
639
553
  return mustHaveEither && !hasEither && !mustHaveTypePosition;
640
- }; // eslint-disable-next-line complexity
641
-
554
+ };
642
555
 
556
+ // eslint-disable-next-line complexity
643
557
  const hasNonFunctionYield = (node, checkYieldReturnValue) => {
644
558
  if (!node) {
645
559
  return false;
646
560
  }
647
-
648
561
  switch (node.type) {
649
562
  case 'BlockStatement':
650
563
  {
@@ -652,20 +565,18 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
652
565
  return !['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(bodyNode.type) && hasNonFunctionYield(bodyNode, checkYieldReturnValue);
653
566
  });
654
567
  }
655
- // istanbul ignore next -- In Babel?
656
568
 
569
+ // istanbul ignore next -- In Babel?
657
570
  case 'OptionalCallExpression':
658
571
  case 'CallExpression':
659
572
  return node.arguments.some(element => {
660
573
  return hasNonFunctionYield(element, checkYieldReturnValue);
661
574
  });
662
-
663
575
  case 'ChainExpression':
664
576
  case 'ExpressionStatement':
665
577
  {
666
578
  return hasNonFunctionYield(node.expression, checkYieldReturnValue);
667
579
  }
668
-
669
580
  case 'LabeledStatement':
670
581
  case 'WhileStatement':
671
582
  case 'DoWhileStatement':
@@ -676,18 +587,15 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
676
587
  {
677
588
  return hasNonFunctionYield(node.body, checkYieldReturnValue);
678
589
  }
679
-
680
590
  case 'ConditionalExpression':
681
591
  case 'IfStatement':
682
592
  {
683
593
  return hasNonFunctionYield(node.test, checkYieldReturnValue) || hasNonFunctionYield(node.consequent, checkYieldReturnValue) || hasNonFunctionYield(node.alternate, checkYieldReturnValue);
684
594
  }
685
-
686
595
  case 'TryStatement':
687
596
  {
688
597
  return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(node.finalizer, checkYieldReturnValue);
689
598
  }
690
-
691
599
  case 'SwitchStatement':
692
600
  {
693
601
  return node.cases.some(someCase => {
@@ -696,130 +604,113 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
696
604
  });
697
605
  });
698
606
  }
699
-
700
607
  case 'ArrayPattern':
701
608
  case 'ArrayExpression':
702
609
  return node.elements.some(element => {
703
610
  return hasNonFunctionYield(element, checkYieldReturnValue);
704
611
  });
705
-
706
612
  case 'AssignmentPattern':
707
613
  return hasNonFunctionYield(node.right, checkYieldReturnValue);
708
-
709
614
  case 'VariableDeclaration':
710
615
  {
711
616
  return node.declarations.some(nde => {
712
617
  return hasNonFunctionYield(nde, checkYieldReturnValue);
713
618
  });
714
619
  }
715
-
716
620
  case 'VariableDeclarator':
717
621
  {
718
622
  return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue);
719
623
  }
720
-
721
624
  case 'AssignmentExpression':
722
625
  case 'BinaryExpression':
723
626
  case 'LogicalExpression':
724
627
  {
725
628
  return hasNonFunctionYield(node.left, checkYieldReturnValue) || hasNonFunctionYield(node.right, checkYieldReturnValue);
726
629
  }
727
- // Comma
728
630
 
631
+ // Comma
729
632
  case 'SequenceExpression':
730
633
  case 'TemplateLiteral':
731
634
  return node.expressions.some(subExpression => {
732
635
  return hasNonFunctionYield(subExpression, checkYieldReturnValue);
733
636
  });
734
-
735
637
  case 'ObjectPattern':
736
638
  case 'ObjectExpression':
737
639
  return node.properties.some(property => {
738
640
  return hasNonFunctionYield(property, checkYieldReturnValue);
739
641
  });
740
- // istanbul ignore next -- In Babel?
741
642
 
643
+ // istanbul ignore next -- In Babel?
742
644
  case 'PropertyDefinition':
743
645
  /* eslint-disable no-fallthrough */
744
646
  // istanbul ignore next -- In Babel?
745
-
746
- case 'ObjectProperty': // istanbul ignore next -- In Babel?
747
-
647
+ case 'ObjectProperty':
648
+ // istanbul ignore next -- In Babel?
748
649
  case 'ClassProperty':
749
650
  /* eslint-enable no-fallthrough */
750
-
751
651
  case 'Property':
752
652
  return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue);
753
653
  // istanbul ignore next -- In Babel?
754
-
755
654
  case 'ObjectMethod':
756
655
  // istanbul ignore next -- In Babel?
757
656
  return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || node.arguments.some(nde => {
758
657
  return hasNonFunctionYield(nde, checkYieldReturnValue);
759
658
  });
760
-
761
659
  case 'SpreadElement':
762
660
  case 'UnaryExpression':
763
661
  return hasNonFunctionYield(node.argument, checkYieldReturnValue);
764
-
765
662
  case 'TaggedTemplateExpression':
766
663
  return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
664
+
767
665
  // ?.
768
666
  // istanbul ignore next -- In Babel?
769
-
770
667
  case 'OptionalMemberExpression':
771
668
  case 'MemberExpression':
772
669
  return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue);
773
- // istanbul ignore next -- In Babel?
774
670
 
671
+ // istanbul ignore next -- In Babel?
775
672
  case 'Import':
776
673
  case 'ImportExpression':
777
674
  return hasNonFunctionYield(node.source, checkYieldReturnValue);
778
-
779
675
  case 'ReturnStatement':
780
676
  {
781
677
  if (node.argument === null) {
782
678
  return false;
783
679
  }
784
-
785
680
  return hasNonFunctionYield(node.argument, checkYieldReturnValue);
786
681
  }
787
-
788
682
  case 'YieldExpression':
789
683
  {
790
684
  if (checkYieldReturnValue) {
791
685
  if (node.parent.type === 'VariableDeclarator') {
792
686
  return true;
793
687
  }
794
-
795
688
  return false;
796
- } // void return does not count.
797
-
689
+ }
798
690
 
691
+ // void return does not count.
799
692
  if (node.argument === null) {
800
693
  return false;
801
694
  }
802
-
803
695
  return true;
804
696
  }
805
-
806
697
  default:
807
698
  {
808
699
  return false;
809
700
  }
810
701
  }
811
702
  };
703
+
812
704
  /**
813
705
  * Checks if a node has a return statement. Void return does not count.
814
706
  *
815
707
  * @param {object} node
816
708
  * @returns {boolean}
817
709
  */
818
-
819
-
820
710
  const hasYieldValue = (node, checkYieldReturnValue) => {
821
711
  return node.generator && (node.expression || hasNonFunctionYield(node.body, checkYieldReturnValue));
822
712
  };
713
+
823
714
  /**
824
715
  * Checks if a node has a throws statement.
825
716
  *
@@ -828,16 +719,14 @@ const hasYieldValue = (node, checkYieldReturnValue) => {
828
719
  * @returns {boolean}
829
720
  */
830
721
  // eslint-disable-next-line complexity
831
-
832
-
833
722
  const hasThrowValue = (node, innerFunction) => {
834
723
  if (!node) {
835
724
  return false;
836
- } // There are cases where a function may execute its inner function which
725
+ }
726
+
727
+ // There are cases where a function may execute its inner function which
837
728
  // throws, but we're treating functions atomically rather than trying to
838
729
  // follow them
839
-
840
-
841
730
  switch (node.type) {
842
731
  case 'FunctionExpression':
843
732
  case 'FunctionDeclaration':
@@ -845,14 +734,12 @@ const hasThrowValue = (node, innerFunction) => {
845
734
  {
846
735
  return !innerFunction && !node.async && hasThrowValue(node.body, true);
847
736
  }
848
-
849
737
  case 'BlockStatement':
850
738
  {
851
739
  return node.body.some(bodyNode => {
852
740
  return bodyNode.type !== 'FunctionDeclaration' && hasThrowValue(bodyNode);
853
741
  });
854
742
  }
855
-
856
743
  case 'LabeledStatement':
857
744
  case 'WhileStatement':
858
745
  case 'DoWhileStatement':
@@ -863,18 +750,16 @@ const hasThrowValue = (node, innerFunction) => {
863
750
  {
864
751
  return hasThrowValue(node.body);
865
752
  }
866
-
867
753
  case 'IfStatement':
868
754
  {
869
755
  return hasThrowValue(node.consequent) || hasThrowValue(node.alternate);
870
756
  }
871
- // We only consider it to throw an error if the catch or finally blocks throw an error.
872
757
 
758
+ // We only consider it to throw an error if the catch or finally blocks throw an error.
873
759
  case 'TryStatement':
874
760
  {
875
761
  return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer);
876
762
  }
877
-
878
763
  case 'SwitchStatement':
879
764
  {
880
765
  return node.cases.some(someCase => {
@@ -883,22 +768,20 @@ const hasThrowValue = (node, innerFunction) => {
883
768
  });
884
769
  });
885
770
  }
886
-
887
771
  case 'ThrowStatement':
888
772
  {
889
773
  return true;
890
774
  }
891
-
892
775
  default:
893
776
  {
894
777
  return false;
895
778
  }
896
779
  }
897
780
  };
781
+
898
782
  /**
899
783
  * @param {string} tag
900
784
  */
901
-
902
785
  /*
903
786
  const isInlineTag = (tag) => {
904
787
  return /^(@link|@linkcode|@linkplain|@tutorial) /u.test(tag);
@@ -913,13 +796,12 @@ const isInlineTag = (tag) => {
913
796
  * @param {JsDocTag} tag
914
797
  * @returns {Array<string>}
915
798
  */
916
-
917
-
918
799
  const parseClosureTemplateTag = tag => {
919
800
  return tag.name.split(',').map(type => {
920
801
  return type.trim().replace(/^\[(?<name>.*?)=.*\]$/u, '$<name>');
921
802
  });
922
803
  };
804
+
923
805
  /**
924
806
  * @typedef {true|string[]} DefaultContexts
925
807
  */
@@ -933,37 +815,32 @@ const parseClosureTemplateTag = tag => {
933
815
  * @param {DefaultContexts} defaultContexts
934
816
  * @returns {string[]}
935
817
  */
936
-
937
-
938
818
  const enforcedContexts = (context, defaultContexts) => {
939
819
  const {
940
820
  contexts = defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts
941
821
  } = context.options[0] || {};
942
822
  return contexts;
943
823
  };
824
+
944
825
  /**
945
826
  * @param {string[]} contexts
946
827
  * @param {Function} checkJsdoc
947
828
  * @param {Function} handler
948
829
  */
949
-
950
-
951
830
  const getContextObject = (contexts, checkJsdoc, handler) => {
952
831
  const properties = {};
953
-
954
832
  for (const [idx, prop] of contexts.entries()) {
955
833
  let property;
956
834
  let value;
957
-
958
835
  if (typeof prop === 'object') {
959
836
  const selInfo = {
960
837
  lastIndex: idx,
961
838
  selector: prop.context
962
839
  };
963
-
964
840
  if (prop.comment) {
965
841
  property = prop.context;
966
- value = checkJsdoc.bind(null, { ...selInfo,
842
+ value = checkJsdoc.bind(null, {
843
+ ...selInfo,
967
844
  comment: prop.comment
968
845
  }, handler.bind(null, prop.comment));
969
846
  } else {
@@ -978,26 +855,22 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
978
855
  property = prop;
979
856
  value = checkJsdoc.bind(null, selInfo, null);
980
857
  }
981
-
982
858
  const old = properties[property];
983
859
  properties[property] = old ? function (...args) {
984
860
  old(...args);
985
861
  value(...args);
986
862
  } : value;
987
863
  }
988
-
989
864
  return properties;
990
865
  };
991
-
992
866
  const filterTags = (tags, filter) => {
993
867
  return tags.filter(tag => {
994
868
  return filter(tag);
995
869
  });
996
870
  };
997
-
998
- const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'property', 'prop', 'template', // These two are parsed by our custom parser as though having a `name`
871
+ const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'property', 'prop', 'template',
872
+ // These two are parsed by our custom parser as though having a `name`
999
873
  'returns', 'return']);
1000
-
1001
874
  const getTagsByType = (context, mode, tags, tagPreference) => {
1002
875
  const descName = getPreferredTagName(context, mode, 'description', tagPreference);
1003
876
  const tagsWithoutNames = [];
@@ -1006,11 +879,9 @@ const getTagsByType = (context, mode, tags, tagPreference) => {
1006
879
  tag: tagName
1007
880
  } = tag;
1008
881
  const tagWithName = tagsWithNamesAndDescriptions.has(tagName);
1009
-
1010
882
  if (!tagWithName && tagName !== descName) {
1011
883
  tagsWithoutNames.push(tag);
1012
884
  }
1013
-
1014
885
  return tagWithName;
1015
886
  });
1016
887
  return {
@@ -1018,31 +889,22 @@ const getTagsByType = (context, mode, tags, tagPreference) => {
1018
889
  tagsWithoutNames
1019
890
  };
1020
891
  };
1021
-
1022
892
  const getIndent = sourceCode => {
1023
893
  var _sourceCode$text$matc;
1024
-
1025
894
  return (((_sourceCode$text$matc = sourceCode.text.match(/^\n*([ \t]+)/u)) === null || _sourceCode$text$matc === void 0 ? void 0 : _sourceCode$text$matc[1]) ?? '') + ' ';
1026
895
  };
1027
-
1028
896
  const isConstructor = node => {
1029
897
  var _node$parent;
1030
-
1031
898
  return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || (node === null || node === void 0 ? void 0 : (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor';
1032
899
  };
1033
-
1034
900
  const isGetter = node => {
1035
901
  var _node$parent2;
1036
-
1037
902
  return node && ((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.kind) === 'get';
1038
903
  };
1039
-
1040
904
  const isSetter = node => {
1041
905
  var _node$parent3;
1042
-
1043
906
  return node && ((_node$parent3 = node.parent) === null || _node$parent3 === void 0 ? void 0 : _node$parent3.kind) === 'set';
1044
907
  };
1045
-
1046
908
  const hasAccessorPair = node => {
1047
909
  const {
1048
910
  type,
@@ -1062,19 +924,17 @@ const hasAccessorPair = node => {
1062
924
  return kind === oppositeKind && name === sourceName;
1063
925
  });
1064
926
  };
1065
-
1066
927
  const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1067
928
  const hasSchemaOption = prop => {
1068
929
  var _context$options$;
1069
-
1070
930
  const schemaProperties = schema[0].properties;
1071
931
  return ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$[prop]) ?? (schemaProperties[prop] && schemaProperties[prop].default);
1072
932
  };
1073
-
1074
933
  const checkGetters = hasSchemaOption('checkGetters');
1075
934
  const checkSetters = hasSchemaOption('checkSetters');
1076
935
  return !hasSchemaOption('checkConstructors') && (isConstructor(node) || hasATag(jsdoc, ['class', 'constructor'])) || isGetter(node) && (!checkGetters || checkGetters === 'no-setter' && hasAccessorPair(node.parent)) || isSetter(node) && (!checkSetters || checkSetters === 'no-getter' && hasAccessorPair(node.parent));
1077
936
  };
937
+
1078
938
  /**
1079
939
  * Since path segments may be unquoted (if matching a reserved word,
1080
940
  * identifier or numeric literal) or single or double quoted, in either
@@ -1084,57 +944,48 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1084
944
  * @param {string} str
1085
945
  * @returns {string}
1086
946
  */
1087
-
1088
-
1089
947
  const dropPathSegmentQuotes = str => {
1090
948
  return str.replace(/\.(['"])(.*)\1/gu, '.$2');
1091
949
  };
950
+
1092
951
  /**
1093
952
  * @param {string} name
1094
953
  * @returns {(otherPathName: string) => void}
1095
954
  */
1096
-
1097
-
1098
955
  const comparePaths = name => {
1099
956
  return otherPathName => {
1100
957
  return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
1101
958
  };
1102
959
  };
960
+
1103
961
  /**
1104
962
  * @param {string} name
1105
963
  * @param {string} otherPathName
1106
964
  * @returns {boolean}
1107
965
  */
1108
-
1109
-
1110
966
  const pathDoesNotBeginWith = (name, otherPathName) => {
1111
967
  return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1112
968
  };
969
+
1113
970
  /**
1114
971
  * @param {string} regexString
1115
972
  * @param {string} requiredFlags
1116
973
  * @returns {RegExp}
1117
974
  */
1118
-
1119
-
1120
975
  const getRegexFromString = (regexString, requiredFlags) => {
1121
976
  const match = regexString.match(/^\/(.*)\/([gimyus]*)$/us);
1122
977
  let flags = 'u';
1123
978
  let regex = regexString;
1124
-
1125
979
  if (match) {
1126
980
  [, regex, flags] = match;
1127
-
1128
981
  if (!flags) {
1129
982
  flags = 'u';
1130
983
  }
1131
984
  }
1132
-
1133
985
  const uniqueFlags = [...new Set(flags + (requiredFlags || ''))];
1134
986
  flags = uniqueFlags.join('');
1135
987
  return new RegExp(regex, flags);
1136
988
  };
1137
-
1138
989
  var _default = {
1139
990
  comparePaths,
1140
991
  dropPathSegmentQuotes,