@dereekb/firebase 13.12.2 → 13.12.3

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.
@@ -1,1133 +1,10 @@
1
+ import { leadingJsdocFor, parseJsdocComment, getStatementAnchor, findFamilyTags, checkDbxTagFamily, reportOnJsdocLine, parseBooleanTagValue, buildLowercaseTagsFix } from '@dereekb/util/eslint';
1
2
  import { createRequire } from 'node:module';
2
3
  import { existsSync, readFileSync, globSync } from 'node:fs';
3
4
  import { join, dirname, isAbsolute, resolve } from 'node:path';
4
5
  import { parse as parse$1 } from '@typescript-eslint/typescript-estree';
5
6
  import { parse as parse$2 } from '@typescript-eslint/parser';
6
7
 
7
- /**
8
- * Returns the outermost statement node for a FunctionDeclaration — its `ExportNamedDeclaration`
9
- * or `ExportDefaultDeclaration` parent if exported, otherwise the declaration itself. This is the
10
- * node ESLint attaches leading comments to.
11
- *
12
- * @param node - The FunctionDeclaration AST node.
13
- * @returns The statement node ESLint attaches leading comments to.
14
- */ function getStatementAnchor(node) {
15
- return node.parent && (node.parent.type === 'ExportNamedDeclaration' || node.parent.type === 'ExportDefaultDeclaration') ? node.parent : node;
16
- }
17
- /**
18
- * Returns the JSDoc Block comment immediately preceding `anchor`, or `null` when
19
- * the anchor has no JSDoc leader. Used by the `@dbx<Family>` companion-tag rules
20
- * to locate the tagged declaration's documentation.
21
- *
22
- * @param sourceCode - The ESLint `SourceCode` object.
23
- * @param anchor - The statement-level node ESLint attaches leading comments to.
24
- * @returns The JSDoc block comment, or null when none is present.
25
- */ function leadingJsdocFor(sourceCode, anchor) {
26
- var comments = sourceCode.getCommentsBefore(anchor) || [];
27
- var result = null;
28
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
29
- try {
30
- for(var _iterator = comments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
31
- var comment = _step.value;
32
- if (comment.type === 'Block' && typeof comment.value === 'string' && comment.value.startsWith('*')) {
33
- result = comment;
34
- }
35
- }
36
- } catch (err) {
37
- _didIteratorError = true;
38
- _iteratorError = err;
39
- } finally{
40
- try {
41
- if (!_iteratorNormalCompletion && _iterator.return != null) {
42
- _iterator.return();
43
- }
44
- } finally{
45
- if (_didIteratorError) {
46
- throw _iteratorError;
47
- }
48
- }
49
- }
50
- return result;
51
- }
52
-
53
- /**
54
- * Default maximum positional parameters before the warn-level rule suggests a config object.
55
- * Triggers a warning when a function has more than 2 positional parameters (i.e. 3+ args).
56
- */ var DEFAULT_MAX_PARAMS_WARN = 2;
57
- /**
58
- * Default maximum positional parameters before the hard-error rule rejects the signature.
59
- * Triggers an error when a function has more than 4 positional parameters (i.e. 5+ args).
60
- */ var DEFAULT_MAX_PARAMS_HARD = 4;
61
- /**
62
- * Default JSDoc tag that opts a function out of this rule.
63
- */ var DEFAULT_ALLOW_JSDOC_TAG = '@dbxAllowMultiParams';
64
- /**
65
- * Returns a human-readable display name for the function-like node, or `<anonymous>`.
66
- *
67
- * @param node - The function-like AST node.
68
- * @returns The identifier string used in diagnostic messages.
69
- */ function getFunctionDisplayName(node) {
70
- var _node_id;
71
- var name = '<anonymous>';
72
- if (((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.type) === 'Identifier') {
73
- name = node.id.name;
74
- } else if (node.parent) {
75
- var _parent_id, _parent_key, _parent_key1, _parent_left;
76
- var parent = node.parent;
77
- if (parent.type === 'VariableDeclarator' && ((_parent_id = parent.id) === null || _parent_id === void 0 ? void 0 : _parent_id.type) === 'Identifier') {
78
- name = parent.id.name;
79
- } else if (parent.type === 'Property' && ((_parent_key = parent.key) === null || _parent_key === void 0 ? void 0 : _parent_key.type) === 'Identifier') {
80
- name = parent.key.name;
81
- } else if (parent.type === 'MethodDefinition' && ((_parent_key1 = parent.key) === null || _parent_key1 === void 0 ? void 0 : _parent_key1.type) === 'Identifier') {
82
- name = parent.key.name;
83
- } else if (parent.type === 'AssignmentExpression' && ((_parent_left = parent.left) === null || _parent_left === void 0 ? void 0 : _parent_left.type) === 'Identifier') {
84
- name = parent.left.name;
85
- }
86
- }
87
- return name;
88
- }
89
- /**
90
- * Returns true if a parameter has any decorators (NestJS handler/Inject pattern).
91
- *
92
- * @param param - The parameter AST node.
93
- * @returns True when the parameter carries at least one decorator.
94
- */ function paramHasDecorator(param) {
95
- var _param_decorators;
96
- var decorators = (_param_decorators = param.decorators) !== null && _param_decorators !== void 0 ? _param_decorators : [];
97
- return Array.isArray(decorators) && decorators.length > 0;
98
- }
99
- /**
100
- * Returns true when the function is the constructor of a class.
101
- *
102
- * @param node - The function-like AST node.
103
- * @returns True if `node` is the `constructor` body of a class.
104
- */ function isConstructor(node) {
105
- var _node_parent;
106
- return ((_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.type) === 'MethodDefinition' && node.parent.kind === 'constructor';
107
- }
108
- /**
109
- * Returns true if any leading JSDoc block above `anchor` contains the allow tag.
110
- *
111
- * @param sourceCode - The ESLint `SourceCode` instance.
112
- * @param anchor - The AST node whose leading comments are scanned.
113
- * @param allowTag - The JSDoc tag string that opts the function out.
114
- * @returns True when a JSDoc with the allow tag is present.
115
- */ function hasAllowJsdoc(sourceCode, anchor, allowTag) {
116
- var comments = sourceCode.getCommentsBefore(anchor) || [];
117
- var allow = false;
118
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
119
- try {
120
- for(var _iterator = comments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
121
- var comment = _step.value;
122
- if (comment.type === 'Block' && comment.value.startsWith('*') && comment.value.includes(allowTag)) {
123
- allow = true;
124
- }
125
- }
126
- } catch (err) {
127
- _didIteratorError = true;
128
- _iteratorError = err;
129
- } finally{
130
- try {
131
- if (!_iteratorNormalCompletion && _iterator.return != null) {
132
- _iterator.return();
133
- }
134
- } finally{
135
- if (_didIteratorError) {
136
- throw _iteratorError;
137
- }
138
- }
139
- }
140
- return allow;
141
- }
142
- /**
143
- * Builds a prefer-config-object-style rule with a configurable default `maxParams` threshold.
144
- * Class constructors and decorated parameters (e.g. NestJS `@Inject`) are exempted. Functions can
145
- * opt out via a leading JSDoc block carrying the configured allow tag (default `@dbxAllowMultiParams`).
146
- *
147
- * @param config - Default threshold and rule description.
148
- * @returns A complete ESLint rule definition that emits `tooManyParams` reports.
149
- */ function createPreferConfigObjectRule(config) {
150
- return {
151
- meta: {
152
- type: 'suggestion',
153
- docs: {
154
- description: config.description,
155
- recommended: true
156
- },
157
- messages: {
158
- tooManyParams: "Function '{{name}}' takes {{count}} positional parameters; use a single config object instead (see dbx__note__typescript-programming → Prefer Single Config Object)."
159
- },
160
- schema: [
161
- {
162
- type: 'object',
163
- properties: {
164
- maxParams: {
165
- type: 'number',
166
- minimum: 0,
167
- description: 'Maximum number of positional parameters before the rule fires.'
168
- },
169
- allowJsdocTag: {
170
- type: 'string',
171
- description: 'JSDoc tag that opts a function out of this rule.'
172
- }
173
- },
174
- additionalProperties: false
175
- }
176
- ]
177
- },
178
- create: function create(context) {
179
- var _context_options_, _options_maxParams, _options_allowJsdocTag;
180
- var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
181
- var maxParams = (_options_maxParams = options.maxParams) !== null && _options_maxParams !== void 0 ? _options_maxParams : config.defaultMaxParams;
182
- var allowTag = (_options_allowJsdocTag = options.allowJsdocTag) !== null && _options_allowJsdocTag !== void 0 ? _options_allowJsdocTag : DEFAULT_ALLOW_JSDOC_TAG;
183
- var sourceCode = context.sourceCode;
184
- function checkFunction(node) {
185
- if (!isConstructor(node)) {
186
- var _node_params;
187
- var params = (_node_params = node.params) !== null && _node_params !== void 0 ? _node_params : [];
188
- // Decorated parameters indicate framework-driven signatures (NestJS handlers, Angular DI inside
189
- // constructors which we already skip — but standalone decorated functions exist too).
190
- if (!params.some(paramHasDecorator) && params.length > maxParams) {
191
- var _node_parent, _node_parent_parent;
192
- // Anchor for JSDoc lookup: prefer the enclosing export statement, then a VariableDeclaration
193
- // (for `const fn = () => ...`), otherwise the function node itself.
194
- var anchor = node;
195
- if (((_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.type) === 'VariableDeclarator' && ((_node_parent_parent = node.parent.parent) === null || _node_parent_parent === void 0 ? void 0 : _node_parent_parent.type) === 'VariableDeclaration') {
196
- anchor = node.parent.parent;
197
- }
198
- if (anchor.parent && (anchor.parent.type === 'ExportNamedDeclaration' || anchor.parent.type === 'ExportDefaultDeclaration')) {
199
- anchor = anchor.parent;
200
- }
201
- if (!hasAllowJsdoc(sourceCode, anchor, allowTag)) {
202
- var _node_id;
203
- var name = getFunctionDisplayName(node);
204
- context.report({
205
- node: (_node_id = node.id) !== null && _node_id !== void 0 ? _node_id : node,
206
- messageId: 'tooManyParams',
207
- data: {
208
- name: name,
209
- count: String(params.length)
210
- }
211
- });
212
- }
213
- }
214
- }
215
- }
216
- return {
217
- FunctionDeclaration: checkFunction,
218
- FunctionExpression: checkFunction,
219
- ArrowFunctionExpression: checkFunction
220
- };
221
- }
222
- };
223
- }
224
- /**
225
- * ESLint rule recommending a single config object when a function takes more than two positional
226
- * parameters (default `maxParams: 2`, i.e. fires at 3+ args). Intended to be configured at the
227
- * `warn` severity. Pair with `prefer-config-object-hard` for a stricter cap.
228
- *
229
- * @see `dbx__note__typescript-programming` → Prefer Single Config Object
230
- */ createPreferConfigObjectRule({
231
- defaultMaxParams: DEFAULT_MAX_PARAMS_WARN,
232
- description: 'Prefer a single config object when a function takes more than two positional parameters.'
233
- });
234
- /**
235
- * Hard-stop variant of `prefer-config-object`. Fires when a function takes more than four positional
236
- * parameters (default `maxParams: 4`, i.e. fires at 5+ args). Intended to be configured at the
237
- * `error` severity so genuinely unwieldy signatures break the build even when the softer warn-level
238
- * rule is disabled or downgraded.
239
- *
240
- * @see `dbx__note__typescript-programming` → Prefer Single Config Object
241
- */ createPreferConfigObjectRule({
242
- defaultMaxParams: DEFAULT_MAX_PARAMS_HARD,
243
- description: 'Reject function signatures with more than four positional parameters; require a single config object.'
244
- });
245
-
246
- function _array_like_to_array$h(arr, len) {
247
- if (len == null || len > arr.length) len = arr.length;
248
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
249
- return arr2;
250
- }
251
- function _array_with_holes$a(arr) {
252
- if (Array.isArray(arr)) return arr;
253
- }
254
- function _iterable_to_array_limit$a(arr, i) {
255
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
256
- if (_i == null) return;
257
- var _arr = [];
258
- var _n = true;
259
- var _d = false;
260
- var _s, _e;
261
- try {
262
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
263
- _arr.push(_s.value);
264
- if (i && _arr.length === i) break;
265
- }
266
- } catch (err) {
267
- _d = true;
268
- _e = err;
269
- } finally{
270
- try {
271
- if (!_n && _i["return"] != null) _i["return"]();
272
- } finally{
273
- if (_d) throw _e;
274
- }
275
- }
276
- return _arr;
277
- }
278
- function _non_iterable_rest$a() {
279
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
280
- }
281
- function _sliced_to_array$a(arr, i) {
282
- return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$a();
283
- }
284
- function _unsupported_iterable_to_array$h(o, minLen) {
285
- if (!o) return;
286
- if (typeof o === "string") return _array_like_to_array$h(o, minLen);
287
- var n = Object.prototype.toString.call(o).slice(8, -1);
288
- if (n === "Object" && o.constructor) n = o.constructor.name;
289
- if (n === "Map" || n === "Set") return Array.from(n);
290
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
291
- }
292
- var TAG_LINE_REGEX = /^@([A-Za-z_]\w*)\s*(.*)$/;
293
- var TYPE_ANNOTATION_REGEX = /^\{([^}]*)\}\s*(.*)$/;
294
- var PARAM_NAME_REGEX = /^([A-Za-z_$][A-Za-z0-9_$.[\]]*)\s*(.*)$/;
295
- var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
296
- /**
297
- * Strips the leading whitespace + `*` + optional space prefix from a JSDoc body line and reports the length stripped.
298
- *
299
- * @param raw - The raw line as it appears in `comment.value`.
300
- * @returns A `{ text, prefixLength }` pair.
301
- *
302
- * @example
303
- * ```ts
304
- * stripPrefix(' * @param x - desc'); // { text: '@param x - desc', prefixLength: 3 }
305
- * stripPrefix(' *'); // { text: '', prefixLength: 2 }
306
- * stripPrefix('* hello'); // { text: 'hello', prefixLength: 2 }
307
- * ```
308
- */ function stripPrefix(raw) {
309
- var match = LINE_PREFIX_REGEX.exec(raw);
310
- var result = {
311
- text: raw,
312
- prefixLength: 0
313
- };
314
- if (match) {
315
- result.text = match[2];
316
- result.prefixLength = match[1].length;
317
- }
318
- return result;
319
- }
320
- /**
321
- * Splits the raw comment value into per-line views with prefix/offset metadata.
322
- *
323
- * @param commentValue - The `value` of an ESLint Block comment.
324
- * @returns Array of parsed line records in source order.
325
- */ function buildParsedLines(commentValue) {
326
- var rawLines = commentValue.split('\n');
327
- var runningOffset = 0;
328
- return rawLines.map(function(raw, index) {
329
- var _stripPrefix = stripPrefix(raw), stripped = _stripPrefix.text, prefixLength = _stripPrefix.prefixLength;
330
- var text = stripped.trimEnd();
331
- var blank = text.length === 0;
332
- var valueOffsetStart = runningOffset;
333
- var textOffsetStart = runningOffset + prefixLength;
334
- runningOffset += raw.length + 1; // +1 for the consumed `\n` (overshoots on last line, harmless)
335
- return {
336
- raw: raw,
337
- text: text,
338
- blank: blank,
339
- index: index,
340
- valueOffsetStart: valueOffsetStart,
341
- textOffsetStart: textOffsetStart
342
- };
343
- });
344
- }
345
- /**
346
- * Computes, per line, whether it sits inside a fenced code block (a ```` ``` ```` block, typically
347
- * an `@example` body) and therefore must not be treated as a tag boundary. Fence delimiter lines
348
- * themselves are flagged too. Without this, `@`-prefixed lines inside a fence — decorators like
349
- * `@Global()` / `@Module()`, or JSDoc snippets — would be mis-parsed as standalone JSDoc tags.
350
- *
351
- * @param lines - Parsed lines in source order.
352
- * @returns Boolean mask where `true` marks a line that must not start a tag.
353
- */ function computeFenceMask(lines) {
354
- var mask = lines.map(function() {
355
- return false;
356
- });
357
- var fenceOpen = false;
358
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
359
- try {
360
- for(var _iterator = lines.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
361
- var _step_value = _sliced_to_array$a(_step.value, 2), i = _step_value[0], line = _step_value[1];
362
- var isDelimiter = line.text.trimStart().startsWith('```');
363
- if (isDelimiter) {
364
- mask[i] = true;
365
- fenceOpen = !fenceOpen;
366
- } else {
367
- mask[i] = fenceOpen;
368
- }
369
- }
370
- } catch (err) {
371
- _didIteratorError = true;
372
- _iteratorError = err;
373
- } finally{
374
- try {
375
- if (!_iteratorNormalCompletion && _iterator.return != null) {
376
- _iterator.return();
377
- }
378
- } finally{
379
- if (_didIteratorError) {
380
- throw _iteratorError;
381
- }
382
- }
383
- }
384
- return mask;
385
- }
386
- /**
387
- * Returns true when the line at `index` opens a JSDoc tag and is not masked out by a code fence.
388
- *
389
- * @param lines - Parsed lines in source order.
390
- * @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
391
- * @param index - Line index to test.
392
- * @returns True when the line begins a tag that should be treated as a tag boundary.
393
- */ function isTagStart(lines, fenceMask, index) {
394
- return !fenceMask[index] && TAG_LINE_REGEX.test(lines[index].text);
395
- }
396
- /**
397
- * Returns the index of the first line that begins with a JSDoc `@tag`, or `-1` when none exists.
398
- *
399
- * @param lines - Parsed lines in source order.
400
- * @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
401
- * @returns Zero-based line index of the first tag, or `-1` when no tag is present.
402
- */ function findFirstTagIndex(lines, fenceMask) {
403
- var firstTagIndex = -1;
404
- for(var i = 0; i < lines.length; i += 1){
405
- if (isTagStart(lines, fenceMask, i)) {
406
- firstTagIndex = i;
407
- break;
408
- }
409
- }
410
- return firstTagIndex;
411
- }
412
- /**
413
- * Trims leading and trailing blank lines from a contiguous run of description lines.
414
- *
415
- * @param descriptionLines - Description-section lines before any tag.
416
- * @returns Sub-array with surrounding blank lines stripped.
417
- */ function trimBlankBoundaries(descriptionLines) {
418
- var descStart = 0;
419
- var descEnd = descriptionLines.length;
420
- while(descStart < descEnd && descriptionLines[descStart].blank)descStart += 1;
421
- while(descEnd > descStart && descriptionLines[descEnd - 1].blank)descEnd -= 1;
422
- return descriptionLines.slice(descStart, descEnd);
423
- }
424
- /**
425
- * Splits the trimmed description lines into paragraphs separated by blank-line runs.
426
- *
427
- * @param trimmedDescription - Description lines with surrounding blank lines removed.
428
- * @returns Paragraph strings joined by `\n`.
429
- */ function buildDescriptionParagraphs(trimmedDescription) {
430
- var descriptionParagraphs = [];
431
- var paragraphBuffer = [];
432
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
433
- try {
434
- for(var _iterator = trimmedDescription[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
435
- var line = _step.value;
436
- if (line.blank) {
437
- if (paragraphBuffer.length > 0) {
438
- descriptionParagraphs.push(paragraphBuffer.join('\n'));
439
- paragraphBuffer = [];
440
- }
441
- } else {
442
- paragraphBuffer.push(line.text);
443
- }
444
- }
445
- } catch (err) {
446
- _didIteratorError = true;
447
- _iteratorError = err;
448
- } finally{
449
- try {
450
- if (!_iteratorNormalCompletion && _iterator.return != null) {
451
- _iterator.return();
452
- }
453
- } finally{
454
- if (_didIteratorError) {
455
- throw _iteratorError;
456
- }
457
- }
458
- }
459
- if (paragraphBuffer.length > 0) {
460
- descriptionParagraphs.push(paragraphBuffer.join('\n'));
461
- }
462
- return descriptionParagraphs;
463
- }
464
- /**
465
- * Pulls an optional `{Type}` annotation off the front of a tag remainder.
466
- *
467
- * @param remainder - The tag-line text after the `@tagName` prefix.
468
- * @returns The annotation (or `undefined`) plus the remaining text.
469
- */ function extractTypeAnnotation(remainder) {
470
- var type;
471
- var rest = remainder;
472
- var typeMatch = TYPE_ANNOTATION_REGEX.exec(remainder);
473
- if (typeMatch) {
474
- type = typeMatch[1];
475
- rest = typeMatch[2];
476
- }
477
- return {
478
- type: type,
479
- rest: rest
480
- };
481
- }
482
- /**
483
- * Pulls an optional parameter name off the front of a `@param` tag remainder.
484
- *
485
- * @param tagName - Tag name (only `'param'` extracts a name; other tags pass through).
486
- * @param remainder - The tag-line text after the optional `{Type}` annotation.
487
- * @returns The parameter name (or `undefined`) plus the remaining text.
488
- */ function extractParamName(tagName, remainder) {
489
- var name;
490
- var rest = remainder;
491
- if (tagName === 'param') {
492
- var nameMatch = PARAM_NAME_REGEX.exec(remainder);
493
- if (nameMatch) {
494
- name = nameMatch[1];
495
- rest = nameMatch[2];
496
- }
497
- }
498
- return {
499
- name: name,
500
- rest: rest
501
- };
502
- }
503
- /**
504
- * Collects the tag line at `startIndex` plus every following non-tag continuation line.
505
- *
506
- * @param lines - All parsed lines in the comment.
507
- * @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
508
- * @param startIndex - Index of the `@tag` opening line.
509
- * @returns The collected tag lines and the index of the next unconsumed line.
510
- */ function collectTagLines(lines, fenceMask, startIndex) {
511
- var tagLines = [
512
- lines[startIndex]
513
- ];
514
- var j = startIndex + 1;
515
- while(j < lines.length){
516
- if (isTagStart(lines, fenceMask, j)) break;
517
- tagLines.push(lines[j]);
518
- j += 1;
519
- }
520
- return {
521
- tagLines: tagLines,
522
- nextIndex: j
523
- };
524
- }
525
- /**
526
- * Joins the on-line remainder and continuation-line text into a tag description, dropping trailing
527
- * blank lines while preserving interior blanks.
528
- *
529
- * @param remainder - The on-line remainder after stripping `@tagName {Type} name`.
530
- * @param tagLines - All lines that belong to the tag (including the header line at index 0).
531
- * @returns Description text joined by `\n`.
532
- */ function buildTagDescription(remainder, tagLines) {
533
- var descriptionParts = [];
534
- if (remainder.length > 0) descriptionParts.push(remainder);
535
- for(var k = 1; k < tagLines.length; k += 1){
536
- descriptionParts.push(tagLines[k].text);
537
- }
538
- while(descriptionParts.length > 0 && descriptionParts.at(-1).trim().length === 0){
539
- descriptionParts.pop();
540
- }
541
- return descriptionParts.join('\n');
542
- }
543
- /**
544
- * Builds a single parsed-tag record starting at `startIndex` in the line array.
545
- *
546
- * @param lines - All parsed lines in the comment.
547
- * @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
548
- * @param startIndex - Index of the `@tag` opening line.
549
- * @returns The parsed tag and the next unconsumed line index.
550
- */ function parseTagAt(lines, fenceMask, startIndex) {
551
- var line = lines[startIndex];
552
- var match = TAG_LINE_REGEX.exec(line.text);
553
- var tagName = match[1];
554
- var _extractTypeAnnotation = extractTypeAnnotation(match[2]), type = _extractTypeAnnotation.type, afterType = _extractTypeAnnotation.rest;
555
- var _extractParamName = extractParamName(tagName, afterType), name = _extractParamName.name, afterName = _extractParamName.rest;
556
- var _collectTagLines = collectTagLines(lines, fenceMask, startIndex), tagLines = _collectTagLines.tagLines, nextIndex = _collectTagLines.nextIndex;
557
- var description = buildTagDescription(afterName, tagLines);
558
- return {
559
- tag: {
560
- tag: tagName,
561
- name: name,
562
- type: type,
563
- description: description,
564
- lines: tagLines,
565
- startLineIndex: startIndex,
566
- endLineIndex: nextIndex - 1
567
- },
568
- nextIndex: nextIndex
569
- };
570
- }
571
- /**
572
- * Parses every `@tag` block starting from `firstTagIndex` to the end of the line array.
573
- *
574
- * @param lines - All parsed lines in the comment.
575
- * @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
576
- * @param firstTagIndex - Index where tag parsing should begin (`-1` skips entirely).
577
- * @returns All parsed tags in source order.
578
- */ function parseTags(lines, fenceMask, firstTagIndex) {
579
- var tags = [];
580
- if (firstTagIndex !== -1) {
581
- var i = firstTagIndex;
582
- while(i < lines.length){
583
- if (!isTagStart(lines, fenceMask, i)) {
584
- i += 1;
585
- continue;
586
- }
587
- var _parseTagAt = parseTagAt(lines, fenceMask, i), tag = _parseTagAt.tag, nextIndex = _parseTagAt.nextIndex;
588
- tags.push(tag);
589
- i = nextIndex;
590
- }
591
- }
592
- return tags;
593
- }
594
- /**
595
- * Parses the value of an ESLint Block comment that represents a JSDoc into a structured form.
596
- *
597
- * @param commentValue - The `value` of an ESLint Block comment (text between `/*` and `*\/`, including the leading `*`).
598
- * @returns A structured view of the JSDoc with description, paragraphs, and tags.
599
- *
600
- * @example
601
- * ```ts
602
- * const parsed = parseJsdocComment('*\n * Hello.\n *\n * @param x - The value.\n ');
603
- * // parsed.description === 'Hello.'
604
- * // parsed.tags[0].tag === 'param'
605
- * // parsed.tags[0].name === 'x'
606
- * // parsed.tags[0].description === 'The value.'
607
- * ```
608
- */ function parseJsdocComment(commentValue) {
609
- var singleLine = !commentValue.includes('\n');
610
- var lines = buildParsedLines(commentValue);
611
- var fenceMask = computeFenceMask(lines);
612
- var firstTagIndex = findFirstTagIndex(lines, fenceMask);
613
- var descriptionLines = firstTagIndex === -1 ? lines.slice() : lines.slice(0, firstTagIndex);
614
- var trimmedDescription = trimBlankBoundaries(descriptionLines);
615
- var description = trimmedDescription.map(function(l) {
616
- return l.text;
617
- }).join('\n');
618
- var descriptionParagraphs = buildDescriptionParagraphs(trimmedDescription);
619
- var tags = parseTags(lines, fenceMask, firstTagIndex);
620
- return {
621
- lines: lines,
622
- descriptionLines: descriptionLines,
623
- description: description,
624
- descriptionParagraphs: descriptionParagraphs,
625
- tags: tags,
626
- singleLine: singleLine
627
- };
628
- }
629
-
630
- /**
631
- * Shared helpers for the `@dbx<Family>` companion-tag ESLint rules. Mirrors the
632
- * scanner schemas in `packages/dbx-cli/src/lib/mcp-scan/scan/*-extract.ts` so
633
- * violations surface at lint time instead of at manifest-regeneration time.
634
- *
635
- * Each per-family rule supplies a {@link DbxTagFamilySpec} describing which
636
- * companions are required/optional, what value format each accepts, and which
637
- * messageId to emit when a check fails. The rule body itself only wires the
638
- * visitors and message map; all value-format validation lives here.
639
- */ function _array_like_to_array$g(arr, len) {
640
- if (len == null || len > arr.length) len = arr.length;
641
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
642
- return arr2;
643
- }
644
- function _array_with_holes$9(arr) {
645
- if (Array.isArray(arr)) return arr;
646
- }
647
- function _iterable_to_array_limit$9(arr, i) {
648
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
649
- if (_i == null) return;
650
- var _arr = [];
651
- var _n = true;
652
- var _d = false;
653
- var _s, _e;
654
- try {
655
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
656
- _arr.push(_s.value);
657
- if (i && _arr.length === i) break;
658
- }
659
- } catch (err) {
660
- _d = true;
661
- _e = err;
662
- } finally{
663
- try {
664
- if (!_n && _i["return"] != null) _i["return"]();
665
- } finally{
666
- if (_d) throw _e;
667
- }
668
- }
669
- return _arr;
670
- }
671
- function _non_iterable_rest$9() {
672
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
673
- }
674
- function _sliced_to_array$9(arr, i) {
675
- return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$g(arr, i) || _non_iterable_rest$9();
676
- }
677
- function _unsupported_iterable_to_array$g(o, minLen) {
678
- if (!o) return;
679
- if (typeof o === "string") return _array_like_to_array$g(o, minLen);
680
- var n = Object.prototype.toString.call(o).slice(8, -1);
681
- if (n === "Object" && o.constructor) n = o.constructor.name;
682
- if (n === "Map" || n === "Set") return Array.from(n);
683
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
684
- }
685
- /**
686
- * Kebab-case slug pattern: lowercase letters/digits, words separated by single hyphens,
687
- * starts with a letter. Used to validate slug/related/skill-ref values.
688
- */ var KEBAB_SLUG_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
689
- /**
690
- * Pascal-case TypeScript identifier pattern (starts uppercase). Used for model
691
- * identifiers and other `<ModelName>` style tag values.
692
- */ var PASCAL_IDENTIFIER_PATTERN$1 = /^[A-Z][A-Za-z0-9_$]*$/;
693
- /**
694
- * Boolean tag-value vocabulary (case-insensitive). `''` and `true|yes` map to
695
- * true; `false|no` map to false. Anything else is flagged as invalid.
696
- */ var TRUE_TAG_VALUES = new Set([
697
- '',
698
- 'true',
699
- 'yes'
700
- ]);
701
- var FALSE_TAG_VALUES = new Set([
702
- 'false',
703
- 'no'
704
- ]);
705
- /**
706
- * Splits a comma-separated tag-value string into trimmed items, preserving order.
707
- *
708
- * @param value - Raw text following the tag name on a single line.
709
- * @returns Non-empty trimmed segments in declaration order.
710
- */ function splitCommaSeparated(value) {
711
- return value.split(',').map(function(item) {
712
- return item.trim();
713
- }).filter(function(item) {
714
- return item.length > 0;
715
- });
716
- }
717
- /**
718
- * Parses a boolean tag value using the workspace vocabulary
719
- * (`''`/`true`/`yes` → true; `false`/`no` → false). Other inputs return `undefined`.
720
- *
721
- * @param text - The trimmed tag value text.
722
- * @returns The parsed boolean, or `undefined` when the text is not in the vocabulary.
723
- */ function parseBooleanTagValue(text) {
724
- var lowered = text.trim().toLowerCase();
725
- var result;
726
- if (TRUE_TAG_VALUES.has(lowered)) {
727
- result = true;
728
- } else if (FALSE_TAG_VALUES.has(lowered)) {
729
- result = false;
730
- }
731
- return result;
732
- }
733
- /**
734
- * Returns the source-text offset of an offset-within-comment-value, given a Block comment node.
735
- *
736
- * @param commentNode - The ESLint Block comment AST node.
737
- * @param valueOffset - The character offset within `comment.value`.
738
- * @returns The character offset in the source file.
739
- */ function commentValueToSourceOffset(commentNode, valueOffset) {
740
- return commentNode.range[0] + 2 + valueOffset;
741
- }
742
- /**
743
- * Returns the family marker + companion tag list for the given parsed JSDoc.
744
- * Family membership is determined by tag-name prefix.
745
- *
746
- * @param parsed - The parsed JSDoc.
747
- * @param marker - The bare family marker (e.g. `'dbxPipe'`).
748
- * @returns The marker tag (if present), and all companion tags in source order.
749
- */ function findFamilyTags(parsed, marker) {
750
- var familyTags = parsed.tags.filter(function(t) {
751
- return t.tag === marker || t.tag.startsWith(marker);
752
- });
753
- var markerTag = parsed.tags.find(function(t) {
754
- return t.tag === marker;
755
- });
756
- return {
757
- markerTag: markerTag,
758
- familyTags: familyTags
759
- };
760
- }
761
- /**
762
- * Groups companion tags (those after the marker) by suffix. Marker entries are excluded.
763
- *
764
- * @param familyTags - The family tag list from {@link findFamilyTags}.
765
- * @param marker - The bare family marker.
766
- * @returns Lookup keyed by companion-suffix listing matching tags in declaration order.
767
- */ function groupCompanionsBySuffix(familyTags, marker) {
768
- var result = new Map();
769
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
770
- try {
771
- for(var _iterator = familyTags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
772
- var tag = _step.value;
773
- var _result_get;
774
- if (tag.tag === marker) continue;
775
- var suffix = tag.tag.slice(marker.length);
776
- var list = (_result_get = result.get(suffix)) !== null && _result_get !== void 0 ? _result_get : [];
777
- list.push(tag);
778
- result.set(suffix, list);
779
- }
780
- } catch (err) {
781
- _didIteratorError = true;
782
- _iteratorError = err;
783
- } finally{
784
- try {
785
- if (!_iteratorNormalCompletion && _iterator.return != null) {
786
- _iterator.return();
787
- }
788
- } finally{
789
- if (_didIteratorError) {
790
- throw _iteratorError;
791
- }
792
- }
793
- }
794
- return result;
795
- }
796
- /**
797
- * Per-format validators dispatched from {@link validateCompanionValue}. Each entry validates
798
- * a single non-empty tag value and emits zero or more violations.
799
- */ var VALUE_VALIDATORS = {
800
- marker: function marker() {
801
- return undefined;
802
- },
803
- 'free-text': function() {
804
- return undefined;
805
- },
806
- 'comma-list-free-text': function() {
807
- return undefined;
808
- },
809
- 'kebab-slug': function(param) {
810
- var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
811
- if (!KEBAB_SLUG_PATTERN.test(value)) emit({
812
- kind: 'invalid-kebab',
813
- suffix: spec.suffix,
814
- value: value,
815
- lineIndex: lineIndex
816
- });
817
- },
818
- enum: function _enum(param) {
819
- var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
820
- var format = spec.format;
821
- if (!format.values.includes(value)) emit({
822
- kind: 'invalid-enum',
823
- suffix: spec.suffix,
824
- value: value,
825
- allowed: format.values,
826
- lineIndex: lineIndex
827
- });
828
- },
829
- 'pascal-identifier': function(param) {
830
- var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
831
- if (!PASCAL_IDENTIFIER_PATTERN$1.test(value)) emit({
832
- kind: 'invalid-pascal',
833
- suffix: spec.suffix,
834
- value: value,
835
- lineIndex: lineIndex
836
- });
837
- },
838
- 'comma-list-kebab-slug': function(param) {
839
- var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
840
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
841
- try {
842
- for(var _iterator = splitCommaSeparated(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
843
- var item = _step.value;
844
- if (!KEBAB_SLUG_PATTERN.test(item)) emit({
845
- kind: 'comma-item-not-kebab',
846
- suffix: spec.suffix,
847
- value: item,
848
- lineIndex: lineIndex
849
- });
850
- }
851
- } catch (err) {
852
- _didIteratorError = true;
853
- _iteratorError = err;
854
- } finally{
855
- try {
856
- if (!_iteratorNormalCompletion && _iterator.return != null) {
857
- _iterator.return();
858
- }
859
- } finally{
860
- if (_didIteratorError) {
861
- throw _iteratorError;
862
- }
863
- }
864
- }
865
- },
866
- 'comma-list-lowercase': function(param) {
867
- var spec = param.spec, tag = param.tag, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
868
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
869
- try {
870
- for(var _iterator = splitCommaSeparated(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
871
- var item = _step.value;
872
- if (/[A-Z]/.test(item)) emit({
873
- kind: 'tags-not-lowercase',
874
- suffix: spec.suffix,
875
- value: item,
876
- lineIndex: lineIndex,
877
- raw: tag
878
- });
879
- }
880
- } catch (err) {
881
- _didIteratorError = true;
882
- _iteratorError = err;
883
- } finally{
884
- try {
885
- if (!_iteratorNormalCompletion && _iterator.return != null) {
886
- _iterator.return();
887
- }
888
- } finally{
889
- if (_didIteratorError) {
890
- throw _iteratorError;
891
- }
892
- }
893
- }
894
- },
895
- boolean: function boolean(param) {
896
- var spec = param.spec, value = param.value, lineIndex = param.lineIndex, emit = param.emit;
897
- if (parseBooleanTagValue(value) === undefined) emit({
898
- kind: 'invalid-boolean',
899
- suffix: spec.suffix,
900
- value: value,
901
- lineIndex: lineIndex
902
- });
903
- }
904
- };
905
- /**
906
- * Validates one companion tag's value against the configured {@link DbxTagFormat}
907
- * and emits zero-or-more violations. Used by {@link checkDbxTagFamily} to keep
908
- * each rule's body small.
909
- *
910
- * @param spec - The companion spec being validated.
911
- * @param tags - All occurrences of the companion in source order.
912
- * @param emit - Callback for each violation.
913
- */ function validateCompanionValue(spec, tags, emit) {
914
- if (spec.format.kind === 'marker') return;
915
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
916
- try {
917
- for(var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
918
- var tag = _step.value;
919
- var value = tag.description.trim();
920
- var lineIndex = tag.startLineIndex;
921
- if (value.length === 0) {
922
- if (spec.format.kind !== 'boolean') emit({
923
- kind: 'empty',
924
- suffix: spec.suffix,
925
- lineIndex: lineIndex
926
- });
927
- continue;
928
- }
929
- var validator = VALUE_VALIDATORS[spec.format.kind];
930
- if (validator) validator({
931
- spec: spec,
932
- tag: tag,
933
- value: value,
934
- lineIndex: lineIndex,
935
- emit: emit
936
- });
937
- }
938
- } catch (err) {
939
- _didIteratorError = true;
940
- _iteratorError = err;
941
- } finally{
942
- try {
943
- if (!_iteratorNormalCompletion && _iterator.return != null) {
944
- _iterator.return();
945
- }
946
- } finally{
947
- if (_didIteratorError) {
948
- throw _iteratorError;
949
- }
950
- }
951
- }
952
- }
953
- function emitUnknownCompanions(groups, knownSuffixes, emit) {
954
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
955
- try {
956
- for(var _iterator = groups.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
957
- var _step_value = _sliced_to_array$9(_step.value, 2), suffix = _step_value[0], instances = _step_value[1];
958
- if (knownSuffixes.has(suffix)) continue;
959
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
960
- try {
961
- for(var _iterator1 = instances[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
962
- var tag = _step1.value;
963
- emit({
964
- kind: 'unknown',
965
- suffix: suffix,
966
- lineIndex: tag.startLineIndex
967
- });
968
- }
969
- } catch (err) {
970
- _didIteratorError1 = true;
971
- _iteratorError1 = err;
972
- } finally{
973
- try {
974
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
975
- _iterator1.return();
976
- }
977
- } finally{
978
- if (_didIteratorError1) {
979
- throw _iteratorError1;
980
- }
981
- }
982
- }
983
- }
984
- } catch (err) {
985
- _didIteratorError = true;
986
- _iteratorError = err;
987
- } finally{
988
- try {
989
- if (!_iteratorNormalCompletion && _iterator.return != null) {
990
- _iterator.return();
991
- }
992
- } finally{
993
- if (_didIteratorError) {
994
- throw _iteratorError;
995
- }
996
- }
997
- }
998
- }
999
- function emitDuplicateCompanions(companion, instances, emit) {
1000
- for(var i = 1; i < instances.length; i += 1){
1001
- emit({
1002
- kind: 'duplicate',
1003
- suffix: companion.suffix,
1004
- lineIndex: instances[i].startLineIndex
1005
- });
1006
- }
1007
- }
1008
- function checkCompanion(input) {
1009
- var companion = input.companion, instances = input.instances, markerLineIndex = input.markerLineIndex, emit = input.emit;
1010
- if (instances.length === 0) {
1011
- if (companion.required) emit({
1012
- kind: 'missing',
1013
- suffix: companion.suffix,
1014
- lineIndex: markerLineIndex
1015
- });
1016
- return;
1017
- }
1018
- if (!companion.multiple && instances.length > 1) emitDuplicateCompanions(companion, instances, emit);
1019
- validateCompanionValue(companion, instances, emit);
1020
- }
1021
- /**
1022
- * Validates a `@dbx<Family>` marker plus its companion tags against the supplied spec.
1023
- * Reports unknown companions, missing required companions, duplicates, and per-companion
1024
- * value violations through `input.emit`.
1025
- *
1026
- * @param input - Parsed JSDoc, family spec, resolved marker/companion tags, and emit sink.
1027
- *
1028
- * @example
1029
- * ```ts
1030
- * checkDbxTagFamily({ parsed, spec, markerTag, familyTags, emit });
1031
- * ```
1032
- */ function checkDbxTagFamily(input) {
1033
- var spec = input.spec, markerTag = input.markerTag, familyTags = input.familyTags, emit = input.emit;
1034
- var knownSuffixes = new Set(spec.companions.map(function(c) {
1035
- return c.suffix;
1036
- }));
1037
- var groups = groupCompanionsBySuffix(familyTags, spec.marker);
1038
- emitUnknownCompanions(groups, knownSuffixes, emit);
1039
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1040
- try {
1041
- for(var _iterator = spec.companions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1042
- var companion = _step.value;
1043
- var _groups_get;
1044
- var instances = (_groups_get = groups.get(companion.suffix)) !== null && _groups_get !== void 0 ? _groups_get : [];
1045
- checkCompanion({
1046
- companion: companion,
1047
- instances: instances,
1048
- markerLineIndex: markerTag.startLineIndex,
1049
- emit: emit
1050
- });
1051
- }
1052
- } catch (err) {
1053
- _didIteratorError = true;
1054
- _iteratorError = err;
1055
- } finally{
1056
- try {
1057
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1058
- _iterator.return();
1059
- }
1060
- } finally{
1061
- if (_didIteratorError) {
1062
- throw _iteratorError;
1063
- }
1064
- }
1065
- }
1066
- }
1067
- /**
1068
- * Translates a JSDoc-line violation into an ESLint `context.report()` call by computing the
1069
- * source range of the offending line and attaching the supplied message + optional fixer.
1070
- *
1071
- * @param input - Reporting context (comment node, parsed JSDoc, source code, line index, message id, optional data + fixer, report sink).
1072
- *
1073
- * @example
1074
- * ```ts
1075
- * reportOnJsdocLine({ commentNode, parsed, sourceCode, lineIndex: tag.startLineIndex, messageId: 'unknown', report: context.report });
1076
- * ```
1077
- */ function reportOnJsdocLine(input) {
1078
- var _ref, _ref1;
1079
- var _line_text;
1080
- var commentNode = input.commentNode, parsed = input.parsed, sourceCode = input.sourceCode, lineIndex = input.lineIndex, messageId = input.messageId, data = input.data, report = input.report, fix = input.fix;
1081
- var line = parsed.lines[lineIndex];
1082
- var startInValue = (_ref = line === null || line === void 0 ? void 0 : line.textOffsetStart) !== null && _ref !== void 0 ? _ref : 0;
1083
- var endInValue = startInValue + ((_ref1 = line === null || line === void 0 ? void 0 : (_line_text = line.text) === null || _line_text === void 0 ? void 0 : _line_text.length) !== null && _ref1 !== void 0 ? _ref1 : 0);
1084
- var start = commentValueToSourceOffset(commentNode, startInValue);
1085
- var end = commentValueToSourceOffset(commentNode, endInValue);
1086
- report({
1087
- loc: {
1088
- type: 'SourceLocation',
1089
- start: sourceCode.getLocFromIndex(start),
1090
- end: sourceCode.getLocFromIndex(end)
1091
- },
1092
- messageId: messageId,
1093
- data: data,
1094
- fix: fix
1095
- });
1096
- }
1097
- /**
1098
- * Computes an auto-fix descriptor that lowercases every token after a `@dbx<Family>Tags` tag
1099
- * name. Returns `undefined` when the line is already canonical so the caller can short-circuit.
1100
- *
1101
- * @param input - Fix context (comment node, parsed JSDoc, source code, target tag).
1102
- * @returns Replacement range + text when a rewrite is needed; otherwise `undefined`.
1103
- *
1104
- * @example
1105
- * ```ts
1106
- * const fix = buildLowercaseTagsFix({ commentNode, parsed, sourceCode, tag });
1107
- * ```
1108
- */ function buildLowercaseTagsFix(input) {
1109
- var commentNode = input.commentNode, parsed = input.parsed, sourceCode = input.sourceCode, tag = input.tag;
1110
- var tagLine = parsed.lines[tag.startLineIndex];
1111
- var result;
1112
- if (tagLine) {
1113
- var tagLineSourceStart = commentValueToSourceOffset(commentNode, tagLine.textOffsetStart);
1114
- var tagLineSourceEnd = tagLineSourceStart + tagLine.text.length;
1115
- var sourceText = sourceCode.getText();
1116
- var lineSource = sourceText.slice(tagLineSourceStart, tagLineSourceEnd);
1117
- var lowered = lineSource.replace(/^(@[A-Za-z]+\s+)(.*)$/, function(_match, prefix, body) {
1118
- return "".concat(prefix).concat(body.toLowerCase());
1119
- });
1120
- if (lowered !== lineSource) {
1121
- result = {
1122
- startOffset: tagLineSourceStart,
1123
- endOffset: tagLineSourceEnd,
1124
- replacement: lowered
1125
- };
1126
- }
1127
- }
1128
- return result;
1129
- }
1130
-
1131
8
  function _array_like_to_array$f(arr, len) {
1132
9
  if (len == null || len > arr.length) len = arr.length;
1133
10
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -2464,6 +1341,7 @@ var DEFAULT_KNOWN_COMPANIONS = [
2464
1341
  if (familyTags.length === 0 || requireBareMarker && !markerTag) return;
2465
1342
  var triggerTag = markerTag !== null && markerTag !== void 0 ? markerTag : familyTags[0];
2466
1343
  checkDbxTagFamily({
1344
+ parsed: parsed,
2467
1345
  spec: spec,
2468
1346
  markerTag: triggerTag,
2469
1347
  familyTags: familyTags,