eslint-plugin-jsdoc 63.0.11 → 63.0.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.
- package/dist/WarnSettings.cjs +8 -1
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/alignTransform.cjs +10 -6
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/buildForbidRuleDefinition.cjs +10 -3
- package/dist/buildForbidRuleDefinition.cjs.map +1 -1
- package/dist/buildRejectOrPreferRuleDefinition.cjs +14 -7
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
- package/dist/defaultTagOrder.cjs +8 -1
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/exportParser.cjs +14 -6
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateDocs.cjs +44 -36
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/generateOptions.cjs +18 -15
- package/dist/generateOptions.cjs.map +1 -1
- package/dist/generateRule.cjs +24 -24
- package/dist/generateRule.cjs.map +1 -1
- package/dist/generateRuleTypes.cjs +9 -6
- package/dist/generateRuleTypes.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.cjs +8 -1
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +28 -20
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/index-cjs.cjs +159 -152
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-esm.cjs +27 -16
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index.cjs +172 -159
- package/dist/index.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +32 -22
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +86 -18
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +10 -2
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +10 -2
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +15 -6
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +9 -2
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +14 -6
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +9 -2
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +9 -2
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkSyntax.cjs +10 -2
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +11 -4
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +20 -12
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +10 -4
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +17 -9
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +19 -13
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +10 -2
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/escapeInlineTags.cjs +10 -2
- package/dist/rules/escapeInlineTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +10 -2
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs +20 -12
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +12 -4
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +9 -2
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +9 -2
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +10 -2
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +9 -2
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +11 -4
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +10 -2
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +10 -2
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +10 -2
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +9 -2
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +10 -2
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +9 -2
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +9 -2
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +21 -13
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/preferImportTag.cjs +28 -21
- package/dist/rules/preferImportTag.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +10 -2
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +9 -2
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +15 -7
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +10 -2
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +10 -2
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +10 -2
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +24 -17
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +9 -2
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +10 -2
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +10 -2
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +10 -2
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +10 -2
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.cjs +10 -2
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +10 -2
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +10 -2
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireRejects.cjs +9 -2
- package/dist/rules/requireRejects.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +11 -4
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +15 -8
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +10 -2
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +10 -2
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTags.cjs +9 -2
- package/dist/rules/requireTags.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +13 -5
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +9 -2
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +9 -2
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +9 -2
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +12 -4
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +9 -2
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +9 -2
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/tsMethodSignatureStyle.cjs +18 -10
- package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -1
- package/dist/rules/tsNoEmptyObjectType.cjs +13 -5
- package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -1
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +16 -8
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -1
- package/dist/rules/tsPreferFunctionType.cjs +16 -8
- package/dist/rules/tsPreferFunctionType.cjs.map +1 -1
- package/dist/rules/typeFormatting.cjs +17 -9
- package/dist/rules/typeFormatting.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +18 -10
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +9 -4
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +8 -1
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +1 -1
package/dist/jsdocUtils.cjs
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasParams = exports.hasATag = exports.getTagsByType = exports.getTags = exports.getTagStructureForMode = exports.getTagDescription = exports.getRegexFromString = exports.getPreferredTagNameSimple = exports.getPreferredTagName = exports.getJsdocTagsDeep = exports.getJSDocCommentBlocks = exports.getInlineTags = exports.getIndent = exports.getFunctionParameterNames = exports.getDocumentNamepathDefiningTags = 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.tagMightHaveNameOrNamepath = exports.tagMightHaveName = exports.tagMightHaveEitherTypeOrNamePosition = exports.strictNativeTypes = exports.setTagStructure = exports.rewireByParsedType = exports.pathDoesNotBeginWith = exports.parseClosureTemplateTag = exports.overrideTagStructure = exports.mayBeUndefinedTypeTag = exports.isValidTag = exports.isSetter = exports.isNamepathReferencingTag = exports.isNamepathOrUrlReferencingTag = exports.isNameOrNamepathDefiningTag = exports.isGetter = exports.isConstructor = exports.hasYieldValue = void 0;
|
|
21
|
+
var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode.cjs"));
|
|
22
|
+
var _tagNames = require("./tagNames.cjs");
|
|
23
|
+
var _WarnSettings = _interopRequireDefault(require("./WarnSettings.cjs"));
|
|
24
|
+
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
25
|
+
var _hasReturnValue = require("./utils/hasReturnValue.cjs");
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
27
|
/**
|
|
7
28
|
* @typedef {number} Integer
|
|
8
29
|
*/
|
|
@@ -24,7 +45,7 @@ let tagStructure;
|
|
|
24
45
|
* @returns {void}
|
|
25
46
|
*/
|
|
26
47
|
const setTagStructure = mode => {
|
|
27
|
-
tagStructure =
|
|
48
|
+
tagStructure = (0, _getDefaultTagStructureForMode.default)(mode);
|
|
28
49
|
};
|
|
29
50
|
|
|
30
51
|
/**
|
|
@@ -75,6 +96,7 @@ const setTagStructure = mode => {
|
|
|
75
96
|
*/
|
|
76
97
|
|
|
77
98
|
/** @type {FlattenRoots} */
|
|
99
|
+
exports.setTagStructure = setTagStructure;
|
|
78
100
|
const flattenRoots = (params, root = '') => {
|
|
79
101
|
let hasRestElement = false;
|
|
80
102
|
let hasPropertyRest = false;
|
|
@@ -146,6 +168,7 @@ const flattenRoots = (params, root = '') => {
|
|
|
146
168
|
* import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
|
|
147
169
|
* @returns {undefined|string|[string, string[]]}
|
|
148
170
|
*/
|
|
171
|
+
exports.flattenRoots = flattenRoots;
|
|
149
172
|
const getPropertiesFromPropertySignature = propSignature => {
|
|
150
173
|
if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
|
|
151
174
|
return undefined;
|
|
@@ -335,6 +358,7 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects, ignoreInte
|
|
|
335
358
|
* @param {ESTreeOrTypeScriptNode} functionNode
|
|
336
359
|
* @returns {Integer}
|
|
337
360
|
*/
|
|
361
|
+
exports.getFunctionParameterNames = getFunctionParameterNames;
|
|
338
362
|
const hasParams = functionNode => {
|
|
339
363
|
// Should also check `functionNode.value.params` if supporting `MethodDefinition`
|
|
340
364
|
return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length;
|
|
@@ -351,6 +375,7 @@ const hasParams = functionNode => {
|
|
|
351
375
|
* type: string
|
|
352
376
|
* }[]}
|
|
353
377
|
*/
|
|
378
|
+
exports.hasParams = hasParams;
|
|
354
379
|
const getJsdocTagsDeep = (jsdoc, targetTagName) => {
|
|
355
380
|
const ret = [];
|
|
356
381
|
for (const [idx, {
|
|
@@ -369,7 +394,8 @@ const getJsdocTagsDeep = (jsdoc, targetTagName) => {
|
|
|
369
394
|
}
|
|
370
395
|
return ret;
|
|
371
396
|
};
|
|
372
|
-
|
|
397
|
+
exports.getJsdocTagsDeep = getJsdocTagsDeep;
|
|
398
|
+
const modeWarnSettings = (0, _WarnSettings.default)();
|
|
373
399
|
|
|
374
400
|
/**
|
|
375
401
|
* @param {ParserMode|undefined} mode
|
|
@@ -380,11 +406,11 @@ const getTagNamesForMode = (mode, context) => {
|
|
|
380
406
|
switch (mode) {
|
|
381
407
|
case 'closure':
|
|
382
408
|
case 'permissive':
|
|
383
|
-
return closureTags;
|
|
409
|
+
return _tagNames.closureTags;
|
|
384
410
|
case 'jsdoc':
|
|
385
|
-
return jsdocTags;
|
|
411
|
+
return _tagNames.jsdocTags;
|
|
386
412
|
case 'typescript':
|
|
387
|
-
return typeScriptTags;
|
|
413
|
+
return _tagNames.typeScriptTags;
|
|
388
414
|
default:
|
|
389
415
|
if (!modeWarnSettings.hasBeenWarned(context, 'mode')) {
|
|
390
416
|
context.report({
|
|
@@ -404,7 +430,7 @@ const getTagNamesForMode = (mode, context) => {
|
|
|
404
430
|
}
|
|
405
431
|
|
|
406
432
|
// We'll avoid breaking too many other rules
|
|
407
|
-
return jsdocTags;
|
|
433
|
+
return _tagNames.jsdocTags;
|
|
408
434
|
}
|
|
409
435
|
};
|
|
410
436
|
|
|
@@ -462,6 +488,7 @@ const getTagDescription = (tg, returnArray) => {
|
|
|
462
488
|
* replacement?: string|undefined;
|
|
463
489
|
* }}
|
|
464
490
|
*/
|
|
491
|
+
exports.getTagDescription = getTagDescription;
|
|
465
492
|
const getPreferredTagNameSimple = (name, mode, tagPreference = {},
|
|
466
493
|
// @ts-expect-error Just a no-op
|
|
467
494
|
// eslint-disable-next-line unicorn/no-object-as-default-parameter -- Ok
|
|
@@ -505,6 +532,7 @@ context = {
|
|
|
505
532
|
* @param {string[]} definedTags
|
|
506
533
|
* @returns {boolean}
|
|
507
534
|
*/
|
|
535
|
+
exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
|
|
508
536
|
const isValidTag = (context, mode, name, definedTags) => {
|
|
509
537
|
const tagNames = getTagNamesForMode(mode, context);
|
|
510
538
|
const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
|
|
@@ -518,6 +546,7 @@ const isValidTag = (context, mode, name, definedTags) => {
|
|
|
518
546
|
* @param {string} targetTagName
|
|
519
547
|
* @returns {boolean}
|
|
520
548
|
*/
|
|
549
|
+
exports.isValidTag = isValidTag;
|
|
521
550
|
const hasTag = (jsdoc, targetTagName) => {
|
|
522
551
|
const targetTagLower = targetTagName.toLowerCase();
|
|
523
552
|
return jsdoc.tags.some(doc => {
|
|
@@ -530,6 +559,7 @@ const hasTag = (jsdoc, targetTagName) => {
|
|
|
530
559
|
* @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
|
|
531
560
|
* @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
|
|
532
561
|
*/
|
|
562
|
+
exports.hasTag = hasTag;
|
|
533
563
|
const filterTags = (jsdoc, filter) => {
|
|
534
564
|
return jsdoc.tags.filter(tag => {
|
|
535
565
|
return filter(tag);
|
|
@@ -541,6 +571,7 @@ const filterTags = (jsdoc, filter) => {
|
|
|
541
571
|
* @param {string} tagName
|
|
542
572
|
* @returns {import('comment-parser').Spec[]}
|
|
543
573
|
*/
|
|
574
|
+
exports.filterTags = filterTags;
|
|
544
575
|
const getTags = (jsdoc, tagName) => {
|
|
545
576
|
return filterTags(jsdoc, item => {
|
|
546
577
|
return item.tag === tagName;
|
|
@@ -567,6 +598,7 @@ const getTags = (jsdoc, tagName) => {
|
|
|
567
598
|
* tagName: string
|
|
568
599
|
* }}
|
|
569
600
|
*/
|
|
601
|
+
exports.getTags = getTags;
|
|
570
602
|
const getPreferredTagName = (jsdoc, {
|
|
571
603
|
allowObjectReturn = false,
|
|
572
604
|
context,
|
|
@@ -608,6 +640,7 @@ const getPreferredTagName = (jsdoc, {
|
|
|
608
640
|
* @param {boolean} [cfg.skipReportingBlockedTag]
|
|
609
641
|
* @returns {void}
|
|
610
642
|
*/
|
|
643
|
+
exports.getPreferredTagName = getPreferredTagName;
|
|
611
644
|
const forEachPreferredTag = (jsdoc, tagName, arrayHandler, {
|
|
612
645
|
context,
|
|
613
646
|
mode,
|
|
@@ -649,6 +682,7 @@ const forEachPreferredTag = (jsdoc, tagName, arrayHandler, {
|
|
|
649
682
|
* line?: number | undefined; column?: number | undefined;
|
|
650
683
|
* })[]}
|
|
651
684
|
*/
|
|
685
|
+
exports.forEachPreferredTag = forEachPreferredTag;
|
|
652
686
|
const getInlineTags = jsdoc => {
|
|
653
687
|
return [...jsdoc.inlineTags.map(inlineTag => {
|
|
654
688
|
// Tags don't have source or line numbers, so add before returning
|
|
@@ -701,6 +735,7 @@ const getInlineTags = jsdoc => {
|
|
|
701
735
|
* line?: number | undefined; column?: number | undefined;
|
|
702
736
|
* })[]}
|
|
703
737
|
*/
|
|
738
|
+
exports.getInlineTags = getInlineTags;
|
|
704
739
|
const getAllTags = jsdoc => {
|
|
705
740
|
return [...jsdoc.tags, ...getInlineTags(jsdoc)];
|
|
706
741
|
};
|
|
@@ -710,6 +745,7 @@ const getAllTags = jsdoc => {
|
|
|
710
745
|
* @param {string[]} targetTagNames
|
|
711
746
|
* @returns {boolean}
|
|
712
747
|
*/
|
|
748
|
+
exports.getAllTags = getAllTags;
|
|
713
749
|
const hasATag = (jsdoc, targetTagNames) => {
|
|
714
750
|
return targetTagNames.some(targetTagName => {
|
|
715
751
|
return hasTag(jsdoc, targetTagName);
|
|
@@ -724,6 +760,7 @@ const hasATag = (jsdoc, targetTagNames) => {
|
|
|
724
760
|
* @returns {boolean}
|
|
725
761
|
* true in case a defined type is undeclared; otherwise false.
|
|
726
762
|
*/
|
|
763
|
+
exports.hasATag = hasATag;
|
|
727
764
|
const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
728
765
|
// The function should not continue in the event the type is not defined...
|
|
729
766
|
if (typeof tag === 'undefined' || tag === null) {
|
|
@@ -739,7 +776,7 @@ const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
|
739
776
|
}
|
|
740
777
|
let parsedTypes;
|
|
741
778
|
try {
|
|
742
|
-
parsedTypes = tryParse(tagType, mode === 'permissive' ? undefined : [mode]);
|
|
779
|
+
parsedTypes = (0, _jsdoccomment.tryParse)(tagType, mode === 'permissive' ? undefined : [mode]);
|
|
743
780
|
} catch {
|
|
744
781
|
// Ignore
|
|
745
782
|
}
|
|
@@ -760,6 +797,7 @@ const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
|
760
797
|
* @param {string} tag
|
|
761
798
|
* @returns {Map<string, string|string[]|boolean|undefined>}
|
|
762
799
|
*/
|
|
800
|
+
exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
|
|
763
801
|
const ensureMap = (map, tag) => {
|
|
764
802
|
if (!map.has(tag)) {
|
|
765
803
|
map.set(tag, new Map());
|
|
@@ -807,8 +845,9 @@ const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
|
|
|
807
845
|
* @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
|
|
808
846
|
* @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
809
847
|
*/
|
|
848
|
+
exports.overrideTagStructure = overrideTagStructure;
|
|
810
849
|
const getTagStructureForMode = (mode, structuredTags) => {
|
|
811
|
-
const tagStruct =
|
|
850
|
+
const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode);
|
|
812
851
|
try {
|
|
813
852
|
overrideTagStructure(structuredTags, tagStruct);
|
|
814
853
|
/* c8 ignore next 3 */
|
|
@@ -823,6 +862,7 @@ const getTagStructureForMode = (mode, structuredTags) => {
|
|
|
823
862
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
824
863
|
* @returns {boolean}
|
|
825
864
|
*/
|
|
865
|
+
exports.getTagStructureForMode = getTagStructureForMode;
|
|
826
866
|
const isNameOrNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
827
867
|
const tagStruct = ensureMap(tagMap, tag);
|
|
828
868
|
return /** @type {(string|boolean|undefined)[]} */['name-defining', 'namepath-defining'].includes(/** @type {string|boolean|undefined} */
|
|
@@ -833,11 +873,12 @@ const isNameOrNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
|
833
873
|
* @param {import('eslint').SourceCode} sourceCode
|
|
834
874
|
* @returns {import('@es-joy/jsdoccomment').JsdocBlockWithInline[]}
|
|
835
875
|
*/
|
|
876
|
+
exports.isNameOrNamepathDefiningTag = isNameOrNamepathDefiningTag;
|
|
836
877
|
const getJSDocCommentBlocks = sourceCode => {
|
|
837
878
|
return sourceCode.getAllComments().filter(comment => {
|
|
838
879
|
return /^\*(?!\*)/v.test(comment.value);
|
|
839
880
|
}).map(commentNode => {
|
|
840
|
-
return parseComment(commentNode, '');
|
|
881
|
+
return (0, _jsdoccomment.parseComment)(commentNode, '');
|
|
841
882
|
});
|
|
842
883
|
};
|
|
843
884
|
|
|
@@ -845,6 +886,7 @@ const getJSDocCommentBlocks = sourceCode => {
|
|
|
845
886
|
* @param {import('eslint').SourceCode} sourceCode
|
|
846
887
|
* @returns {import('comment-parser').Spec[]}
|
|
847
888
|
*/
|
|
889
|
+
exports.getJSDocCommentBlocks = getJSDocCommentBlocks;
|
|
848
890
|
const getDocumentNamepathDefiningTags = sourceCode => {
|
|
849
891
|
return getJSDocCommentBlocks(sourceCode).flatMap(doc => {
|
|
850
892
|
return doc.tags.filter(({
|
|
@@ -860,6 +902,7 @@ const getDocumentNamepathDefiningTags = sourceCode => {
|
|
|
860
902
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
861
903
|
* @returns {boolean}
|
|
862
904
|
*/
|
|
905
|
+
exports.getDocumentNamepathDefiningTags = getDocumentNamepathDefiningTags;
|
|
863
906
|
const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
|
|
864
907
|
const tagStruct = ensureMap(tagMap, tag);
|
|
865
908
|
return tagStruct.get('namepathRole') === 'namepath-referencing';
|
|
@@ -870,6 +913,7 @@ const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
|
|
|
870
913
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
871
914
|
* @returns {boolean}
|
|
872
915
|
*/
|
|
916
|
+
exports.isNamepathReferencingTag = isNamepathReferencingTag;
|
|
873
917
|
const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
|
|
874
918
|
const tagStruct = ensureMap(tagMap, tag);
|
|
875
919
|
return tagStruct.get('namepathRole') === 'namepath-or-url-referencing';
|
|
@@ -880,6 +924,7 @@ const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
|
|
|
880
924
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
881
925
|
* @returns {boolean|undefined}
|
|
882
926
|
*/
|
|
927
|
+
exports.isNamepathOrUrlReferencingTag = isNamepathOrUrlReferencingTag;
|
|
883
928
|
const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
884
929
|
const tagStruct = ensureMap(tagMap, tag);
|
|
885
930
|
return /** @type {boolean|undefined} */tagStruct.get('typeRequired');
|
|
@@ -890,6 +935,7 @@ const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
|
890
935
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
891
936
|
* @returns {boolean|string}
|
|
892
937
|
*/
|
|
938
|
+
exports.tagMustHaveTypePosition = tagMustHaveTypePosition;
|
|
893
939
|
const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
894
940
|
if (tagMustHaveTypePosition(tag, tagMap)) {
|
|
895
941
|
return true;
|
|
@@ -898,6 +944,7 @@ const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
|
898
944
|
const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed');
|
|
899
945
|
return ret === undefined ? true : ret;
|
|
900
946
|
};
|
|
947
|
+
exports.tagMightHaveTypePosition = tagMightHaveTypePosition;
|
|
901
948
|
const namepathTypes = new Set(['name-defining', 'namepath-defining', 'namepath-referencing']);
|
|
902
949
|
|
|
903
950
|
/**
|
|
@@ -916,6 +963,7 @@ const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
|
916
963
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
917
964
|
* @returns {boolean}
|
|
918
965
|
*/
|
|
966
|
+
exports.tagMightHaveNamePosition = tagMightHaveNamePosition;
|
|
919
967
|
const tagMightHaveNameOrNamepath = (tag, tagMap = tagStructure) => {
|
|
920
968
|
const tagStruct = ensureMap(tagMap, tag);
|
|
921
969
|
const nampathRole = tagStruct.get('namepathRole');
|
|
@@ -927,6 +975,7 @@ const tagMightHaveNameOrNamepath = (tag, tagMap = tagStructure) => {
|
|
|
927
975
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
928
976
|
* @returns {boolean}
|
|
929
977
|
*/
|
|
978
|
+
exports.tagMightHaveNameOrNamepath = tagMightHaveNameOrNamepath;
|
|
930
979
|
const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
|
|
931
980
|
const tagStruct = ensureMap(tagMap, tag);
|
|
932
981
|
const nampathRole = tagStruct.get('namepathRole');
|
|
@@ -938,6 +987,7 @@ const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
|
|
|
938
987
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
939
988
|
* @returns {boolean}
|
|
940
989
|
*/
|
|
990
|
+
exports.tagMightHaveNamepath = tagMightHaveNamepath;
|
|
941
991
|
const tagMightHaveName = (tag, tagMap = tagStructure) => {
|
|
942
992
|
const tagStruct = ensureMap(tagMap, tag);
|
|
943
993
|
const nampathRole = tagStruct.get('namepathRole');
|
|
@@ -949,6 +999,7 @@ const tagMightHaveName = (tag, tagMap = tagStructure) => {
|
|
|
949
999
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
950
1000
|
* @returns {boolean|undefined}
|
|
951
1001
|
*/
|
|
1002
|
+
exports.tagMightHaveName = tagMightHaveName;
|
|
952
1003
|
const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
953
1004
|
const tagStruct = ensureMap(tagMap, tag);
|
|
954
1005
|
return /** @type {boolean|undefined} */tagStruct.get('nameRequired');
|
|
@@ -959,6 +1010,7 @@ const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
|
959
1010
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
960
1011
|
* @returns {boolean}
|
|
961
1012
|
*/
|
|
1013
|
+
exports.tagMustHaveNamePosition = tagMustHaveNamePosition;
|
|
962
1014
|
const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
963
1015
|
return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNameOrNamepath(tag, tagMap);
|
|
964
1016
|
};
|
|
@@ -968,6 +1020,7 @@ const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
|
968
1020
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
969
1021
|
* @returns {boolean|undefined}
|
|
970
1022
|
*/
|
|
1023
|
+
exports.tagMightHaveEitherTypeOrNamePosition = tagMightHaveEitherTypeOrNamePosition;
|
|
971
1024
|
const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
972
1025
|
const tagStruct = ensureMap(tagMap, tag);
|
|
973
1026
|
return /** @type {boolean} */tagStruct.get('typeOrNameRequired');
|
|
@@ -994,6 +1047,7 @@ const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
|
|
|
994
1047
|
* @param {boolean} [checkYieldReturnValue]
|
|
995
1048
|
* @returns {boolean}
|
|
996
1049
|
*/
|
|
1050
|
+
exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
|
|
997
1051
|
const hasNonFunctionYield = (node, checkYieldReturnValue) => {
|
|
998
1052
|
/* eslint-enable complexity -- Temporary */
|
|
999
1053
|
if (!node) {
|
|
@@ -1168,6 +1222,7 @@ const hasYieldValue = (node, checkYieldReturnValue) => {
|
|
|
1168
1222
|
* @param {boolean} [innerFunction]
|
|
1169
1223
|
* @returns {boolean}
|
|
1170
1224
|
*/
|
|
1225
|
+
exports.hasYieldValue = hasYieldValue;
|
|
1171
1226
|
const hasThrowValue = (node, innerFunction) => {
|
|
1172
1227
|
if (!node) {
|
|
1173
1228
|
return false;
|
|
@@ -1249,6 +1304,7 @@ const isInlineTag = (tag) => {
|
|
|
1249
1304
|
* @param {string} str
|
|
1250
1305
|
* @returns {string[]}
|
|
1251
1306
|
*/
|
|
1307
|
+
exports.hasThrowValue = hasThrowValue;
|
|
1252
1308
|
const splitTopLevelCommas = str => {
|
|
1253
1309
|
const parts = [];
|
|
1254
1310
|
let depth = 0;
|
|
@@ -1298,6 +1354,7 @@ const parseClosureTemplateTag = tag => {
|
|
|
1298
1354
|
* }} settings
|
|
1299
1355
|
* @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
|
|
1300
1356
|
*/
|
|
1357
|
+
exports.parseClosureTemplateTag = parseClosureTemplateTag;
|
|
1301
1358
|
const enforcedContexts = (context, defaultContexts, settings) => {
|
|
1302
1359
|
const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
|
|
1303
1360
|
return contexts;
|
|
@@ -1309,6 +1366,7 @@ const enforcedContexts = (context, defaultContexts, settings) => {
|
|
|
1309
1366
|
* @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
|
|
1310
1367
|
* @returns {import('eslint').Rule.RuleListener}
|
|
1311
1368
|
*/
|
|
1369
|
+
exports.enforcedContexts = enforcedContexts;
|
|
1312
1370
|
const getContextObject = (contexts, checkJsdoc, handler) => {
|
|
1313
1371
|
/** @type {import('eslint').Rule.RuleListener} */
|
|
1314
1372
|
const properties = {};
|
|
@@ -1362,6 +1420,7 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
|
|
|
1362
1420
|
}
|
|
1363
1421
|
return properties;
|
|
1364
1422
|
};
|
|
1423
|
+
exports.getContextObject = getContextObject;
|
|
1365
1424
|
const tagsWithNamesAndDescriptions = new Set(['arg', 'argument', 'param', 'prop', 'property', 'return',
|
|
1366
1425
|
// These two are parsed by our custom parser as though having a `name`
|
|
1367
1426
|
'returns', 'template']);
|
|
@@ -1409,6 +1468,7 @@ const getTagsByType = (context, mode, tags) => {
|
|
|
1409
1468
|
* }} sourceCode
|
|
1410
1469
|
* @returns {string}
|
|
1411
1470
|
*/
|
|
1471
|
+
exports.getTagsByType = getTagsByType;
|
|
1412
1472
|
const getIndent = sourceCode => {
|
|
1413
1473
|
return (sourceCode.text.match(/^\n*([ \t]+)/v)?.[1] ?? '') + ' ';
|
|
1414
1474
|
};
|
|
@@ -1417,6 +1477,7 @@ const getIndent = sourceCode => {
|
|
|
1417
1477
|
* @param {import('eslint').Rule.Node|null} node
|
|
1418
1478
|
* @returns {boolean}
|
|
1419
1479
|
*/
|
|
1480
|
+
exports.getIndent = getIndent;
|
|
1420
1481
|
const isConstructor = node => {
|
|
1421
1482
|
return node?.type === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */node?.parent?.kind === 'constructor';
|
|
1422
1483
|
};
|
|
@@ -1425,6 +1486,7 @@ const isConstructor = node => {
|
|
|
1425
1486
|
* @param {import('eslint').Rule.Node|null} node
|
|
1426
1487
|
* @returns {boolean}
|
|
1427
1488
|
*/
|
|
1489
|
+
exports.isConstructor = isConstructor;
|
|
1428
1490
|
const isGetter = node => {
|
|
1429
1491
|
return node !== null &&
|
|
1430
1492
|
/**
|
|
@@ -1438,6 +1500,7 @@ const isGetter = node => {
|
|
|
1438
1500
|
* @param {import('eslint').Rule.Node|null} node
|
|
1439
1501
|
* @returns {boolean}
|
|
1440
1502
|
*/
|
|
1503
|
+
exports.isGetter = isGetter;
|
|
1441
1504
|
const isSetter = node => {
|
|
1442
1505
|
return node !== null &&
|
|
1443
1506
|
/**
|
|
@@ -1451,6 +1514,7 @@ const isSetter = node => {
|
|
|
1451
1514
|
* @param {import('eslint').Rule.Node} node
|
|
1452
1515
|
* @returns {boolean}
|
|
1453
1516
|
*/
|
|
1517
|
+
exports.isSetter = isSetter;
|
|
1454
1518
|
const hasAccessorPair = node => {
|
|
1455
1519
|
const {
|
|
1456
1520
|
key,
|
|
@@ -1511,6 +1575,7 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
|
|
|
1511
1575
|
* @param {string} str
|
|
1512
1576
|
* @returns {string}
|
|
1513
1577
|
*/
|
|
1578
|
+
exports.exemptSpeciaMethods = exemptSpeciaMethods;
|
|
1514
1579
|
const dropPathSegmentQuotes = str => {
|
|
1515
1580
|
return str.replaceAll(/\.(['"])(.*)\1/gv, '.$2');
|
|
1516
1581
|
};
|
|
@@ -1519,6 +1584,7 @@ const dropPathSegmentQuotes = str => {
|
|
|
1519
1584
|
* @param {string} name
|
|
1520
1585
|
* @returns {(otherPathName: string) => boolean}
|
|
1521
1586
|
*/
|
|
1587
|
+
exports.dropPathSegmentQuotes = dropPathSegmentQuotes;
|
|
1522
1588
|
const comparePaths = name => {
|
|
1523
1589
|
return otherPathName => {
|
|
1524
1590
|
return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
|
|
@@ -1533,6 +1599,7 @@ const comparePaths = name => {
|
|
|
1533
1599
|
*/
|
|
1534
1600
|
|
|
1535
1601
|
/** @type {PathDoesNotBeginWith} */
|
|
1602
|
+
exports.comparePaths = comparePaths;
|
|
1536
1603
|
const pathDoesNotBeginWith = (name, otherPathName) => {
|
|
1537
1604
|
return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
|
|
1538
1605
|
};
|
|
@@ -1542,6 +1609,7 @@ const pathDoesNotBeginWith = (name, otherPathName) => {
|
|
|
1542
1609
|
* @param {string} [requiredFlags]
|
|
1543
1610
|
* @returns {RegExp}
|
|
1544
1611
|
*/
|
|
1612
|
+
exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
|
|
1545
1613
|
const getRegexFromString = (regexString, requiredFlags) => {
|
|
1546
1614
|
const match = regexString.match(/^\/(.*)\/([gimyvus]*)$/vs);
|
|
1547
1615
|
let flags = 'v';
|
|
@@ -1556,7 +1624,8 @@ const getRegexFromString = (regexString, requiredFlags) => {
|
|
|
1556
1624
|
flags = uniqueFlags.join('');
|
|
1557
1625
|
return new RegExp(regex, flags);
|
|
1558
1626
|
};
|
|
1559
|
-
|
|
1627
|
+
exports.getRegexFromString = getRegexFromString;
|
|
1628
|
+
const strictNativeTypes = exports.strictNativeTypes = ['undefined', 'null', 'boolean', 'number', 'bigint', 'string', 'symbol', 'object', 'Array', 'Function', 'Date', 'RegExp'];
|
|
1560
1629
|
|
|
1561
1630
|
/**
|
|
1562
1631
|
* @param {import('@es-joy/jsdoccomment').JsdocBlockWithInline} jsdoc
|
|
@@ -1566,7 +1635,7 @@ const strictNativeTypes = ['undefined', 'null', 'boolean', 'number', 'bigint', '
|
|
|
1566
1635
|
* @param {string} typeBracketSpacing
|
|
1567
1636
|
*/
|
|
1568
1637
|
const rewireByParsedType = (jsdoc, tag, parsedType, indent, typeBracketSpacing = '') => {
|
|
1569
|
-
const typeLines = stringify(parsedType).split('\n');
|
|
1638
|
+
const typeLines = (0, _jsdoccomment.stringify)(parsedType).split('\n');
|
|
1570
1639
|
const firstTypeLine = typeLines.shift();
|
|
1571
1640
|
const lastTypeLine = typeLines.pop();
|
|
1572
1641
|
const beginNameOrDescIdx = tag.source.findIndex(({
|
|
@@ -1713,6 +1782,5 @@ const rewireByParsedType = (jsdoc, tag, parsedType, indent, typeBracketSpacing =
|
|
|
1713
1782
|
jsdoc.source.push(initialEndSource);
|
|
1714
1783
|
}
|
|
1715
1784
|
};
|
|
1716
|
-
|
|
1717
|
-
export { hasReturnValue, hasValueOrExecutorHasNonEmptyResolveValue } from './utils/hasReturnValue.js';
|
|
1785
|
+
exports.rewireByParsedType = rewireByParsedType;
|
|
1718
1786
|
//# sourceMappingURL=jsdocUtils.cjs.map
|