eslint-plugin-jsdoc 48.8.3 → 48.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/WarnSettings.cjs +2 -2
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +538 -0
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/iterateJsdoc.cjs +58 -112
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +226 -48
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +5 -6
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +7 -7
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/eslint.config.js +3 -2
- package/package.json +12 -4
- package/src/WarnSettings.js +2 -2
- package/src/getJsdocProcessorPlugin.js +602 -0
- package/src/index.js +106 -0
- package/src/iterateJsdoc.js +21 -97
- package/src/jsdocUtils.js +191 -7
- package/src/rules/convertToJsdocComments.js +10 -6
- package/src/rules/requireJsdoc.js +16 -8
package/dist/jsdocUtils.cjs
CHANGED
|
@@ -3,7 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.hasParams = exports.hasATag = exports.getTagsByType = exports.getTags = exports.getTagStructureForMode = exports.getTagDescription = exports.getRegexFromString = exports.getPreferredTagNameSimple = exports.getPreferredTagName = exports.getJsdocTagsDeep = exports.getIndent = exports.getFunctionParameterNames = exports.getContextObject = exports.getAllTags = exports.forEachPreferredTag = exports.flattenRoots = exports.filterTags = exports.exemptSpeciaMethods = exports.enforcedContexts = exports.dropPathSegmentQuotes = exports.comparePaths = void 0;
|
|
7
|
+
Object.defineProperty(exports, "hasReturnValue", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _hasReturnValue.hasReturnValue;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.hasThrowValue = exports.hasTag = void 0;
|
|
14
|
+
Object.defineProperty(exports, "hasValueOrExecutorHasNonEmptyResolveValue", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.tagMustHaveTypePosition = exports.tagMustHaveNamePosition = exports.tagMissingRequiredTypeOrNamepath = exports.tagMightHaveTypePosition = exports.tagMightHaveNamepath = exports.tagMightHaveNamePosition = exports.tagMightHaveEitherTypeOrNamePosition = exports.setTagStructure = exports.pathDoesNotBeginWith = exports.parseClosureTemplateTag = exports.overrideTagStructure = exports.mayBeUndefinedTypeTag = exports.isValidTag = exports.isSetter = exports.isNamepathReferencingTag = exports.isNamepathOrUrlReferencingTag = exports.isNamepathDefiningTag = exports.isGetter = exports.isConstructor = exports.hasYieldValue = void 0;
|
|
7
21
|
var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode.cjs"));
|
|
8
22
|
var _tagNames = require("./tagNames.cjs");
|
|
9
23
|
var _hasReturnValue = require("./utils/hasReturnValue.cjs");
|
|
@@ -82,6 +96,7 @@ const setTagStructure = mode => {
|
|
|
82
96
|
*/
|
|
83
97
|
|
|
84
98
|
/** @type {FlattenRoots} */
|
|
99
|
+
exports.setTagStructure = setTagStructure;
|
|
85
100
|
const flattenRoots = (params, root = '') => {
|
|
86
101
|
let hasRestElement = false;
|
|
87
102
|
let hasPropertyRest = false;
|
|
@@ -153,6 +168,7 @@ const flattenRoots = (params, root = '') => {
|
|
|
153
168
|
* import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
|
|
154
169
|
* @returns {undefined|string|[string, string[]]}
|
|
155
170
|
*/
|
|
171
|
+
exports.flattenRoots = flattenRoots;
|
|
156
172
|
const getPropertiesFromPropertySignature = propSignature => {
|
|
157
173
|
if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
|
|
158
174
|
return undefined;
|
|
@@ -337,6 +353,7 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
337
353
|
* @param {ESTreeOrTypeScriptNode} functionNode
|
|
338
354
|
* @returns {Integer}
|
|
339
355
|
*/
|
|
356
|
+
exports.getFunctionParameterNames = getFunctionParameterNames;
|
|
340
357
|
const hasParams = functionNode => {
|
|
341
358
|
// Should also check `functionNode.value.params` if supporting `MethodDefinition`
|
|
342
359
|
return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length;
|
|
@@ -353,6 +370,7 @@ const hasParams = functionNode => {
|
|
|
353
370
|
* type: string
|
|
354
371
|
* }[]}
|
|
355
372
|
*/
|
|
373
|
+
exports.hasParams = hasParams;
|
|
356
374
|
const getJsdocTagsDeep = (jsdoc, targetTagName) => {
|
|
357
375
|
const ret = [];
|
|
358
376
|
for (const [idx, {
|
|
@@ -371,11 +389,12 @@ const getJsdocTagsDeep = (jsdoc, targetTagName) => {
|
|
|
371
389
|
}
|
|
372
390
|
return ret;
|
|
373
391
|
};
|
|
392
|
+
exports.getJsdocTagsDeep = getJsdocTagsDeep;
|
|
374
393
|
const modeWarnSettings = (0, _WarnSettings.default)();
|
|
375
394
|
|
|
376
395
|
/**
|
|
377
396
|
* @param {ParserMode|undefined} mode
|
|
378
|
-
* @param {
|
|
397
|
+
* @param {Reporter} context
|
|
379
398
|
* @returns {import('./tagNames.js').AliasedTags}
|
|
380
399
|
*/
|
|
381
400
|
const getTagNamesForMode = (mode, context) => {
|
|
@@ -411,16 +430,65 @@ const getTagNamesForMode = (mode, context) => {
|
|
|
411
430
|
};
|
|
412
431
|
|
|
413
432
|
/**
|
|
414
|
-
* @param {import('
|
|
415
|
-
* @param {
|
|
433
|
+
* @param {import('comment-parser').Spec} tg
|
|
434
|
+
* @param {boolean} [returnArray]
|
|
435
|
+
* @returns {string[]|string}
|
|
436
|
+
*/
|
|
437
|
+
const getTagDescription = (tg, returnArray) => {
|
|
438
|
+
/**
|
|
439
|
+
* @type {string[]}
|
|
440
|
+
*/
|
|
441
|
+
const descriptions = [];
|
|
442
|
+
tg.source.some(({
|
|
443
|
+
tokens: {
|
|
444
|
+
end,
|
|
445
|
+
lineEnd,
|
|
446
|
+
postDelimiter,
|
|
447
|
+
tag,
|
|
448
|
+
postTag,
|
|
449
|
+
name,
|
|
450
|
+
type,
|
|
451
|
+
description
|
|
452
|
+
}
|
|
453
|
+
}) => {
|
|
454
|
+
const desc = (tag && postTag || !tag && !name && !type && postDelimiter || ''
|
|
455
|
+
|
|
456
|
+
// Remove space
|
|
457
|
+
).slice(1) + (description || '') + (lineEnd || '');
|
|
458
|
+
if (end) {
|
|
459
|
+
if (desc) {
|
|
460
|
+
descriptions.push(desc);
|
|
461
|
+
}
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
descriptions.push(desc);
|
|
465
|
+
return false;
|
|
466
|
+
});
|
|
467
|
+
return returnArray ? descriptions : descriptions.join('\n');
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* @typedef {{
|
|
472
|
+
* report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
|
|
473
|
+
* }} Reporter
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
/**
|
|
416
477
|
* @param {string} name
|
|
478
|
+
* @param {ParserMode|undefined} mode
|
|
417
479
|
* @param {TagNamePreference} tagPreference
|
|
480
|
+
* @param {Reporter} context
|
|
418
481
|
* @returns {string|false|{
|
|
419
482
|
* message: string;
|
|
420
483
|
* replacement?: string|undefined;
|
|
421
484
|
* }}
|
|
422
485
|
*/
|
|
423
|
-
|
|
486
|
+
exports.getTagDescription = getTagDescription;
|
|
487
|
+
const getPreferredTagNameSimple = (name, mode, tagPreference = {}, context = {
|
|
488
|
+
report() {
|
|
489
|
+
// No-op
|
|
490
|
+
}
|
|
491
|
+
}) => {
|
|
424
492
|
var _Object$entries$find;
|
|
425
493
|
const prefValues = Object.values(tagPreference);
|
|
426
494
|
if (prefValues.includes(name) || prefValues.some(prefVal => {
|
|
@@ -457,6 +525,7 @@ const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
|
|
|
457
525
|
* @param {string[]} definedTags
|
|
458
526
|
* @returns {boolean}
|
|
459
527
|
*/
|
|
528
|
+
exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
|
|
460
529
|
const isValidTag = (context, mode, name, definedTags) => {
|
|
461
530
|
const tagNames = getTagNamesForMode(mode, context);
|
|
462
531
|
const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
|
|
@@ -470,6 +539,7 @@ const isValidTag = (context, mode, name, definedTags) => {
|
|
|
470
539
|
* @param {string} targetTagName
|
|
471
540
|
* @returns {boolean}
|
|
472
541
|
*/
|
|
542
|
+
exports.isValidTag = isValidTag;
|
|
473
543
|
const hasTag = (jsdoc, targetTagName) => {
|
|
474
544
|
const targetTagLower = targetTagName.toLowerCase();
|
|
475
545
|
return jsdoc.tags.some(doc => {
|
|
@@ -477,12 +547,133 @@ const hasTag = (jsdoc, targetTagName) => {
|
|
|
477
547
|
});
|
|
478
548
|
};
|
|
479
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
552
|
+
* @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
|
|
553
|
+
* @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
|
|
554
|
+
*/
|
|
555
|
+
exports.hasTag = hasTag;
|
|
556
|
+
const filterTags = (jsdoc, filter) => {
|
|
557
|
+
return jsdoc.tags.filter(tag => {
|
|
558
|
+
return filter(tag);
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
564
|
+
* @param {string} tagName
|
|
565
|
+
* @returns {import('comment-parser').Spec[]}
|
|
566
|
+
*/
|
|
567
|
+
exports.filterTags = filterTags;
|
|
568
|
+
const getTags = (jsdoc, tagName) => {
|
|
569
|
+
return filterTags(jsdoc, item => {
|
|
570
|
+
return item.tag === tagName;
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
576
|
+
* @param {{
|
|
577
|
+
* tagName: string,
|
|
578
|
+
* context?: import('eslint').Rule.RuleContext,
|
|
579
|
+
* mode?: ParserMode,
|
|
580
|
+
* report?: import('./iterateJsdoc.js').Report
|
|
581
|
+
* tagNamePreference?: TagNamePreference
|
|
582
|
+
* skipReportingBlockedTag?: boolean,
|
|
583
|
+
* allowObjectReturn?: boolean,
|
|
584
|
+
* defaultMessage?: string,
|
|
585
|
+
* }} cfg
|
|
586
|
+
* @returns {string|undefined|false|{
|
|
587
|
+
* message: string;
|
|
588
|
+
* replacement?: string|undefined;
|
|
589
|
+
* }|{
|
|
590
|
+
* blocked: true,
|
|
591
|
+
* tagName: string
|
|
592
|
+
* }}
|
|
593
|
+
*/
|
|
594
|
+
exports.getTags = getTags;
|
|
595
|
+
const getPreferredTagName = (jsdoc, {
|
|
596
|
+
tagName,
|
|
597
|
+
context,
|
|
598
|
+
mode,
|
|
599
|
+
tagNamePreference,
|
|
600
|
+
report = () => {},
|
|
601
|
+
skipReportingBlockedTag = false,
|
|
602
|
+
allowObjectReturn = false,
|
|
603
|
+
defaultMessage = `Unexpected tag \`@${tagName}\``
|
|
604
|
+
}) => {
|
|
605
|
+
const ret = getPreferredTagNameSimple(tagName, mode, tagNamePreference, context);
|
|
606
|
+
const isObject = ret && typeof ret === 'object';
|
|
607
|
+
if (hasTag(jsdoc, tagName) && (ret === false || isObject && !ret.replacement)) {
|
|
608
|
+
if (skipReportingBlockedTag) {
|
|
609
|
+
return {
|
|
610
|
+
blocked: true,
|
|
611
|
+
tagName
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
const message = isObject && ret.message || defaultMessage;
|
|
615
|
+
report(message, null, getTags(jsdoc, tagName)[0]);
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
return isObject && !allowObjectReturn ? ret.replacement : ret;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
623
|
+
* @param {string} tagName
|
|
624
|
+
* @param {(
|
|
625
|
+
* matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
|
|
626
|
+
* targetTagName: string
|
|
627
|
+
* ) => void} arrayHandler
|
|
628
|
+
* @param {object} cfg
|
|
629
|
+
* @param {import('eslint').Rule.RuleContext} [cfg.context]
|
|
630
|
+
* @param {ParserMode} [cfg.mode]
|
|
631
|
+
* @param {import('./iterateJsdoc.js').Report} [cfg.report]
|
|
632
|
+
* @param {TagNamePreference} [cfg.tagNamePreference]
|
|
633
|
+
* @param {boolean} [cfg.skipReportingBlockedTag]
|
|
634
|
+
* @returns {void}
|
|
635
|
+
*/
|
|
636
|
+
exports.getPreferredTagName = getPreferredTagName;
|
|
637
|
+
const forEachPreferredTag = (jsdoc, tagName, arrayHandler, {
|
|
638
|
+
context,
|
|
639
|
+
mode,
|
|
640
|
+
report,
|
|
641
|
+
tagNamePreference,
|
|
642
|
+
skipReportingBlockedTag = false
|
|
643
|
+
} = {}) => {
|
|
644
|
+
const targetTagName = /** @type {string|false} */
|
|
645
|
+
getPreferredTagName(jsdoc, {
|
|
646
|
+
skipReportingBlockedTag,
|
|
647
|
+
tagName,
|
|
648
|
+
context,
|
|
649
|
+
mode,
|
|
650
|
+
report,
|
|
651
|
+
tagNamePreference
|
|
652
|
+
});
|
|
653
|
+
if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object') {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
const matchingJsdocTags = jsdoc.tags.filter(({
|
|
657
|
+
tag
|
|
658
|
+
}) => {
|
|
659
|
+
return tag === targetTagName;
|
|
660
|
+
});
|
|
661
|
+
for (const matchingJsdocTag of matchingJsdocTags) {
|
|
662
|
+
arrayHandler(
|
|
663
|
+
/**
|
|
664
|
+
* @type {import('@es-joy/jsdoccomment').JsdocTagWithInline}
|
|
665
|
+
*/
|
|
666
|
+
matchingJsdocTag, targetTagName);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
|
|
480
670
|
/**
|
|
481
671
|
* Get all tags, inline tags and inline tags in tags
|
|
482
672
|
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
483
673
|
* @returns {(import('comment-parser').Spec|
|
|
484
674
|
* import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
|
|
485
675
|
*/
|
|
676
|
+
exports.forEachPreferredTag = forEachPreferredTag;
|
|
486
677
|
const getAllTags = jsdoc => {
|
|
487
678
|
return [...jsdoc.tags, ...jsdoc.inlineTags.map(inlineTag => {
|
|
488
679
|
// Tags don't have source or line numbers, so add before returning
|
|
@@ -543,6 +734,7 @@ const getAllTags = jsdoc => {
|
|
|
543
734
|
* @param {string[]} targetTagNames
|
|
544
735
|
* @returns {boolean}
|
|
545
736
|
*/
|
|
737
|
+
exports.getAllTags = getAllTags;
|
|
546
738
|
const hasATag = (jsdoc, targetTagNames) => {
|
|
547
739
|
return targetTagNames.some(targetTagName => {
|
|
548
740
|
return hasTag(jsdoc, targetTagName);
|
|
@@ -557,6 +749,7 @@ const hasATag = (jsdoc, targetTagNames) => {
|
|
|
557
749
|
* @returns {boolean}
|
|
558
750
|
* true in case a defined type is undeclared; otherwise false.
|
|
559
751
|
*/
|
|
752
|
+
exports.hasATag = hasATag;
|
|
560
753
|
const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
561
754
|
// The function should not continue in the event the type is not defined...
|
|
562
755
|
if (typeof tag === 'undefined' || tag === null) {
|
|
@@ -593,6 +786,7 @@ const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
|
593
786
|
* @param {string} tag
|
|
594
787
|
* @returns {Map<string, string|string[]|boolean|undefined>}
|
|
595
788
|
*/
|
|
789
|
+
exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
|
|
596
790
|
const ensureMap = (map, tag) => {
|
|
597
791
|
if (!map.has(tag)) {
|
|
598
792
|
map.set(tag, new Map());
|
|
@@ -640,6 +834,7 @@ const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
|
|
|
640
834
|
* @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
|
|
641
835
|
* @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
642
836
|
*/
|
|
837
|
+
exports.overrideTagStructure = overrideTagStructure;
|
|
643
838
|
const getTagStructureForMode = (mode, structuredTags) => {
|
|
644
839
|
const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode);
|
|
645
840
|
try {
|
|
@@ -656,6 +851,7 @@ const getTagStructureForMode = (mode, structuredTags) => {
|
|
|
656
851
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
657
852
|
* @returns {boolean}
|
|
658
853
|
*/
|
|
854
|
+
exports.getTagStructureForMode = getTagStructureForMode;
|
|
659
855
|
const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
660
856
|
const tagStruct = ensureMap(tagMap, tag);
|
|
661
857
|
return tagStruct.get('namepathRole') === 'namepath-defining';
|
|
@@ -666,6 +862,7 @@ const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
|
666
862
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
667
863
|
* @returns {boolean}
|
|
668
864
|
*/
|
|
865
|
+
exports.isNamepathDefiningTag = isNamepathDefiningTag;
|
|
669
866
|
const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
|
|
670
867
|
const tagStruct = ensureMap(tagMap, tag);
|
|
671
868
|
return tagStruct.get('namepathRole') === 'namepath-referencing';
|
|
@@ -676,6 +873,7 @@ const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
|
|
|
676
873
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
677
874
|
* @returns {boolean}
|
|
678
875
|
*/
|
|
876
|
+
exports.isNamepathReferencingTag = isNamepathReferencingTag;
|
|
679
877
|
const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
|
|
680
878
|
const tagStruct = ensureMap(tagMap, tag);
|
|
681
879
|
return tagStruct.get('namepathRole') === 'namepath-or-url-referencing';
|
|
@@ -686,6 +884,7 @@ const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
|
|
|
686
884
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
687
885
|
* @returns {boolean|undefined}
|
|
688
886
|
*/
|
|
887
|
+
exports.isNamepathOrUrlReferencingTag = isNamepathOrUrlReferencingTag;
|
|
689
888
|
const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
690
889
|
const tagStruct = ensureMap(tagMap, tag);
|
|
691
890
|
return /** @type {boolean|undefined} */tagStruct.get('typeRequired');
|
|
@@ -696,6 +895,7 @@ const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
|
696
895
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
697
896
|
* @returns {boolean|string}
|
|
698
897
|
*/
|
|
898
|
+
exports.tagMustHaveTypePosition = tagMustHaveTypePosition;
|
|
699
899
|
const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
700
900
|
if (tagMustHaveTypePosition(tag, tagMap)) {
|
|
701
901
|
return true;
|
|
@@ -704,6 +904,7 @@ const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
|
704
904
|
const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed');
|
|
705
905
|
return ret === undefined ? true : ret;
|
|
706
906
|
};
|
|
907
|
+
exports.tagMightHaveTypePosition = tagMightHaveTypePosition;
|
|
707
908
|
const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
|
|
708
909
|
|
|
709
910
|
/**
|
|
@@ -722,6 +923,7 @@ const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
|
722
923
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
723
924
|
* @returns {boolean}
|
|
724
925
|
*/
|
|
926
|
+
exports.tagMightHaveNamePosition = tagMightHaveNamePosition;
|
|
725
927
|
const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
|
|
726
928
|
const tagStruct = ensureMap(tagMap, tag);
|
|
727
929
|
const nampathRole = tagStruct.get('namepathRole');
|
|
@@ -733,6 +935,7 @@ const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
|
|
|
733
935
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
734
936
|
* @returns {boolean|undefined}
|
|
735
937
|
*/
|
|
938
|
+
exports.tagMightHaveNamepath = tagMightHaveNamepath;
|
|
736
939
|
const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
737
940
|
const tagStruct = ensureMap(tagMap, tag);
|
|
738
941
|
return /** @type {boolean|undefined} */tagStruct.get('nameRequired');
|
|
@@ -743,6 +946,7 @@ const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
|
743
946
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
744
947
|
* @returns {boolean}
|
|
745
948
|
*/
|
|
949
|
+
exports.tagMustHaveNamePosition = tagMustHaveNamePosition;
|
|
746
950
|
const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
747
951
|
return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
|
|
748
952
|
};
|
|
@@ -752,6 +956,7 @@ const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
|
752
956
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
753
957
|
* @returns {boolean|undefined}
|
|
754
958
|
*/
|
|
959
|
+
exports.tagMightHaveEitherTypeOrNamePosition = tagMightHaveEitherTypeOrNamePosition;
|
|
755
960
|
const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
756
961
|
const tagStruct = ensureMap(tagMap, tag);
|
|
757
962
|
return /** @type {boolean} */tagStruct.get('typeOrNameRequired');
|
|
@@ -778,6 +983,7 @@ const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
|
|
|
778
983
|
* @param {boolean} [checkYieldReturnValue]
|
|
779
984
|
* @returns {boolean}
|
|
780
985
|
*/
|
|
986
|
+
exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
|
|
781
987
|
const hasNonFunctionYield = (node, checkYieldReturnValue) => {
|
|
782
988
|
/* eslint-enable complexity -- Temporary */
|
|
783
989
|
if (!node) {
|
|
@@ -954,6 +1160,7 @@ const hasYieldValue = (node, checkYieldReturnValue) => {
|
|
|
954
1160
|
* @returns {boolean}
|
|
955
1161
|
*/
|
|
956
1162
|
// eslint-disable-next-line complexity
|
|
1163
|
+
exports.hasYieldValue = hasYieldValue;
|
|
957
1164
|
const hasThrowValue = (node, innerFunction) => {
|
|
958
1165
|
if (!node) {
|
|
959
1166
|
return false;
|
|
@@ -1030,6 +1237,7 @@ const isInlineTag = (tag) => {
|
|
|
1030
1237
|
* @param {import('comment-parser').Spec} tag
|
|
1031
1238
|
* @returns {string[]}
|
|
1032
1239
|
*/
|
|
1240
|
+
exports.hasThrowValue = hasThrowValue;
|
|
1033
1241
|
const parseClosureTemplateTag = tag => {
|
|
1034
1242
|
return tag.name.split(',').map(type => {
|
|
1035
1243
|
return type.trim().replace(/^\[(?<name>.*?)=.*\]$/u, '$<name>');
|
|
@@ -1051,6 +1259,7 @@ const parseClosureTemplateTag = tag => {
|
|
|
1051
1259
|
* }} settings
|
|
1052
1260
|
* @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
|
|
1053
1261
|
*/
|
|
1262
|
+
exports.parseClosureTemplateTag = parseClosureTemplateTag;
|
|
1054
1263
|
const enforcedContexts = (context, defaultContexts, settings) => {
|
|
1055
1264
|
var _context$options$;
|
|
1056
1265
|
const contexts = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.contexts) || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
|
|
@@ -1063,6 +1272,7 @@ const enforcedContexts = (context, defaultContexts, settings) => {
|
|
|
1063
1272
|
* @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
|
|
1064
1273
|
* @returns {import('eslint').Rule.RuleListener}
|
|
1065
1274
|
*/
|
|
1275
|
+
exports.enforcedContexts = enforcedContexts;
|
|
1066
1276
|
const getContextObject = (contexts, checkJsdoc, handler) => {
|
|
1067
1277
|
/** @type {import('eslint').Rule.RuleListener} */
|
|
1068
1278
|
const properties = {};
|
|
@@ -1116,6 +1326,7 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
|
|
|
1116
1326
|
}
|
|
1117
1327
|
return properties;
|
|
1118
1328
|
};
|
|
1329
|
+
exports.getContextObject = getContextObject;
|
|
1119
1330
|
const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'property', 'prop', 'template',
|
|
1120
1331
|
// These two are parsed by our custom parser as though having a `name`
|
|
1121
1332
|
'returns', 'return']);
|
|
@@ -1163,6 +1374,7 @@ const getTagsByType = (context, mode, tags) => {
|
|
|
1163
1374
|
* }} sourceCode
|
|
1164
1375
|
* @returns {string}
|
|
1165
1376
|
*/
|
|
1377
|
+
exports.getTagsByType = getTagsByType;
|
|
1166
1378
|
const getIndent = sourceCode => {
|
|
1167
1379
|
var _sourceCode$text$matc;
|
|
1168
1380
|
return (((_sourceCode$text$matc = sourceCode.text.match(/^\n*([ \t]+)/u)) === null || _sourceCode$text$matc === void 0 ? void 0 : _sourceCode$text$matc[1]) ?? '') + ' ';
|
|
@@ -1172,6 +1384,7 @@ const getIndent = sourceCode => {
|
|
|
1172
1384
|
* @param {import('eslint').Rule.Node|null} node
|
|
1173
1385
|
* @returns {boolean}
|
|
1174
1386
|
*/
|
|
1387
|
+
exports.getIndent = getIndent;
|
|
1175
1388
|
const isConstructor = node => {
|
|
1176
1389
|
var _node$parent;
|
|
1177
1390
|
return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(node === null || node === void 0 || (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor';
|
|
@@ -1181,6 +1394,7 @@ const isConstructor = node => {
|
|
|
1181
1394
|
* @param {import('eslint').Rule.Node|null} node
|
|
1182
1395
|
* @returns {boolean}
|
|
1183
1396
|
*/
|
|
1397
|
+
exports.isConstructor = isConstructor;
|
|
1184
1398
|
const isGetter = node => {
|
|
1185
1399
|
var _node$parent2;
|
|
1186
1400
|
return node !== null &&
|
|
@@ -1195,6 +1409,7 @@ const isGetter = node => {
|
|
|
1195
1409
|
* @param {import('eslint').Rule.Node|null} node
|
|
1196
1410
|
* @returns {boolean}
|
|
1197
1411
|
*/
|
|
1412
|
+
exports.isGetter = isGetter;
|
|
1198
1413
|
const isSetter = node => {
|
|
1199
1414
|
var _node$parent3;
|
|
1200
1415
|
return node !== null &&
|
|
@@ -1209,6 +1424,7 @@ const isSetter = node => {
|
|
|
1209
1424
|
* @param {import('eslint').Rule.Node} node
|
|
1210
1425
|
* @returns {boolean}
|
|
1211
1426
|
*/
|
|
1427
|
+
exports.isSetter = isSetter;
|
|
1212
1428
|
const hasAccessorPair = node => {
|
|
1213
1429
|
const {
|
|
1214
1430
|
type,
|
|
@@ -1268,6 +1484,7 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
|
|
|
1268
1484
|
* @param {string} str
|
|
1269
1485
|
* @returns {string}
|
|
1270
1486
|
*/
|
|
1487
|
+
exports.exemptSpeciaMethods = exemptSpeciaMethods;
|
|
1271
1488
|
const dropPathSegmentQuotes = str => {
|
|
1272
1489
|
return str.replaceAll(/\.(['"])(.*)\1/gu, '.$2');
|
|
1273
1490
|
};
|
|
@@ -1276,6 +1493,7 @@ const dropPathSegmentQuotes = str => {
|
|
|
1276
1493
|
* @param {string} name
|
|
1277
1494
|
* @returns {(otherPathName: string) => boolean}
|
|
1278
1495
|
*/
|
|
1496
|
+
exports.dropPathSegmentQuotes = dropPathSegmentQuotes;
|
|
1279
1497
|
const comparePaths = name => {
|
|
1280
1498
|
return otherPathName => {
|
|
1281
1499
|
return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
|
|
@@ -1290,6 +1508,7 @@ const comparePaths = name => {
|
|
|
1290
1508
|
*/
|
|
1291
1509
|
|
|
1292
1510
|
/** @type {PathDoesNotBeginWith} */
|
|
1511
|
+
exports.comparePaths = comparePaths;
|
|
1293
1512
|
const pathDoesNotBeginWith = (name, otherPathName) => {
|
|
1294
1513
|
return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
|
|
1295
1514
|
};
|
|
@@ -1299,6 +1518,7 @@ const pathDoesNotBeginWith = (name, otherPathName) => {
|
|
|
1299
1518
|
* @param {string} [requiredFlags]
|
|
1300
1519
|
* @returns {RegExp}
|
|
1301
1520
|
*/
|
|
1521
|
+
exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
|
|
1302
1522
|
const getRegexFromString = (regexString, requiredFlags) => {
|
|
1303
1523
|
const match = regexString.match(/^\/(.*)\/([gimyus]*)$/us);
|
|
1304
1524
|
let flags = 'u';
|
|
@@ -1313,47 +1533,5 @@ const getRegexFromString = (regexString, requiredFlags) => {
|
|
|
1313
1533
|
flags = uniqueFlags.join('');
|
|
1314
1534
|
return new RegExp(regex, flags);
|
|
1315
1535
|
};
|
|
1316
|
-
|
|
1317
|
-
comparePaths,
|
|
1318
|
-
dropPathSegmentQuotes,
|
|
1319
|
-
enforcedContexts,
|
|
1320
|
-
exemptSpeciaMethods,
|
|
1321
|
-
flattenRoots,
|
|
1322
|
-
getAllTags,
|
|
1323
|
-
getContextObject,
|
|
1324
|
-
getFunctionParameterNames,
|
|
1325
|
-
getIndent,
|
|
1326
|
-
getJsdocTagsDeep,
|
|
1327
|
-
getPreferredTagName,
|
|
1328
|
-
getRegexFromString,
|
|
1329
|
-
getTagsByType,
|
|
1330
|
-
getTagStructureForMode,
|
|
1331
|
-
hasATag,
|
|
1332
|
-
hasParams,
|
|
1333
|
-
hasReturnValue: _hasReturnValue.hasReturnValue,
|
|
1334
|
-
hasTag,
|
|
1335
|
-
hasThrowValue,
|
|
1336
|
-
hasValueOrExecutorHasNonEmptyResolveValue: _hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue,
|
|
1337
|
-
hasYieldValue,
|
|
1338
|
-
isConstructor,
|
|
1339
|
-
isGetter,
|
|
1340
|
-
isNamepathDefiningTag,
|
|
1341
|
-
isNamepathOrUrlReferencingTag,
|
|
1342
|
-
isNamepathReferencingTag,
|
|
1343
|
-
isSetter,
|
|
1344
|
-
isValidTag,
|
|
1345
|
-
mayBeUndefinedTypeTag,
|
|
1346
|
-
overrideTagStructure,
|
|
1347
|
-
parseClosureTemplateTag,
|
|
1348
|
-
pathDoesNotBeginWith,
|
|
1349
|
-
setTagStructure,
|
|
1350
|
-
tagMightHaveEitherTypeOrNamePosition,
|
|
1351
|
-
tagMightHaveNamepath,
|
|
1352
|
-
tagMightHaveNamePosition,
|
|
1353
|
-
tagMightHaveTypePosition,
|
|
1354
|
-
tagMissingRequiredTypeOrNamepath,
|
|
1355
|
-
tagMustHaveNamePosition,
|
|
1356
|
-
tagMustHaveTypePosition
|
|
1357
|
-
};
|
|
1358
|
-
module.exports = exports.default;
|
|
1536
|
+
exports.getRegexFromString = getRegexFromString;
|
|
1359
1537
|
//# sourceMappingURL=jsdocUtils.cjs.map
|