eslint-plugin-jsdoc 52.0.4 → 53.0.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/dist/WarnSettings.cjs +18 -35
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/WarnSettings.js +20 -0
- package/dist/WarnSettings.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +32 -0
- package/dist/_virtual/rolldown_runtime.js +11 -0
- package/dist/alignTransform.cjs +224 -305
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/alignTransform.js +241 -0
- package/dist/alignTransform.js.map +1 -0
- package/dist/defaultTagOrder.cjs +132 -43
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/defaultTagOrder.js +134 -0
- package/dist/defaultTagOrder.js.map +1 -0
- package/dist/exportParser.cjs +478 -696
- package/dist/exportParser.cjs.map +1 -1
- package/dist/exportParser.js +518 -0
- package/dist/exportParser.js.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +184 -288
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.js +188 -0
- package/dist/getDefaultTagStructureForMode.js.map +1 -0
- package/dist/getJsdocProcessorPlugin.cjs +364 -550
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.cts +70 -0
- package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
- package/dist/getJsdocProcessorPlugin.d.ts +68 -65
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/getJsdocProcessorPlugin.js +383 -0
- package/dist/getJsdocProcessorPlugin.js.map +1 -0
- package/dist/index.cjs +2 -410
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -17
- package/dist/index.js +3 -0
- package/dist/iterateJsdoc.cjs +1539 -1988
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.cts +472 -0
- package/dist/iterateJsdoc.d.cts.map +1 -0
- package/dist/iterateJsdoc.d.ts +359 -349
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/iterateJsdoc.js +1628 -0
- package/dist/iterateJsdoc.js.map +1 -0
- package/dist/jsdocUtils.cjs +1009 -1376
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.js +1123 -0
- package/dist/jsdocUtils.js.map +1 -0
- package/dist/plugin.cjs +427 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +427 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/checkAccess.cjs +29 -36
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAccess.js +33 -0
- package/dist/rules/checkAccess.js.map +1 -0
- package/dist/rules/checkAlignment.cjs +41 -54
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkAlignment.js +47 -0
- package/dist/rules/checkAlignment.js.map +1 -0
- package/dist/rules/checkExamples.cjs +327 -484
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkExamples.js +348 -0
- package/dist/rules/checkExamples.js.map +1 -0
- package/dist/rules/checkIndentation.cjs +50 -65
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkIndentation.js +59 -0
- package/dist/rules/checkIndentation.js.map +1 -0
- package/dist/rules/checkLineAlignment.cjs +220 -311
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.js +229 -0
- package/dist/rules/checkLineAlignment.js.map +1 -0
- package/dist/rules/checkParamNames.cjs +227 -335
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkParamNames.js +237 -0
- package/dist/rules/checkParamNames.js.map +1 -0
- package/dist/rules/checkPropertyNames.cjs +78 -106
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.js +88 -0
- package/dist/rules/checkPropertyNames.js.map +1 -0
- package/dist/rules/checkSyntax.cjs +21 -34
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkSyntax.js +25 -0
- package/dist/rules/checkSyntax.js.map +1 -0
- package/dist/rules/checkTagNames.cjs +188 -210
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.js +191 -0
- package/dist/rules/checkTagNames.js.map +1 -0
- package/dist/rules/checkTemplateNames.cjs +121 -178
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.js +124 -0
- package/dist/rules/checkTemplateNames.js.map +1 -0
- package/dist/rules/checkTypes.cjs +291 -385
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkTypes.js +299 -0
- package/dist/rules/checkTypes.js.map +1 -0
- package/dist/rules/checkValues.cjs +100 -146
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/checkValues.js +103 -0
- package/dist/rules/checkValues.js.map +1 -0
- package/dist/rules/convertToJsdocComments.cjs +228 -306
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.js +231 -0
- package/dist/rules/convertToJsdocComments.js.map +1 -0
- package/dist/rules/emptyTags.cjs +62 -72
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/emptyTags.js +67 -0
- package/dist/rules/emptyTags.js.map +1 -0
- package/dist/rules/implementsOnClasses.cjs +36 -56
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.js +40 -0
- package/dist/rules/implementsOnClasses.js.map +1 -0
- package/dist/rules/importsAsDependencies.cjs +62 -99
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.js +68 -0
- package/dist/rules/importsAsDependencies.js.map +1 -0
- package/dist/rules/informativeDocs.cjs +105 -142
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/informativeDocs.js +110 -0
- package/dist/rules/informativeDocs.js.map +1 -0
- package/dist/rules/linesBeforeBlock.cjs +70 -105
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.js +75 -0
- package/dist/rules/linesBeforeBlock.js.map +1 -0
- package/dist/rules/matchDescription.cjs +160 -222
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchDescription.js +167 -0
- package/dist/rules/matchDescription.js.map +1 -0
- package/dist/rules/matchName.cjs +73 -128
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/matchName.js +77 -0
- package/dist/rules/matchName.js.map +1 -0
- package/dist/rules/multilineBlocks.cjs +235 -352
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/multilineBlocks.js +245 -0
- package/dist/rules/multilineBlocks.js.map +1 -0
- package/dist/rules/noBadBlocks.cjs +63 -86
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.js +68 -0
- package/dist/rules/noBadBlocks.js.map +1 -0
- package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +41 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
- package/dist/rules/noBlankBlocks.cjs +26 -48
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.js +30 -0
- package/dist/rules/noBlankBlocks.js.map +1 -0
- package/dist/rules/noDefaults.cjs +52 -79
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noDefaults.js +56 -0
- package/dist/rules/noDefaults.js.map +1 -0
- package/dist/rules/noMissingSyntax.cjs +115 -165
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.js +126 -0
- package/dist/rules/noMissingSyntax.js.map +1 -0
- package/dist/rules/noMultiAsterisks.cjs +48 -89
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.js +58 -0
- package/dist/rules/noMultiAsterisks.js.map +1 -0
- package/dist/rules/noRestrictedSyntax.cjs +45 -79
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +49 -0
- package/dist/rules/noRestrictedSyntax.js.map +1 -0
- package/dist/rules/noTypes.cjs +59 -80
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noTypes.js +65 -0
- package/dist/rules/noTypes.js.map +1 -0
- package/dist/rules/noUndefinedTypes.cjs +297 -388
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.js +303 -0
- package/dist/rules/noUndefinedTypes.js.map +1 -0
- package/dist/rules/requireAsteriskPrefix.cjs +108 -159
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +112 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -0
- package/dist/rules/requireDescription.cjs +89 -129
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescription.js +95 -0
- package/dist/rules/requireDescription.js.map +1 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
- package/dist/rules/requireExample.cjs +73 -104
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireExample.js +77 -0
- package/dist/rules/requireExample.js.map +1 -0
- package/dist/rules/requireFileOverview.cjs +75 -129
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireFileOverview.js +81 -0
- package/dist/rules/requireFileOverview.js.map +1 -0
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
- package/dist/rules/requireJsdoc.cjs +384 -557
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireJsdoc.js +404 -0
- package/dist/rules/requireJsdoc.js.map +1 -0
- package/dist/rules/requireParam.cjs +336 -526
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParam.js +344 -0
- package/dist/rules/requireParam.js.map +1 -0
- package/dist/rules/requireParamDescription.cjs +55 -80
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamDescription.js +59 -0
- package/dist/rules/requireParamDescription.js.map +1 -0
- package/dist/rules/requireParamName.cjs +32 -50
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamName.js +36 -0
- package/dist/rules/requireParamName.js.map +1 -0
- package/dist/rules/requireParamType.cjs +55 -80
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireParamType.js +59 -0
- package/dist/rules/requireParamType.js.map +1 -0
- package/dist/rules/requireProperty.cjs +31 -42
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requireProperty.js +35 -0
- package/dist/rules/requireProperty.js.map +1 -0
- package/dist/rules/requirePropertyDescription.cjs +17 -25
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.js +21 -0
- package/dist/rules/requirePropertyDescription.js.map +1 -0
- package/dist/rules/requirePropertyName.cjs +17 -25
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyName.js +21 -0
- package/dist/rules/requirePropertyName.js.map +1 -0
- package/dist/rules/requirePropertyType.cjs +17 -25
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requirePropertyType.js +21 -0
- package/dist/rules/requirePropertyType.js.map +1 -0
- package/dist/rules/requireReturns.cjs +125 -203
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturns.js +131 -0
- package/dist/rules/requireReturns.js.map +1 -0
- package/dist/rules/requireReturnsCheck.cjs +60 -103
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.js +66 -0
- package/dist/rules/requireReturnsCheck.js.map +1 -0
- package/dist/rules/requireReturnsDescription.cjs +39 -54
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.js +43 -0
- package/dist/rules/requireReturnsDescription.js.map +1 -0
- package/dist/rules/requireReturnsType.cjs +32 -50
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireReturnsType.js +36 -0
- package/dist/rules/requireReturnsType.js.map +1 -0
- package/dist/rules/requireTemplate.cjs +119 -178
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireTemplate.js +122 -0
- package/dist/rules/requireTemplate.js.map +1 -0
- package/dist/rules/requireThrows.cjs +61 -95
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireThrows.js +67 -0
- package/dist/rules/requireThrows.js.map +1 -0
- package/dist/rules/requireYields.cjs +106 -166
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYields.js +115 -0
- package/dist/rules/requireYields.js.map +1 -0
- package/dist/rules/requireYieldsCheck.cjs +96 -152
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.js +105 -0
- package/dist/rules/requireYieldsCheck.js.map +1 -0
- package/dist/rules/sortTags.cjs +258 -444
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/sortTags.js +262 -0
- package/dist/rules/sortTags.js.map +1 -0
- package/dist/rules/tagLines.cjs +179 -266
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/tagLines.js +183 -0
- package/dist/rules/tagLines.js.map +1 -0
- package/dist/rules/textEscaping.cjs +92 -127
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/textEscaping.js +102 -0
- package/dist/rules/textEscaping.js.map +1 -0
- package/dist/rules/validTypes.cjs +252 -265
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/rules/validTypes.js +259 -0
- package/dist/rules/validTypes.js.map +1 -0
- package/dist/tagNames.cjs +134 -170
- package/dist/tagNames.cjs.map +1 -1
- package/dist/tagNames.js +144 -0
- package/dist/tagNames.js.map +1 -0
- package/dist/utils/hasReturnValue.cjs +246 -474
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/dist/utils/hasReturnValue.js +265 -0
- package/dist/utils/hasReturnValue.js.map +1 -0
- package/package.json +40 -24
- package/dist/generateRule.cjs +0 -242
- package/dist/generateRule.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/WarnSettings.js +0 -34
- package/src/alignTransform.js +0 -358
- package/src/defaultTagOrder.js +0 -169
- package/src/exportParser.js +0 -978
- package/src/getDefaultTagStructureForMode.js +0 -969
- package/src/getJsdocProcessorPlugin.js +0 -672
- package/src/index.js +0 -530
- package/src/iterateJsdoc.js +0 -2518
- package/src/jsdocUtils.js +0 -1896
- package/src/rules/checkAccess.js +0 -45
- package/src/rules/checkAlignment.js +0 -63
- package/src/rules/checkExamples.js +0 -589
- package/src/rules/checkIndentation.js +0 -75
- package/src/rules/checkLineAlignment.js +0 -372
- package/src/rules/checkParamNames.js +0 -474
- package/src/rules/checkPropertyNames.js +0 -152
- package/src/rules/checkSyntax.js +0 -30
- package/src/rules/checkTagNames.js +0 -314
- package/src/rules/checkTemplateNames.js +0 -204
- package/src/rules/checkTypes.js +0 -535
- package/src/rules/checkValues.js +0 -248
- package/src/rules/convertToJsdocComments.js +0 -398
- package/src/rules/emptyTags.js +0 -98
- package/src/rules/implementsOnClasses.js +0 -64
- package/src/rules/importsAsDependencies.js +0 -133
- package/src/rules/informativeDocs.js +0 -189
- package/src/rules/linesBeforeBlock.js +0 -134
- package/src/rules/matchDescription.js +0 -286
- package/src/rules/matchName.js +0 -151
- package/src/rules/multilineBlocks.js +0 -493
- package/src/rules/noBadBlocks.js +0 -119
- package/src/rules/noBlankBlockDescriptions.js +0 -69
- package/src/rules/noBlankBlocks.js +0 -53
- package/src/rules/noDefaults.js +0 -85
- package/src/rules/noMissingSyntax.js +0 -195
- package/src/rules/noMultiAsterisks.js +0 -134
- package/src/rules/noRestrictedSyntax.js +0 -91
- package/src/rules/noTypes.js +0 -93
- package/src/rules/noUndefinedTypes.js +0 -543
- package/src/rules/requireAsteriskPrefix.js +0 -190
- package/src/rules/requireDescription.js +0 -161
- package/src/rules/requireDescriptionCompleteSentence.js +0 -335
- package/src/rules/requireExample.js +0 -118
- package/src/rules/requireFileOverview.js +0 -154
- package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
- package/src/rules/requireJsdoc.js +0 -743
- package/src/rules/requireParam.js +0 -602
- package/src/rules/requireParamDescription.js +0 -89
- package/src/rules/requireParamName.js +0 -55
- package/src/rules/requireParamType.js +0 -89
- package/src/rules/requireProperty.js +0 -48
- package/src/rules/requirePropertyDescription.js +0 -25
- package/src/rules/requirePropertyName.js +0 -25
- package/src/rules/requirePropertyType.js +0 -25
- package/src/rules/requireReturns.js +0 -238
- package/src/rules/requireReturnsCheck.js +0 -145
- package/src/rules/requireReturnsDescription.js +0 -59
- package/src/rules/requireReturnsType.js +0 -51
- package/src/rules/requireTemplate.js +0 -201
- package/src/rules/requireThrows.js +0 -111
- package/src/rules/requireYields.js +0 -216
- package/src/rules/requireYieldsCheck.js +0 -208
- package/src/rules/sortTags.js +0 -558
- package/src/rules/tagLines.js +0 -359
- package/src/rules/textEscaping.js +0 -154
- package/src/rules/validTypes.js +0 -401
- package/src/tagNames.js +0 -238
- package/src/utils/hasReturnValue.js +0 -572
package/dist/jsdocUtils.cjs
CHANGED
|
@@ -1,1527 +1,1160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_getDefaultTagStructureForMode = require('./getDefaultTagStructureForMode.cjs');
|
|
3
|
+
const require_tagNames = require('./tagNames.cjs');
|
|
4
|
+
const require_WarnSettings = require('./WarnSettings.cjs');
|
|
5
|
+
const require_hasReturnValue = require('./utils/hasReturnValue.cjs');
|
|
6
|
+
const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
|
|
7
|
+
|
|
8
|
+
//#region src/jsdocUtils.js
|
|
9
|
+
var jsdocUtils_exports = {};
|
|
10
|
+
require_rolldown_runtime.__export(jsdocUtils_exports, {
|
|
11
|
+
comparePaths: () => comparePaths,
|
|
12
|
+
dropPathSegmentQuotes: () => dropPathSegmentQuotes,
|
|
13
|
+
enforcedContexts: () => enforcedContexts,
|
|
14
|
+
exemptSpeciaMethods: () => exemptSpeciaMethods,
|
|
15
|
+
filterTags: () => filterTags,
|
|
16
|
+
flattenRoots: () => flattenRoots,
|
|
17
|
+
forEachPreferredTag: () => forEachPreferredTag,
|
|
18
|
+
getAllTags: () => getAllTags,
|
|
19
|
+
getContextObject: () => getContextObject,
|
|
20
|
+
getFunctionParameterNames: () => getFunctionParameterNames,
|
|
21
|
+
getIndent: () => getIndent,
|
|
22
|
+
getJsdocTagsDeep: () => getJsdocTagsDeep,
|
|
23
|
+
getPreferredTagName: () => getPreferredTagName,
|
|
24
|
+
getPreferredTagNameSimple: () => getPreferredTagNameSimple,
|
|
25
|
+
getRegexFromString: () => getRegexFromString,
|
|
26
|
+
getTagDescription: () => getTagDescription,
|
|
27
|
+
getTagStructureForMode: () => getTagStructureForMode,
|
|
28
|
+
getTags: () => getTags,
|
|
29
|
+
getTagsByType: () => getTagsByType,
|
|
30
|
+
hasATag: () => hasATag,
|
|
31
|
+
hasParams: () => hasParams,
|
|
32
|
+
hasReturnValue: () => require_hasReturnValue.hasReturnValue,
|
|
33
|
+
hasTag: () => hasTag,
|
|
34
|
+
hasThrowValue: () => hasThrowValue,
|
|
35
|
+
hasValueOrExecutorHasNonEmptyResolveValue: () => require_hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue,
|
|
36
|
+
hasYieldValue: () => hasYieldValue,
|
|
37
|
+
isConstructor: () => isConstructor,
|
|
38
|
+
isGetter: () => isGetter,
|
|
39
|
+
isNamepathDefiningTag: () => isNamepathDefiningTag,
|
|
40
|
+
isNamepathOrUrlReferencingTag: () => isNamepathOrUrlReferencingTag,
|
|
41
|
+
isNamepathReferencingTag: () => isNamepathReferencingTag,
|
|
42
|
+
isSetter: () => isSetter,
|
|
43
|
+
isValidTag: () => isValidTag,
|
|
44
|
+
mayBeUndefinedTypeTag: () => mayBeUndefinedTypeTag,
|
|
45
|
+
overrideTagStructure: () => overrideTagStructure,
|
|
46
|
+
parseClosureTemplateTag: () => parseClosureTemplateTag,
|
|
47
|
+
pathDoesNotBeginWith: () => pathDoesNotBeginWith,
|
|
48
|
+
setTagStructure: () => setTagStructure,
|
|
49
|
+
tagMightHaveEitherTypeOrNamePosition: () => tagMightHaveEitherTypeOrNamePosition,
|
|
50
|
+
tagMightHaveNamePosition: () => tagMightHaveNamePosition,
|
|
51
|
+
tagMightHaveNamepath: () => tagMightHaveNamepath,
|
|
52
|
+
tagMightHaveTypePosition: () => tagMightHaveTypePosition,
|
|
53
|
+
tagMissingRequiredTypeOrNamepath: () => tagMissingRequiredTypeOrNamepath,
|
|
54
|
+
tagMustHaveNamePosition: () => tagMustHaveNamePosition,
|
|
55
|
+
tagMustHaveTypePosition: () => tagMustHaveTypePosition
|
|
19
56
|
});
|
|
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;
|
|
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 }; }
|
|
27
57
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
58
|
+
* @typedef {number} Integer
|
|
59
|
+
*/
|
|
30
60
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
* @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode
|
|
62
|
+
*/
|
|
34
63
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
64
|
+
* @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode
|
|
65
|
+
*/
|
|
38
66
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
* @type {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
68
|
+
*/
|
|
41
69
|
let tagStructure;
|
|
42
|
-
|
|
43
70
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const setTagStructure = mode => {
|
|
48
|
-
|
|
71
|
+
* @param {ParserMode} mode
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
const setTagStructure = (mode) => {
|
|
75
|
+
tagStructure = require_getDefaultTagStructureForMode.default(mode);
|
|
49
76
|
};
|
|
50
|
-
|
|
51
77
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
* @typedef {undefined|string|{
|
|
79
|
+
* name: Integer,
|
|
80
|
+
* restElement: boolean
|
|
81
|
+
* }|{
|
|
82
|
+
* isRestProperty: boolean|undefined,
|
|
83
|
+
* name: string,
|
|
84
|
+
* restElement: boolean
|
|
85
|
+
* }|{
|
|
86
|
+
* name: string,
|
|
87
|
+
* restElement: boolean
|
|
88
|
+
* }} ParamCommon
|
|
89
|
+
*/
|
|
64
90
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
* @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
|
|
92
|
+
* annotationParamName?: string,
|
|
93
|
+
* })]|NestedParamInfo} ParamNameInfo
|
|
94
|
+
*/
|
|
70
95
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
* @typedef {{
|
|
97
|
+
* hasPropertyRest: boolean,
|
|
98
|
+
* hasRestElement: boolean,
|
|
99
|
+
* names: string[],
|
|
100
|
+
* rests: boolean[],
|
|
101
|
+
* }} FlattendRootInfo
|
|
102
|
+
*/
|
|
78
103
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
* @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
|
|
105
|
+
*/
|
|
81
106
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
* @typedef {ParamCommon|
|
|
108
|
+
* [string|undefined, (FlattendRootInfo & {
|
|
109
|
+
* annotationParamName?: string
|
|
110
|
+
* })]|
|
|
111
|
+
* NestedParamInfo} ParamInfo
|
|
112
|
+
*/
|
|
89
113
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
* Given a nested array of property names, reduce them to a single array,
|
|
115
|
+
* appending the name of the root element along the way if present.
|
|
116
|
+
* @callback FlattenRoots
|
|
117
|
+
* @param {ParamInfo[]} params
|
|
118
|
+
* @param {string} [root]
|
|
119
|
+
* @returns {FlattendRootInfo}
|
|
120
|
+
*/
|
|
98
121
|
/** @type {FlattenRoots} */
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name));
|
|
150
|
-
} else if (typeof cur !== 'undefined') {
|
|
151
|
-
rests.push(false);
|
|
152
|
-
acc.push(root ? `${root}.${cur}` : cur);
|
|
153
|
-
}
|
|
154
|
-
return acc;
|
|
155
|
-
}, []);
|
|
156
|
-
return {
|
|
157
|
-
hasPropertyRest,
|
|
158
|
-
hasRestElement,
|
|
159
|
-
names,
|
|
160
|
-
rests
|
|
161
|
-
};
|
|
122
|
+
const flattenRoots = (params, root = "") => {
|
|
123
|
+
let hasRestElement = false;
|
|
124
|
+
let hasPropertyRest = false;
|
|
125
|
+
/**
|
|
126
|
+
* @type {boolean[]}
|
|
127
|
+
*/
|
|
128
|
+
const rests = [];
|
|
129
|
+
const names = params.reduce(
|
|
130
|
+
/**
|
|
131
|
+
* @param {string[]} acc
|
|
132
|
+
* @param {ParamInfo} cur
|
|
133
|
+
* @returns {string[]}
|
|
134
|
+
*/
|
|
135
|
+
(acc, cur) => {
|
|
136
|
+
if (Array.isArray(cur)) {
|
|
137
|
+
let nms;
|
|
138
|
+
if (Array.isArray(cur[1])) nms = cur[1];
|
|
139
|
+
else {
|
|
140
|
+
if (cur[1].hasRestElement) hasRestElement = true;
|
|
141
|
+
if (cur[1].hasPropertyRest) hasPropertyRest = true;
|
|
142
|
+
nms = cur[1].names;
|
|
143
|
+
}
|
|
144
|
+
const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]);
|
|
145
|
+
if (flattened.hasRestElement) hasRestElement = true;
|
|
146
|
+
if (flattened.hasPropertyRest) hasPropertyRest = true;
|
|
147
|
+
const inner = [root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
|
|
148
|
+
rests.push(false, ...flattened.rests);
|
|
149
|
+
return acc.concat(inner);
|
|
150
|
+
}
|
|
151
|
+
if (typeof cur === "object") {
|
|
152
|
+
if ("isRestProperty" in cur && cur.isRestProperty) {
|
|
153
|
+
hasPropertyRest = true;
|
|
154
|
+
rests.push(true);
|
|
155
|
+
} else rests.push(false);
|
|
156
|
+
if ("restElement" in cur && cur.restElement) hasRestElement = true;
|
|
157
|
+
acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name));
|
|
158
|
+
} else if (typeof cur !== "undefined") {
|
|
159
|
+
rests.push(false);
|
|
160
|
+
acc.push(root ? `${root}.${cur}` : cur);
|
|
161
|
+
}
|
|
162
|
+
return acc;
|
|
163
|
+
},
|
|
164
|
+
[]
|
|
165
|
+
);
|
|
166
|
+
return {
|
|
167
|
+
hasPropertyRest,
|
|
168
|
+
hasRestElement,
|
|
169
|
+
names,
|
|
170
|
+
rests
|
|
171
|
+
};
|
|
162
172
|
};
|
|
163
|
-
|
|
164
173
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return [/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => {
|
|
178
|
-
return /** @type {string} */getPropertiesFromPropertySignature(/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
|
|
179
|
-
member);
|
|
180
|
-
})];
|
|
181
|
-
}
|
|
182
|
-
return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name;
|
|
174
|
+
* @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature|
|
|
175
|
+
* import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration|
|
|
176
|
+
* import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration|
|
|
177
|
+
* import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
|
|
178
|
+
* @returns {undefined|string|[string, string[]]}
|
|
179
|
+
*/
|
|
180
|
+
const getPropertiesFromPropertySignature = (propSignature) => {
|
|
181
|
+
if (propSignature.type === "TSIndexSignature" || propSignature.type === "TSConstructSignatureDeclaration" || propSignature.type === "TSCallSignatureDeclaration") return void 0;
|
|
182
|
+
if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === "TSTypeLiteral") return [propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map((member) => {
|
|
183
|
+
return getPropertiesFromPropertySignature(member);
|
|
184
|
+
})];
|
|
185
|
+
return propSignature.key.name;
|
|
183
186
|
};
|
|
184
|
-
|
|
185
187
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
* @param {ESTreeOrTypeScriptNode|null} functionNode
|
|
189
|
+
* @param {boolean} [checkDefaultObjects]
|
|
190
|
+
* @throws {Error}
|
|
191
|
+
* @returns {ParamNameInfo[]}
|
|
192
|
+
*/
|
|
191
193
|
const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return /** @type {string} */param.key.raw || param.key.value;
|
|
298
|
-
|
|
299
|
-
// case 'MemberExpression':
|
|
300
|
-
default:
|
|
301
|
-
// Todo: We should really create a structure (and a corresponding
|
|
302
|
-
// option analogous to `checkRestProperty`) which allows for
|
|
303
|
-
// (and optionally requires) dynamic properties to have a single
|
|
304
|
-
// line of documentation
|
|
305
|
-
return undefined;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */param.left?.type === 'ArrayPattern') {
|
|
309
|
-
const elements = /** @type {import('estree').ArrayPattern} */param.elements || /** @type {import('estree').ArrayPattern} */(/** @type {import('estree').AssignmentPattern} */param.left)?.elements;
|
|
310
|
-
const roots = elements.map((prop, idx) => {
|
|
311
|
-
return {
|
|
312
|
-
name: `"${idx}"`,
|
|
313
|
-
restElement: prop?.type === 'RestElement'
|
|
314
|
-
};
|
|
315
|
-
});
|
|
316
|
-
return [undefined, flattenRoots(roots)];
|
|
317
|
-
}
|
|
318
|
-
if (['ExperimentalRestProperty', 'RestElement'].includes(param.type)) {
|
|
319
|
-
return {
|
|
320
|
-
isRestProperty: isProperty,
|
|
321
|
-
name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */(/** @type {import('@typescript-eslint/types').TSESTree.RestElement} */param
|
|
322
|
-
// @ts-expect-error Ok
|
|
323
|
-
.argument).name ?? param?.argument?.elements?.map(({
|
|
324
|
-
// @ts-expect-error Ok
|
|
325
|
-
name
|
|
326
|
-
}) => {
|
|
327
|
-
return name;
|
|
328
|
-
}),
|
|
329
|
-
restElement: true
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
if (param.type === 'TSParameterProperty') {
|
|
333
|
-
return getParamName(/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
|
|
334
|
-
/** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */param.parameter, true);
|
|
335
|
-
}
|
|
336
|
-
throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
|
|
337
|
-
};
|
|
338
|
-
if (!functionNode) {
|
|
339
|
-
return [];
|
|
340
|
-
}
|
|
341
|
-
return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */functionNode.value?.params || []).map(param => {
|
|
342
|
-
return getParamName(param);
|
|
343
|
-
});
|
|
194
|
+
/**
|
|
195
|
+
* @param {import('estree').Identifier|import('estree').AssignmentPattern|
|
|
196
|
+
* import('estree').ObjectPattern|import('estree').Property|
|
|
197
|
+
* import('estree').RestElement|import('estree').ArrayPattern|
|
|
198
|
+
* import('@typescript-eslint/types').TSESTree.TSParameterProperty|
|
|
199
|
+
* import('@typescript-eslint/types').TSESTree.Property|
|
|
200
|
+
* import('@typescript-eslint/types').TSESTree.RestElement|
|
|
201
|
+
* import('@typescript-eslint/types').TSESTree.Identifier|
|
|
202
|
+
* import('@typescript-eslint/types').TSESTree.ObjectPattern|
|
|
203
|
+
* import('@typescript-eslint/types').TSESTree.BindingName|
|
|
204
|
+
* import('@typescript-eslint/types').TSESTree.Parameter
|
|
205
|
+
* } param
|
|
206
|
+
* @param {boolean} [isProperty]
|
|
207
|
+
* @returns {ParamNameInfo|[string, ParamNameInfo[]]}
|
|
208
|
+
*/
|
|
209
|
+
const getParamName = (param, isProperty) => {
|
|
210
|
+
const hasLeftTypeAnnotation = "left" in param && "typeAnnotation" in param.left;
|
|
211
|
+
if ("typeAnnotation" in param || hasLeftTypeAnnotation) {
|
|
212
|
+
const typeAnnotation = hasLeftTypeAnnotation ? param.left.typeAnnotation : param.typeAnnotation;
|
|
213
|
+
if (typeAnnotation?.typeAnnotation?.type === "TSTypeLiteral") {
|
|
214
|
+
const propertyNames = typeAnnotation.typeAnnotation.members.map((member) => {
|
|
215
|
+
return getPropertiesFromPropertySignature(member);
|
|
216
|
+
});
|
|
217
|
+
const flattened = {
|
|
218
|
+
...flattenRoots(propertyNames),
|
|
219
|
+
annotationParamName: "name" in param ? param.name : void 0
|
|
220
|
+
};
|
|
221
|
+
const hasLeftName = "left" in param && "name" in param.left;
|
|
222
|
+
if ("name" in param || hasLeftName) return [hasLeftName ? param.left.name : param.name, flattened];
|
|
223
|
+
return [void 0, flattened];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if ("name" in param) return param.name;
|
|
227
|
+
if ("left" in param && "name" in param.left) return param.left.name;
|
|
228
|
+
if (param.type === "ObjectPattern" || "left" in param && param.left.type === "ObjectPattern") {
|
|
229
|
+
const properties = param.properties || param.left?.properties;
|
|
230
|
+
const roots = properties.map((prop) => {
|
|
231
|
+
return getParamName(prop, true);
|
|
232
|
+
});
|
|
233
|
+
return [void 0, flattenRoots(roots)];
|
|
234
|
+
}
|
|
235
|
+
if (param.type === "Property") {
|
|
236
|
+
switch (param.value.type) {
|
|
237
|
+
case "ArrayPattern": return [param.key.name, param.value.elements.map((prop, idx) => {
|
|
238
|
+
return {
|
|
239
|
+
name: idx,
|
|
240
|
+
restElement: prop?.type === "RestElement"
|
|
241
|
+
};
|
|
242
|
+
})];
|
|
243
|
+
case "ObjectPattern": return [param.key.name, param.value.properties.map((prop) => {
|
|
244
|
+
return getParamName(prop, isProperty);
|
|
245
|
+
})];
|
|
246
|
+
case "AssignmentPattern": switch (param.value.left.type) {
|
|
247
|
+
case "ArrayPattern": return [param.key.name, param.value.left.elements.map((prop, idx) => {
|
|
248
|
+
return {
|
|
249
|
+
name: idx,
|
|
250
|
+
restElement: prop?.type === "RestElement"
|
|
251
|
+
};
|
|
252
|
+
})];
|
|
253
|
+
case "Identifier":
|
|
254
|
+
if (checkDefaultObjects && param.value.right.type === "ObjectExpression") return [param.key.name, param.value.right.properties.map((prop) => {
|
|
255
|
+
return getParamName(prop, isProperty);
|
|
256
|
+
})];
|
|
257
|
+
break;
|
|
258
|
+
case "ObjectPattern": return [param.key.name, param.value.left.properties.map((prop) => {
|
|
259
|
+
return getParamName(prop, isProperty);
|
|
260
|
+
})];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
switch (param.key.type) {
|
|
264
|
+
case "Identifier": return param.key.name;
|
|
265
|
+
case "Literal":
|
|
266
|
+
/* c8 ignore next 2 -- `raw` may not be present in all parsers */
|
|
267
|
+
return param.key.raw || param.key.value;
|
|
268
|
+
default: return void 0;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (param.type === "ArrayPattern" || param.left?.type === "ArrayPattern") {
|
|
272
|
+
const elements = param.elements || param.left?.elements;
|
|
273
|
+
const roots = elements.map((prop, idx) => {
|
|
274
|
+
return {
|
|
275
|
+
name: `"${idx}"`,
|
|
276
|
+
restElement: prop?.type === "RestElement"
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
return [void 0, flattenRoots(roots)];
|
|
280
|
+
}
|
|
281
|
+
if (["ExperimentalRestProperty", "RestElement"].includes(param.type)) return {
|
|
282
|
+
isRestProperty: isProperty,
|
|
283
|
+
name: param.argument.name ?? param?.argument?.elements?.map(({ name }) => {
|
|
284
|
+
return name;
|
|
285
|
+
}),
|
|
286
|
+
restElement: true
|
|
287
|
+
};
|
|
288
|
+
if (param.type === "TSParameterProperty") return getParamName(
|
|
289
|
+
/** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */
|
|
290
|
+
param.parameter,
|
|
291
|
+
true
|
|
292
|
+
);
|
|
293
|
+
throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
|
|
294
|
+
};
|
|
295
|
+
if (!functionNode) return [];
|
|
296
|
+
return (functionNode.params || functionNode.value?.params || []).map((param) => {
|
|
297
|
+
return getParamName(param);
|
|
298
|
+
});
|
|
344
299
|
};
|
|
345
|
-
|
|
346
300
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
// Should also check `functionNode.value.params` if supporting `MethodDefinition`
|
|
353
|
-
return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length;
|
|
301
|
+
* @param {ESTreeOrTypeScriptNode} functionNode
|
|
302
|
+
* @returns {Integer}
|
|
303
|
+
*/
|
|
304
|
+
const hasParams = (functionNode) => {
|
|
305
|
+
return functionNode.params.length;
|
|
354
306
|
};
|
|
355
|
-
|
|
356
307
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
exports.hasParams = hasParams;
|
|
308
|
+
* Gets all names of the target type, including those that refer to a path, e.g.
|
|
309
|
+
* `foo` or `foo.bar`.
|
|
310
|
+
* @param {import('comment-parser').Block} jsdoc
|
|
311
|
+
* @param {string} targetTagName
|
|
312
|
+
* @returns {{
|
|
313
|
+
* idx: Integer,
|
|
314
|
+
* name: string,
|
|
315
|
+
* type: string
|
|
316
|
+
* }[]}
|
|
317
|
+
*/
|
|
368
318
|
const getJsdocTagsDeep = (jsdoc, targetTagName) => {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
idx,
|
|
380
|
-
name,
|
|
381
|
-
type
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
return ret;
|
|
319
|
+
const ret = [];
|
|
320
|
+
for (const [idx, { name, tag, type }] of jsdoc.tags.entries()) {
|
|
321
|
+
if (tag !== targetTagName) continue;
|
|
322
|
+
ret.push({
|
|
323
|
+
idx,
|
|
324
|
+
name,
|
|
325
|
+
type
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return ret;
|
|
385
329
|
};
|
|
386
|
-
|
|
387
|
-
const modeWarnSettings = (0, _WarnSettings.default)();
|
|
388
|
-
|
|
330
|
+
const modeWarnSettings = require_WarnSettings.default();
|
|
389
331
|
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
332
|
+
* @param {ParserMode|undefined} mode
|
|
333
|
+
* @param {Reporter} context
|
|
334
|
+
* @returns {import('./tagNames.js').AliasedTags}
|
|
335
|
+
*/
|
|
394
336
|
const getTagNamesForMode = (mode, context) => {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// We'll avoid breaking too many other rules
|
|
422
|
-
return _tagNames.jsdocTags;
|
|
423
|
-
}
|
|
337
|
+
switch (mode) {
|
|
338
|
+
case "closure":
|
|
339
|
+
case "permissive": return require_tagNames.closureTags;
|
|
340
|
+
case "jsdoc": return require_tagNames.jsdocTags;
|
|
341
|
+
case "typescript": return require_tagNames.typeScriptTags;
|
|
342
|
+
default:
|
|
343
|
+
if (!modeWarnSettings.hasBeenWarned(context, "mode")) {
|
|
344
|
+
context.report({
|
|
345
|
+
loc: {
|
|
346
|
+
end: {
|
|
347
|
+
column: 1,
|
|
348
|
+
line: 1
|
|
349
|
+
},
|
|
350
|
+
start: {
|
|
351
|
+
column: 1,
|
|
352
|
+
line: 1
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.`
|
|
356
|
+
});
|
|
357
|
+
modeWarnSettings.markSettingAsWarned(context, "mode");
|
|
358
|
+
}
|
|
359
|
+
return require_tagNames.jsdocTags;
|
|
360
|
+
}
|
|
424
361
|
};
|
|
425
|
-
|
|
426
362
|
/**
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
363
|
+
* @param {import('comment-parser').Spec} tg
|
|
364
|
+
* @param {boolean} [returnArray]
|
|
365
|
+
* @returns {string[]|string}
|
|
366
|
+
*/
|
|
431
367
|
const getTagDescription = (tg, returnArray) => {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
}) => {
|
|
448
|
-
const desc = (tag && postTag || !tag && !name && !type && postDelimiter || ''
|
|
449
|
-
|
|
450
|
-
// Remove space
|
|
451
|
-
).slice(1) + (description || '') + (lineEnd || '');
|
|
452
|
-
if (end) {
|
|
453
|
-
if (desc) {
|
|
454
|
-
descriptions.push(desc);
|
|
455
|
-
}
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
458
|
-
descriptions.push(desc);
|
|
459
|
-
return false;
|
|
460
|
-
});
|
|
461
|
-
return returnArray ? descriptions : descriptions.join('\n');
|
|
368
|
+
/**
|
|
369
|
+
* @type {string[]}
|
|
370
|
+
*/
|
|
371
|
+
const descriptions = [];
|
|
372
|
+
tg.source.some(({ tokens: { description, end, lineEnd, name, postDelimiter, postTag, tag, type } }) => {
|
|
373
|
+
const desc = (tag && postTag || !tag && !name && !type && postDelimiter || "").slice(1) + (description || "") + (lineEnd || "");
|
|
374
|
+
if (end) {
|
|
375
|
+
if (desc) descriptions.push(desc);
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
descriptions.push(desc);
|
|
379
|
+
return false;
|
|
380
|
+
});
|
|
381
|
+
return returnArray ? descriptions : descriptions.join("\n");
|
|
462
382
|
};
|
|
463
|
-
|
|
464
383
|
/**
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
384
|
+
* @typedef {{
|
|
385
|
+
* report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
|
|
386
|
+
* }} Reporter
|
|
387
|
+
*/
|
|
470
388
|
/**
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
})
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
// Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint
|
|
496
|
-
// that disallows keys that conflict with Object.prototype,
|
|
497
|
-
// e.g. 'tag constructor' for 'constructor':
|
|
498
|
-
// https://github.com/eslint/eslint/issues/13289
|
|
499
|
-
// https://github.com/gajus/eslint-plugin-jsdoc/issues/537
|
|
500
|
-
const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => {
|
|
501
|
-
return [key.replace(/^tag /v, ''), value];
|
|
502
|
-
}));
|
|
503
|
-
if (Object.hasOwn(tagPreferenceFixed, name)) {
|
|
504
|
-
return tagPreferenceFixed[name];
|
|
505
|
-
}
|
|
506
|
-
const tagNames = getTagNamesForMode(mode, context);
|
|
507
|
-
const preferredTagName = Object.entries(tagNames).find(([, aliases]) => {
|
|
508
|
-
return aliases.includes(name);
|
|
509
|
-
})?.[0];
|
|
510
|
-
if (preferredTagName) {
|
|
511
|
-
return preferredTagName;
|
|
512
|
-
}
|
|
513
|
-
return name;
|
|
389
|
+
* @param {string} name
|
|
390
|
+
* @param {ParserMode|undefined} mode
|
|
391
|
+
* @param {TagNamePreference} tagPreference
|
|
392
|
+
* @param {Reporter} context
|
|
393
|
+
* @returns {string|false|{
|
|
394
|
+
* message: string;
|
|
395
|
+
* replacement?: string|undefined;
|
|
396
|
+
* }}
|
|
397
|
+
*/
|
|
398
|
+
const getPreferredTagNameSimple = (name, mode, tagPreference = {}, context = { report() {} }) => {
|
|
399
|
+
const prefValues = Object.values(tagPreference);
|
|
400
|
+
if (prefValues.includes(name) || prefValues.some((prefVal) => {
|
|
401
|
+
return prefVal && typeof prefVal === "object" && prefVal.replacement === name;
|
|
402
|
+
})) return name;
|
|
403
|
+
const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => {
|
|
404
|
+
return [key.replace(/^tag /v, ""), value];
|
|
405
|
+
}));
|
|
406
|
+
if (Object.hasOwn(tagPreferenceFixed, name)) return tagPreferenceFixed[name];
|
|
407
|
+
const tagNames = getTagNamesForMode(mode, context);
|
|
408
|
+
const preferredTagName = Object.entries(tagNames).find(([, aliases]) => {
|
|
409
|
+
return aliases.includes(name);
|
|
410
|
+
})?.[0];
|
|
411
|
+
if (preferredTagName) return preferredTagName;
|
|
412
|
+
return name;
|
|
514
413
|
};
|
|
515
|
-
|
|
516
414
|
/**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
|
|
415
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
416
|
+
* @param {ParserMode|undefined} mode
|
|
417
|
+
* @param {string} name
|
|
418
|
+
* @param {string[]} definedTags
|
|
419
|
+
* @returns {boolean}
|
|
420
|
+
*/
|
|
524
421
|
const isValidTag = (context, mode, name, definedTags) => {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
422
|
+
const tagNames = getTagNamesForMode(mode, context);
|
|
423
|
+
const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
|
|
424
|
+
const additionalTags = definedTags;
|
|
425
|
+
const allTags = validTagNames.concat(additionalTags);
|
|
426
|
+
return allTags.includes(name);
|
|
530
427
|
};
|
|
531
|
-
|
|
532
428
|
/**
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
exports.isValidTag = isValidTag;
|
|
429
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
430
|
+
* @param {string} targetTagName
|
|
431
|
+
* @returns {boolean}
|
|
432
|
+
*/
|
|
538
433
|
const hasTag = (jsdoc, targetTagName) => {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
434
|
+
const targetTagLower = targetTagName.toLowerCase();
|
|
435
|
+
return jsdoc.tags.some((doc) => {
|
|
436
|
+
return doc.tag.toLowerCase() === targetTagLower;
|
|
437
|
+
});
|
|
543
438
|
};
|
|
544
|
-
|
|
545
439
|
/**
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
exports.hasTag = hasTag;
|
|
440
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
441
|
+
* @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
|
|
442
|
+
* @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
|
|
443
|
+
*/
|
|
551
444
|
const filterTags = (jsdoc, filter) => {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
445
|
+
return jsdoc.tags.filter((tag) => {
|
|
446
|
+
return filter(tag);
|
|
447
|
+
});
|
|
555
448
|
};
|
|
556
|
-
|
|
557
449
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
exports.filterTags = filterTags;
|
|
450
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
451
|
+
* @param {string} tagName
|
|
452
|
+
* @returns {import('comment-parser').Spec[]}
|
|
453
|
+
*/
|
|
563
454
|
const getTags = (jsdoc, tagName) => {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
455
|
+
return filterTags(jsdoc, (item) => {
|
|
456
|
+
return item.tag === tagName;
|
|
457
|
+
});
|
|
567
458
|
};
|
|
568
|
-
|
|
569
459
|
/**
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
if (hasTag(jsdoc, tagName) && (ret === false || isObject && !ret.replacement)) {
|
|
603
|
-
if (skipReportingBlockedTag) {
|
|
604
|
-
return {
|
|
605
|
-
blocked: true,
|
|
606
|
-
tagName
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
const message = isObject && ret.message || defaultMessage;
|
|
610
|
-
report(message, null, getTags(jsdoc, tagName)[0]);
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
return isObject && !allowObjectReturn ? ret.replacement : ret;
|
|
460
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
461
|
+
* @param {{
|
|
462
|
+
* tagName: string,
|
|
463
|
+
* context?: import('eslint').Rule.RuleContext,
|
|
464
|
+
* mode?: ParserMode,
|
|
465
|
+
* report?: import('./iterateJsdoc.js').Report
|
|
466
|
+
* tagNamePreference?: TagNamePreference
|
|
467
|
+
* skipReportingBlockedTag?: boolean,
|
|
468
|
+
* allowObjectReturn?: boolean,
|
|
469
|
+
* defaultMessage?: string,
|
|
470
|
+
* }} cfg
|
|
471
|
+
* @returns {string|undefined|false|{
|
|
472
|
+
* message: string;
|
|
473
|
+
* replacement?: string|undefined;
|
|
474
|
+
* }|{
|
|
475
|
+
* blocked: true,
|
|
476
|
+
* tagName: string
|
|
477
|
+
* }}
|
|
478
|
+
*/
|
|
479
|
+
const getPreferredTagName = (jsdoc, { allowObjectReturn = false, context, tagName, defaultMessage = `Unexpected tag \`@${tagName}\``, mode, report = () => {}, skipReportingBlockedTag = false, tagNamePreference }) => {
|
|
480
|
+
const ret = getPreferredTagNameSimple(tagName, mode, tagNamePreference, context);
|
|
481
|
+
const isObject = ret && typeof ret === "object";
|
|
482
|
+
if (hasTag(jsdoc, tagName) && (ret === false || isObject && !ret.replacement)) {
|
|
483
|
+
if (skipReportingBlockedTag) return {
|
|
484
|
+
blocked: true,
|
|
485
|
+
tagName
|
|
486
|
+
};
|
|
487
|
+
const message = isObject && ret.message || defaultMessage;
|
|
488
|
+
report(message, null, getTags(jsdoc, tagName)[0]);
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
return isObject && !allowObjectReturn ? ret.replacement : ret;
|
|
614
492
|
};
|
|
615
|
-
|
|
616
493
|
/**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
tagName,
|
|
646
|
-
tagNamePreference
|
|
647
|
-
});
|
|
648
|
-
if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object') {
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
const matchingJsdocTags = jsdoc.tags.filter(({
|
|
652
|
-
tag
|
|
653
|
-
}) => {
|
|
654
|
-
return tag === targetTagName;
|
|
655
|
-
});
|
|
656
|
-
for (const matchingJsdocTag of matchingJsdocTags) {
|
|
657
|
-
arrayHandler(
|
|
658
|
-
/**
|
|
659
|
-
* @type {import('@es-joy/jsdoccomment').JsdocTagWithInline}
|
|
660
|
-
*/
|
|
661
|
-
matchingJsdocTag, targetTagName);
|
|
662
|
-
}
|
|
494
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
495
|
+
* @param {string} tagName
|
|
496
|
+
* @param {(
|
|
497
|
+
* matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
|
|
498
|
+
* targetTagName: string
|
|
499
|
+
* ) => void} arrayHandler
|
|
500
|
+
* @param {object} cfg
|
|
501
|
+
* @param {import('eslint').Rule.RuleContext} [cfg.context]
|
|
502
|
+
* @param {ParserMode} [cfg.mode]
|
|
503
|
+
* @param {import('./iterateJsdoc.js').Report} [cfg.report]
|
|
504
|
+
* @param {TagNamePreference} [cfg.tagNamePreference]
|
|
505
|
+
* @param {boolean} [cfg.skipReportingBlockedTag]
|
|
506
|
+
* @returns {void}
|
|
507
|
+
*/
|
|
508
|
+
const forEachPreferredTag = (jsdoc, tagName, arrayHandler, { context, mode, report, skipReportingBlockedTag = false, tagNamePreference } = {}) => {
|
|
509
|
+
const targetTagName = getPreferredTagName(jsdoc, {
|
|
510
|
+
context,
|
|
511
|
+
mode,
|
|
512
|
+
report,
|
|
513
|
+
skipReportingBlockedTag,
|
|
514
|
+
tagName,
|
|
515
|
+
tagNamePreference
|
|
516
|
+
});
|
|
517
|
+
if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === "object") return;
|
|
518
|
+
const matchingJsdocTags = jsdoc.tags.filter(({ tag }) => {
|
|
519
|
+
return tag === targetTagName;
|
|
520
|
+
});
|
|
521
|
+
for (const matchingJsdocTag of matchingJsdocTags) arrayHandler(matchingJsdocTag, targetTagName);
|
|
663
522
|
};
|
|
664
|
-
|
|
665
523
|
/**
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
/** @type {import('./iterateJsdoc.js').Integer} */
|
|
702
|
-
let line = 0;
|
|
703
|
-
for (const {
|
|
704
|
-
number,
|
|
705
|
-
tokens: {
|
|
706
|
-
description
|
|
707
|
-
}
|
|
708
|
-
} of tag.source) {
|
|
709
|
-
if (description && description.includes(`{@${inlineTag.tag}`)) {
|
|
710
|
-
line = number;
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
inlineTag.line = tagBegins + line - 1;
|
|
715
|
-
}
|
|
716
|
-
return (
|
|
717
|
-
/**
|
|
718
|
-
* @type {import('comment-parser').Spec & {
|
|
719
|
-
* inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[]
|
|
720
|
-
* }}
|
|
721
|
-
*/
|
|
722
|
-
tag.inlineTags
|
|
723
|
-
);
|
|
724
|
-
})];
|
|
524
|
+
* Get all tags, inline tags and inline tags in tags
|
|
525
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
526
|
+
* @returns {(import('comment-parser').Spec|
|
|
527
|
+
* import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
|
|
528
|
+
*/
|
|
529
|
+
const getAllTags = (jsdoc) => {
|
|
530
|
+
return [
|
|
531
|
+
...jsdoc.tags,
|
|
532
|
+
...jsdoc.inlineTags.map((inlineTag) => {
|
|
533
|
+
let line = -1;
|
|
534
|
+
for (const { tokens: { description } } of jsdoc.source) {
|
|
535
|
+
line++;
|
|
536
|
+
if (description && description.includes(`{@${inlineTag.tag}`)) break;
|
|
537
|
+
}
|
|
538
|
+
inlineTag.line = line;
|
|
539
|
+
return inlineTag;
|
|
540
|
+
}),
|
|
541
|
+
...jsdoc.tags.flatMap((tag) => {
|
|
542
|
+
let tagBegins = -1;
|
|
543
|
+
for (const { tokens: { tag: tg } } of jsdoc.source) {
|
|
544
|
+
tagBegins++;
|
|
545
|
+
if (tg) break;
|
|
546
|
+
}
|
|
547
|
+
for (const inlineTag of tag.inlineTags) {
|
|
548
|
+
/** @type {import('./iterateJsdoc.js').Integer} */
|
|
549
|
+
let line = 0;
|
|
550
|
+
for (const { number, tokens: { description } } of tag.source) if (description && description.includes(`{@${inlineTag.tag}`)) {
|
|
551
|
+
line = number;
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
inlineTag.line = tagBegins + line - 1;
|
|
555
|
+
}
|
|
556
|
+
return tag.inlineTags;
|
|
557
|
+
})
|
|
558
|
+
];
|
|
725
559
|
};
|
|
726
|
-
|
|
727
560
|
/**
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
exports.getAllTags = getAllTags;
|
|
561
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
562
|
+
* @param {string[]} targetTagNames
|
|
563
|
+
* @returns {boolean}
|
|
564
|
+
*/
|
|
733
565
|
const hasATag = (jsdoc, targetTagNames) => {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
566
|
+
return targetTagNames.some((targetTagName) => {
|
|
567
|
+
return hasTag(jsdoc, targetTagName);
|
|
568
|
+
});
|
|
737
569
|
};
|
|
738
|
-
|
|
739
570
|
/**
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
exports.hasATag = hasATag;
|
|
571
|
+
* Checks if the JSDoc comment has an undefined type.
|
|
572
|
+
* @param {import('comment-parser').Spec|null|undefined} tag
|
|
573
|
+
* the tag which should be checked.
|
|
574
|
+
* @param {ParserMode} mode
|
|
575
|
+
* @returns {boolean}
|
|
576
|
+
* true in case a defined type is undeclared; otherwise false.
|
|
577
|
+
*/
|
|
748
578
|
const mayBeUndefinedTypeTag = (tag, mode) => {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
let parsedTypes;
|
|
762
|
-
try {
|
|
763
|
-
parsedTypes = (0, _jsdoccomment.tryParse)(tagType, mode === 'permissive' ? undefined : [mode]);
|
|
764
|
-
} catch {
|
|
765
|
-
// Ignore
|
|
766
|
-
}
|
|
767
|
-
if (
|
|
768
|
-
// We do not traverse deeply as it could be, e.g., `Promise<void>`
|
|
769
|
-
parsedTypes && parsedTypes.type === 'JsdocTypeUnion' && parsedTypes.elements.find(elem => {
|
|
770
|
-
return elem.type === 'JsdocTypeUndefined' || elem.type === 'JsdocTypeName' && elem.value === 'void';
|
|
771
|
-
})) {
|
|
772
|
-
return true;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
// In any other case, a type is present
|
|
776
|
-
return false;
|
|
579
|
+
if (typeof tag === "undefined" || tag === null) return true;
|
|
580
|
+
const tagType = tag.type.trim();
|
|
581
|
+
if (tagType === "undefined" || tagType === "void" || tagType === "*" || tagType === "any") return true;
|
|
582
|
+
let parsedTypes;
|
|
583
|
+
try {
|
|
584
|
+
parsedTypes = (0, __es_joy_jsdoccomment.tryParse)(tagType, mode === "permissive" ? void 0 : [mode]);
|
|
585
|
+
} catch {}
|
|
586
|
+
if (parsedTypes && parsedTypes.type === "JsdocTypeUnion" && parsedTypes.elements.find((elem) => {
|
|
587
|
+
return elem.type === "JsdocTypeUndefined" || elem.type === "JsdocTypeName" && elem.value === "void";
|
|
588
|
+
})) return true;
|
|
589
|
+
return false;
|
|
777
590
|
};
|
|
778
|
-
|
|
779
591
|
/**
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
|
|
592
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
|
|
593
|
+
* @param {string} tag
|
|
594
|
+
* @returns {Map<string, string|string[]|boolean|undefined>}
|
|
595
|
+
*/
|
|
785
596
|
const ensureMap = (map, tag) => {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
}
|
|
789
|
-
return /** @type {Map<string, string | boolean>} */map.get(tag);
|
|
597
|
+
if (!map.has(tag)) map.set(tag, /* @__PURE__ */ new Map());
|
|
598
|
+
return map.get(tag);
|
|
790
599
|
};
|
|
791
|
-
|
|
792
600
|
/**
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
601
|
+
* @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
|
|
602
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
603
|
+
* @returns {void}
|
|
604
|
+
*/
|
|
797
605
|
const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
throw new Error('Cannot add "type" to `require` with the tag\'s `type` set to `false`');
|
|
814
|
-
}
|
|
815
|
-
tagStruct.set('typeRequired', requiredType);
|
|
816
|
-
const typeOrNameRequired = required.includes('typeOrNameRequired');
|
|
817
|
-
if (typeOrNameRequired && name === false) {
|
|
818
|
-
throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `name` set to `false`');
|
|
819
|
-
}
|
|
820
|
-
if (typeOrNameRequired && type === false) {
|
|
821
|
-
throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `type` set to `false`');
|
|
822
|
-
}
|
|
823
|
-
tagStruct.set('typeOrNameRequired', typeOrNameRequired);
|
|
824
|
-
}
|
|
606
|
+
for (const [tag, { name, required = [], type }] of Object.entries(structuredTags)) {
|
|
607
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
608
|
+
tagStruct.set("namepathRole", name);
|
|
609
|
+
tagStruct.set("typeAllowed", type);
|
|
610
|
+
const requiredName = required.includes("name");
|
|
611
|
+
if (requiredName && name === false) throw new Error("Cannot add \"name\" to `require` with the tag's `name` set to `false`");
|
|
612
|
+
tagStruct.set("nameRequired", requiredName);
|
|
613
|
+
const requiredType = required.includes("type");
|
|
614
|
+
if (requiredType && type === false) throw new Error("Cannot add \"type\" to `require` with the tag's `type` set to `false`");
|
|
615
|
+
tagStruct.set("typeRequired", requiredType);
|
|
616
|
+
const typeOrNameRequired = required.includes("typeOrNameRequired");
|
|
617
|
+
if (typeOrNameRequired && name === false) throw new Error("Cannot add \"typeOrNameRequired\" to `require` with the tag's `name` set to `false`");
|
|
618
|
+
if (typeOrNameRequired && type === false) throw new Error("Cannot add \"typeOrNameRequired\" to `require` with the tag's `type` set to `false`");
|
|
619
|
+
tagStruct.set("typeOrNameRequired", typeOrNameRequired);
|
|
620
|
+
}
|
|
825
621
|
};
|
|
826
|
-
|
|
827
622
|
/**
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
exports.overrideTagStructure = overrideTagStructure;
|
|
623
|
+
* @param {ParserMode} mode
|
|
624
|
+
* @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
|
|
625
|
+
* @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
|
|
626
|
+
*/
|
|
833
627
|
const getTagStructureForMode = (mode, structuredTags) => {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
//
|
|
840
|
-
}
|
|
841
|
-
return tagStruct;
|
|
628
|
+
const tagStruct = require_getDefaultTagStructureForMode.default(mode);
|
|
629
|
+
try {
|
|
630
|
+
overrideTagStructure(structuredTags, tagStruct);
|
|
631
|
+
} catch {}
|
|
632
|
+
return tagStruct;
|
|
842
633
|
};
|
|
843
|
-
|
|
844
634
|
/**
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
exports.getTagStructureForMode = getTagStructureForMode;
|
|
635
|
+
* @param {string} tag
|
|
636
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
637
|
+
* @returns {boolean}
|
|
638
|
+
*/
|
|
850
639
|
const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
851
|
-
|
|
852
|
-
|
|
640
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
641
|
+
return tagStruct.get("namepathRole") === "namepath-defining";
|
|
853
642
|
};
|
|
854
|
-
|
|
855
643
|
/**
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
exports.isNamepathDefiningTag = isNamepathDefiningTag;
|
|
644
|
+
* @param {string} tag
|
|
645
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
646
|
+
* @returns {boolean}
|
|
647
|
+
*/
|
|
861
648
|
const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
|
|
862
|
-
|
|
863
|
-
|
|
649
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
650
|
+
return tagStruct.get("namepathRole") === "namepath-referencing";
|
|
864
651
|
};
|
|
865
|
-
|
|
866
652
|
/**
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
exports.isNamepathReferencingTag = isNamepathReferencingTag;
|
|
653
|
+
* @param {string} tag
|
|
654
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
655
|
+
* @returns {boolean}
|
|
656
|
+
*/
|
|
872
657
|
const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
|
|
873
|
-
|
|
874
|
-
|
|
658
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
659
|
+
return tagStruct.get("namepathRole") === "namepath-or-url-referencing";
|
|
875
660
|
};
|
|
876
|
-
|
|
877
661
|
/**
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
exports.isNamepathOrUrlReferencingTag = isNamepathOrUrlReferencingTag;
|
|
662
|
+
* @param {string} tag
|
|
663
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
664
|
+
* @returns {boolean|undefined}
|
|
665
|
+
*/
|
|
883
666
|
const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
884
|
-
|
|
885
|
-
|
|
667
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
668
|
+
return tagStruct.get("typeRequired");
|
|
886
669
|
};
|
|
887
|
-
|
|
888
670
|
/**
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
exports.tagMustHaveTypePosition = tagMustHaveTypePosition;
|
|
671
|
+
* @param {string} tag
|
|
672
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
673
|
+
* @returns {boolean|string}
|
|
674
|
+
*/
|
|
894
675
|
const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed');
|
|
900
|
-
return ret === undefined ? true : ret;
|
|
676
|
+
if (tagMustHaveTypePosition(tag, tagMap)) return true;
|
|
677
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
678
|
+
const ret = tagStruct.get("typeAllowed");
|
|
679
|
+
return ret === void 0 ? true : ret;
|
|
901
680
|
};
|
|
902
|
-
|
|
903
|
-
const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
|
|
904
|
-
|
|
681
|
+
const namepathTypes = new Set(["namepath-defining", "namepath-referencing"]);
|
|
905
682
|
/**
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
683
|
+
* @param {string} tag
|
|
684
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
685
|
+
* @returns {boolean}
|
|
686
|
+
*/
|
|
910
687
|
const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
688
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
689
|
+
const ret = tagStruct.get("namepathRole");
|
|
690
|
+
return ret === void 0 ? true : Boolean(ret);
|
|
914
691
|
};
|
|
915
|
-
|
|
916
692
|
/**
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
exports.tagMightHaveNamePosition = tagMightHaveNamePosition;
|
|
693
|
+
* @param {string} tag
|
|
694
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
695
|
+
* @returns {boolean}
|
|
696
|
+
*/
|
|
922
697
|
const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
698
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
699
|
+
const nampathRole = tagStruct.get("namepathRole");
|
|
700
|
+
return nampathRole !== false && namepathTypes.has(nampathRole);
|
|
926
701
|
};
|
|
927
|
-
|
|
928
702
|
/**
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
exports.tagMightHaveNamepath = tagMightHaveNamepath;
|
|
703
|
+
* @param {string} tag
|
|
704
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
705
|
+
* @returns {boolean|undefined}
|
|
706
|
+
*/
|
|
934
707
|
const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
|
|
935
|
-
|
|
936
|
-
|
|
708
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
709
|
+
return tagStruct.get("nameRequired");
|
|
937
710
|
};
|
|
938
|
-
|
|
939
711
|
/**
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
exports.tagMustHaveNamePosition = tagMustHaveNamePosition;
|
|
712
|
+
* @param {string} tag
|
|
713
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
714
|
+
* @returns {boolean}
|
|
715
|
+
*/
|
|
945
716
|
const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
946
|
-
|
|
717
|
+
return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
|
|
947
718
|
};
|
|
948
|
-
|
|
949
719
|
/**
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
exports.tagMightHaveEitherTypeOrNamePosition = tagMightHaveEitherTypeOrNamePosition;
|
|
720
|
+
* @param {string} tag
|
|
721
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
722
|
+
* @returns {boolean|undefined}
|
|
723
|
+
*/
|
|
955
724
|
const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
|
|
956
|
-
|
|
957
|
-
|
|
725
|
+
const tagStruct = ensureMap(tagMap, tag);
|
|
726
|
+
return tagStruct.get("typeOrNameRequired");
|
|
958
727
|
};
|
|
959
|
-
|
|
960
728
|
/**
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
729
|
+
* @param {import('comment-parser').Spec} tag
|
|
730
|
+
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
731
|
+
* @returns {boolean|undefined}
|
|
732
|
+
*/
|
|
965
733
|
const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
734
|
+
const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
|
|
735
|
+
const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap);
|
|
736
|
+
const hasTypePosition = mightHaveTypePosition && Boolean(tag.type);
|
|
737
|
+
const hasNameOrNamepathPosition = (tagMustHaveNamePosition(tag.tag, tagMap) || tagMightHaveNamepath(tag.tag, tagMap)) && Boolean(tag.name);
|
|
738
|
+
const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap);
|
|
739
|
+
const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && (hasTypePosition || hasNameOrNamepathPosition);
|
|
740
|
+
return mustHaveEither && !hasEither && !mustHaveTypePosition;
|
|
973
741
|
};
|
|
974
|
-
|
|
975
|
-
/* eslint-disable complexity -- Temporary */
|
|
976
742
|
/**
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
|
|
743
|
+
* @param {ESTreeOrTypeScriptNode|null|undefined} node
|
|
744
|
+
* @param {boolean} [checkYieldReturnValue]
|
|
745
|
+
* @returns {boolean}
|
|
746
|
+
*/
|
|
982
747
|
const hasNonFunctionYield = (node, checkYieldReturnValue) => {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
/* eslint-disable no-fallthrough */
|
|
1062
|
-
case 'ObjectPattern':
|
|
1063
|
-
/* eslint-enable no-fallthrough */
|
|
1064
|
-
return node.properties.some(property => {
|
|
1065
|
-
return hasNonFunctionYield(property, checkYieldReturnValue);
|
|
1066
|
-
});
|
|
1067
|
-
/* c8 ignore next 2 -- In Babel? */
|
|
1068
|
-
// @ts-expect-error In Babel?
|
|
1069
|
-
case 'ObjectMethod':
|
|
1070
|
-
/* c8 ignore next 6 -- In Babel? */
|
|
1071
|
-
// @ts-expect-error In Babel?
|
|
1072
|
-
return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) ||
|
|
1073
|
-
// @ts-expect-error In Babel?
|
|
1074
|
-
node.arguments.some(nde => {
|
|
1075
|
-
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
1076
|
-
});
|
|
1077
|
-
case 'ReturnStatement':
|
|
1078
|
-
{
|
|
1079
|
-
if (node.argument === null) {
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
return hasNonFunctionYield(node.argument, checkYieldReturnValue);
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
// Comma
|
|
1086
|
-
case 'SequenceExpression':
|
|
1087
|
-
case 'TemplateLiteral':
|
|
1088
|
-
return node.expressions.some(subExpression => {
|
|
1089
|
-
return hasNonFunctionYield(subExpression, checkYieldReturnValue);
|
|
1090
|
-
});
|
|
1091
|
-
case 'SpreadElement':
|
|
1092
|
-
case 'UnaryExpression':
|
|
1093
|
-
return hasNonFunctionYield(node.argument, checkYieldReturnValue);
|
|
1094
|
-
case 'SwitchStatement':
|
|
1095
|
-
{
|
|
1096
|
-
return node.cases.some(someCase => {
|
|
1097
|
-
return someCase.consequent.some(nde => {
|
|
1098
|
-
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
1099
|
-
});
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
case 'TaggedTemplateExpression':
|
|
1103
|
-
return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
|
|
1104
|
-
case 'TryStatement':
|
|
1105
|
-
{
|
|
1106
|
-
return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(/** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */
|
|
1107
|
-
node.finalizer, checkYieldReturnValue);
|
|
1108
|
-
}
|
|
1109
|
-
case 'VariableDeclaration':
|
|
1110
|
-
{
|
|
1111
|
-
return node.declarations.some(nde => {
|
|
1112
|
-
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
case 'VariableDeclarator':
|
|
1116
|
-
{
|
|
1117
|
-
return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue);
|
|
1118
|
-
}
|
|
1119
|
-
case 'YieldExpression':
|
|
1120
|
-
{
|
|
1121
|
-
if (checkYieldReturnValue) {
|
|
1122
|
-
if (/** @type {import('eslint').Rule.Node} */node.parent.type === 'VariableDeclarator') {
|
|
1123
|
-
return true;
|
|
1124
|
-
}
|
|
1125
|
-
return false;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
// void return does not count.
|
|
1129
|
-
if (node.argument === null) {
|
|
1130
|
-
return false;
|
|
1131
|
-
}
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
default:
|
|
1135
|
-
{
|
|
1136
|
-
return false;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
748
|
+
if (!node) return false;
|
|
749
|
+
switch (node.type) {
|
|
750
|
+
case "ArrayExpression":
|
|
751
|
+
case "ArrayPattern": return node.elements.some((element) => {
|
|
752
|
+
return hasNonFunctionYield(element, checkYieldReturnValue);
|
|
753
|
+
});
|
|
754
|
+
case "AssignmentExpression":
|
|
755
|
+
case "BinaryExpression":
|
|
756
|
+
case "LogicalExpression": return hasNonFunctionYield(node.left, checkYieldReturnValue) || hasNonFunctionYield(node.right, checkYieldReturnValue);
|
|
757
|
+
case "AssignmentPattern": return hasNonFunctionYield(node.right, checkYieldReturnValue);
|
|
758
|
+
case "BlockStatement": return node.body.some((bodyNode) => {
|
|
759
|
+
return ![
|
|
760
|
+
"ArrowFunctionExpression",
|
|
761
|
+
"FunctionDeclaration",
|
|
762
|
+
"FunctionExpression"
|
|
763
|
+
].includes(bodyNode.type) && hasNonFunctionYield(bodyNode, checkYieldReturnValue);
|
|
764
|
+
});
|
|
765
|
+
case "CallExpression":
|
|
766
|
+
case "OptionalCallExpression": return node.arguments.some((element) => {
|
|
767
|
+
return hasNonFunctionYield(element, checkYieldReturnValue);
|
|
768
|
+
});
|
|
769
|
+
case "ChainExpression":
|
|
770
|
+
case "ExpressionStatement": return hasNonFunctionYield(node.expression, checkYieldReturnValue);
|
|
771
|
+
case "ClassProperty":
|
|
772
|
+
case "ObjectProperty":
|
|
773
|
+
case "Property":
|
|
774
|
+
case "PropertyDefinition": return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue);
|
|
775
|
+
case "ConditionalExpression":
|
|
776
|
+
case "IfStatement": return hasNonFunctionYield(node.test, checkYieldReturnValue) || hasNonFunctionYield(node.consequent, checkYieldReturnValue) || hasNonFunctionYield(node.alternate, checkYieldReturnValue);
|
|
777
|
+
case "DoWhileStatement":
|
|
778
|
+
case "ForInStatement":
|
|
779
|
+
case "ForOfStatement":
|
|
780
|
+
case "ForStatement":
|
|
781
|
+
case "LabeledStatement":
|
|
782
|
+
case "WhileStatement":
|
|
783
|
+
case "WithStatement": return hasNonFunctionYield(node.body, checkYieldReturnValue);
|
|
784
|
+
case "Import":
|
|
785
|
+
case "ImportExpression": return hasNonFunctionYield(node.source, checkYieldReturnValue);
|
|
786
|
+
case "MemberExpression":
|
|
787
|
+
case "OptionalMemberExpression": return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue);
|
|
788
|
+
case "ObjectExpression":
|
|
789
|
+
case "ObjectPattern": return node.properties.some((property) => {
|
|
790
|
+
return hasNonFunctionYield(property, checkYieldReturnValue);
|
|
791
|
+
});
|
|
792
|
+
case "ObjectMethod":
|
|
793
|
+
/* c8 ignore next 6 -- In Babel? */
|
|
794
|
+
return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || node.arguments.some((nde) => {
|
|
795
|
+
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
796
|
+
});
|
|
797
|
+
case "ReturnStatement":
|
|
798
|
+
if (node.argument === null) return false;
|
|
799
|
+
return hasNonFunctionYield(node.argument, checkYieldReturnValue);
|
|
800
|
+
case "SequenceExpression":
|
|
801
|
+
case "TemplateLiteral": return node.expressions.some((subExpression) => {
|
|
802
|
+
return hasNonFunctionYield(subExpression, checkYieldReturnValue);
|
|
803
|
+
});
|
|
804
|
+
case "SpreadElement":
|
|
805
|
+
case "UnaryExpression": return hasNonFunctionYield(node.argument, checkYieldReturnValue);
|
|
806
|
+
case "SwitchStatement": return node.cases.some((someCase) => {
|
|
807
|
+
return someCase.consequent.some((nde) => {
|
|
808
|
+
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
case "TaggedTemplateExpression": return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
|
|
812
|
+
case "TryStatement": return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(node.finalizer, checkYieldReturnValue);
|
|
813
|
+
case "VariableDeclaration": return node.declarations.some((nde) => {
|
|
814
|
+
return hasNonFunctionYield(nde, checkYieldReturnValue);
|
|
815
|
+
});
|
|
816
|
+
case "VariableDeclarator": return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue);
|
|
817
|
+
case "YieldExpression":
|
|
818
|
+
if (checkYieldReturnValue) {
|
|
819
|
+
if (node.parent.type === "VariableDeclarator") return true;
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
if (node.argument === null) return false;
|
|
823
|
+
return true;
|
|
824
|
+
default: return false;
|
|
825
|
+
}
|
|
1139
826
|
};
|
|
1140
|
-
|
|
1141
827
|
/**
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
828
|
+
* Checks if a node has a return statement. Void return does not count.
|
|
829
|
+
* @param {ESTreeOrTypeScriptNode} node
|
|
830
|
+
* @param {boolean} [checkYieldReturnValue]
|
|
831
|
+
* @returns {boolean}
|
|
832
|
+
*/
|
|
1147
833
|
const hasYieldValue = (node, checkYieldReturnValue) => {
|
|
1148
|
-
|
|
1149
|
-
|
|
834
|
+
return node.generator && (node.expression || hasNonFunctionYield(
|
|
835
|
+
/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */
|
|
836
|
+
node.body,
|
|
837
|
+
checkYieldReturnValue
|
|
838
|
+
));
|
|
1150
839
|
};
|
|
1151
|
-
|
|
1152
840
|
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
// eslint-disable-next-line complexity
|
|
1159
|
-
exports.hasYieldValue = hasYieldValue;
|
|
841
|
+
* Checks if a node has a throws statement.
|
|
842
|
+
* @param {ESTreeOrTypeScriptNode|null|undefined} node
|
|
843
|
+
* @param {boolean} [innerFunction]
|
|
844
|
+
* @returns {boolean}
|
|
845
|
+
*/
|
|
1160
846
|
const hasThrowValue = (node, innerFunction) => {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
case 'WhileStatement':
|
|
1187
|
-
case 'WithStatement':
|
|
1188
|
-
{
|
|
1189
|
-
return hasThrowValue(node.body);
|
|
1190
|
-
}
|
|
1191
|
-
case 'IfStatement':
|
|
1192
|
-
{
|
|
1193
|
-
return hasThrowValue(node.consequent) || hasThrowValue(node.alternate);
|
|
1194
|
-
}
|
|
1195
|
-
case 'SwitchStatement':
|
|
1196
|
-
{
|
|
1197
|
-
return node.cases.some(someCase => {
|
|
1198
|
-
return someCase.consequent.some(nde => {
|
|
1199
|
-
return hasThrowValue(nde);
|
|
1200
|
-
});
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
case 'ThrowStatement':
|
|
1204
|
-
{
|
|
1205
|
-
return true;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
// We only consider it to throw an error if the catch or finally blocks throw an error.
|
|
1209
|
-
case 'TryStatement':
|
|
1210
|
-
{
|
|
1211
|
-
return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer);
|
|
1212
|
-
}
|
|
1213
|
-
default:
|
|
1214
|
-
{
|
|
1215
|
-
return false;
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
847
|
+
if (!node) return false;
|
|
848
|
+
switch (node.type) {
|
|
849
|
+
case "ArrowFunctionExpression":
|
|
850
|
+
case "FunctionDeclaration":
|
|
851
|
+
case "FunctionExpression": return !innerFunction && !node.async && hasThrowValue(node.body, true);
|
|
852
|
+
case "BlockStatement": return node.body.some((bodyNode) => {
|
|
853
|
+
return bodyNode.type !== "FunctionDeclaration" && hasThrowValue(bodyNode);
|
|
854
|
+
});
|
|
855
|
+
case "DoWhileStatement":
|
|
856
|
+
case "ForInStatement":
|
|
857
|
+
case "ForOfStatement":
|
|
858
|
+
case "ForStatement":
|
|
859
|
+
case "LabeledStatement":
|
|
860
|
+
case "WhileStatement":
|
|
861
|
+
case "WithStatement": return hasThrowValue(node.body);
|
|
862
|
+
case "IfStatement": return hasThrowValue(node.consequent) || hasThrowValue(node.alternate);
|
|
863
|
+
case "SwitchStatement": return node.cases.some((someCase) => {
|
|
864
|
+
return someCase.consequent.some((nde) => {
|
|
865
|
+
return hasThrowValue(nde);
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
case "ThrowStatement": return true;
|
|
869
|
+
case "TryStatement": return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer);
|
|
870
|
+
default: return false;
|
|
871
|
+
}
|
|
1218
872
|
};
|
|
1219
|
-
|
|
1220
873
|
/**
|
|
1221
|
-
|
|
1222
|
-
*/
|
|
1223
|
-
/*
|
|
1224
|
-
const isInlineTag = (tag) => {
|
|
1225
|
-
return /^(@link|@linkcode|@linkplain|@tutorial) /v.test(tag);
|
|
1226
|
-
};
|
|
874
|
+
* @param {string} tag
|
|
1227
875
|
*/
|
|
1228
|
-
|
|
1229
876
|
/**
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
});
|
|
877
|
+
* Parses GCC Generic/Template types
|
|
878
|
+
* @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types}
|
|
879
|
+
* @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template}
|
|
880
|
+
* @param {import('comment-parser').Spec} tag
|
|
881
|
+
* @returns {string[]}
|
|
882
|
+
*/
|
|
883
|
+
const parseClosureTemplateTag = (tag) => {
|
|
884
|
+
return tag.name.split(",").map((type) => {
|
|
885
|
+
return type.trim().replace(/^\[?(?<name>.*?)=.*$/v, "$<name>");
|
|
886
|
+
});
|
|
1241
887
|
};
|
|
1242
|
-
|
|
1243
888
|
/**
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
889
|
+
* @typedef {true|string[]} DefaultContexts
|
|
890
|
+
*/
|
|
1247
891
|
/**
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
exports.parseClosureTemplateTag = parseClosureTemplateTag;
|
|
892
|
+
* Checks user option for `contexts` array, defaulting to
|
|
893
|
+
* contexts designated by the rule. Returns an array of
|
|
894
|
+
* ESTree AST types, indicating allowable contexts.
|
|
895
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
896
|
+
* @param {DefaultContexts|undefined} defaultContexts
|
|
897
|
+
* @param {{
|
|
898
|
+
* contexts?: import('./iterateJsdoc.js').Context[]
|
|
899
|
+
* }} settings
|
|
900
|
+
* @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
|
|
901
|
+
*/
|
|
1259
902
|
const enforcedContexts = (context, defaultContexts, settings) => {
|
|
1260
|
-
|
|
1261
|
-
|
|
903
|
+
const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? [
|
|
904
|
+
"ArrowFunctionExpression",
|
|
905
|
+
"FunctionDeclaration",
|
|
906
|
+
"FunctionExpression",
|
|
907
|
+
"TSDeclareFunction"
|
|
908
|
+
] : defaultContexts);
|
|
909
|
+
return contexts;
|
|
1262
910
|
};
|
|
1263
|
-
|
|
1264
911
|
/**
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
exports.enforcedContexts = enforcedContexts;
|
|
912
|
+
* @param {import('./iterateJsdoc.js').Context[]} contexts
|
|
913
|
+
* @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc
|
|
914
|
+
* @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
|
|
915
|
+
* @returns {import('eslint').Rule.RuleListener}
|
|
916
|
+
*/
|
|
1271
917
|
const getContextObject = (contexts, checkJsdoc, handler) => {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* @type {((node: import('eslint').Rule.Node) => void)}
|
|
1316
|
-
*/
|
|
1317
|
-
function (node) {
|
|
1318
|
-
old(node);
|
|
1319
|
-
value(node);
|
|
1320
|
-
} : value;
|
|
1321
|
-
}
|
|
1322
|
-
return properties;
|
|
918
|
+
/** @type {import('eslint').Rule.RuleListener} */
|
|
919
|
+
const properties = {};
|
|
920
|
+
for (const [idx, prop] of contexts.entries()) {
|
|
921
|
+
/** @type {string} */
|
|
922
|
+
let property;
|
|
923
|
+
/** @type {(node: import('eslint').Rule.Node) => void} */
|
|
924
|
+
let value;
|
|
925
|
+
if (typeof prop === "object") {
|
|
926
|
+
const selInfo = {
|
|
927
|
+
lastIndex: idx,
|
|
928
|
+
selector: prop.context
|
|
929
|
+
};
|
|
930
|
+
if (prop.comment) {
|
|
931
|
+
property = prop.context;
|
|
932
|
+
value = checkJsdoc.bind(
|
|
933
|
+
null,
|
|
934
|
+
{
|
|
935
|
+
...selInfo,
|
|
936
|
+
comment: prop.comment
|
|
937
|
+
},
|
|
938
|
+
/** @type {import('@es-joy/jsdoccomment').CommentHandler} */
|
|
939
|
+
handler.bind(null, prop.comment)
|
|
940
|
+
);
|
|
941
|
+
} else {
|
|
942
|
+
property = prop.context;
|
|
943
|
+
value = checkJsdoc.bind(null, selInfo, null);
|
|
944
|
+
}
|
|
945
|
+
} else {
|
|
946
|
+
const selInfo = {
|
|
947
|
+
lastIndex: idx,
|
|
948
|
+
selector: prop
|
|
949
|
+
};
|
|
950
|
+
property = prop;
|
|
951
|
+
value = checkJsdoc.bind(null, selInfo, null);
|
|
952
|
+
}
|
|
953
|
+
const old = properties[property];
|
|
954
|
+
properties[property] = old ? function(node) {
|
|
955
|
+
old(node);
|
|
956
|
+
value(node);
|
|
957
|
+
} : value;
|
|
958
|
+
}
|
|
959
|
+
return properties;
|
|
1323
960
|
};
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
961
|
+
const tagsWithNamesAndDescriptions = new Set([
|
|
962
|
+
"arg",
|
|
963
|
+
"argument",
|
|
964
|
+
"param",
|
|
965
|
+
"prop",
|
|
966
|
+
"property",
|
|
967
|
+
"return",
|
|
968
|
+
"returns",
|
|
969
|
+
"template"
|
|
970
|
+
]);
|
|
1329
971
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
972
|
+
* @typedef {{
|
|
973
|
+
* [key: string]: false|string|
|
|
974
|
+
* {message: string, replacement?: string}
|
|
975
|
+
* }} TagNamePreference
|
|
976
|
+
*/
|
|
1336
977
|
/**
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
978
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
979
|
+
* @param {ParserMode|undefined} mode
|
|
980
|
+
* @param {import('comment-parser').Spec[]} tags
|
|
981
|
+
* @returns {{
|
|
982
|
+
* tagsWithNames: import('comment-parser').Spec[],
|
|
983
|
+
* tagsWithoutNames: import('comment-parser').Spec[]
|
|
984
|
+
* }}
|
|
985
|
+
*/
|
|
1345
986
|
const getTagsByType = (context, mode, tags) => {
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
return {
|
|
1361
|
-
tagsWithNames,
|
|
1362
|
-
tagsWithoutNames
|
|
1363
|
-
};
|
|
987
|
+
/**
|
|
988
|
+
* @type {import('comment-parser').Spec[]}
|
|
989
|
+
*/
|
|
990
|
+
const tagsWithoutNames = [];
|
|
991
|
+
const tagsWithNames = tags.filter((tag) => {
|
|
992
|
+
const { tag: tagName } = tag;
|
|
993
|
+
const tagWithName = tagsWithNamesAndDescriptions.has(tagName);
|
|
994
|
+
if (!tagWithName) tagsWithoutNames.push(tag);
|
|
995
|
+
return tagWithName;
|
|
996
|
+
});
|
|
997
|
+
return {
|
|
998
|
+
tagsWithNames,
|
|
999
|
+
tagsWithoutNames
|
|
1000
|
+
};
|
|
1364
1001
|
};
|
|
1365
|
-
|
|
1366
1002
|
/**
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return (sourceCode.text.match(/^\n*([ \t]+)/v)?.[1] ?? '') + ' ';
|
|
1003
|
+
* @param {import('eslint').SourceCode|{
|
|
1004
|
+
* text: string
|
|
1005
|
+
* }} sourceCode
|
|
1006
|
+
* @returns {string}
|
|
1007
|
+
*/
|
|
1008
|
+
const getIndent = (sourceCode) => {
|
|
1009
|
+
return (sourceCode.text.match(/^\n*([ \t]+)/v)?.[1] ?? "") + " ";
|
|
1375
1010
|
};
|
|
1376
|
-
|
|
1377
1011
|
/**
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
return node?.type === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */node?.parent?.kind === 'constructor';
|
|
1012
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
1013
|
+
* @returns {boolean}
|
|
1014
|
+
*/
|
|
1015
|
+
const isConstructor = (node) => {
|
|
1016
|
+
return node?.type === "MethodDefinition" && node.kind === "constructor" || (node?.parent)?.kind === "constructor";
|
|
1384
1017
|
};
|
|
1385
|
-
|
|
1386
1018
|
/**
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
return node !== null &&
|
|
1393
|
-
/**
|
|
1394
|
-
* @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
|
|
1395
|
-
* import('@typescript-eslint/types').TSESTree.Property}
|
|
1396
|
-
*/
|
|
1397
|
-
node.parent?.kind === 'get';
|
|
1019
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
1020
|
+
* @returns {boolean}
|
|
1021
|
+
*/
|
|
1022
|
+
const isGetter = (node) => {
|
|
1023
|
+
return node !== null && node.parent?.kind === "get";
|
|
1398
1024
|
};
|
|
1399
|
-
|
|
1400
1025
|
/**
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
return node !== null &&
|
|
1407
|
-
/**
|
|
1408
|
-
* @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
|
|
1409
|
-
* import('@typescript-eslint/types').TSESTree.Property}
|
|
1410
|
-
*/
|
|
1411
|
-
node.parent?.kind === 'set';
|
|
1026
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
1027
|
+
* @returns {boolean}
|
|
1028
|
+
*/
|
|
1029
|
+
const isSetter = (node) => {
|
|
1030
|
+
return node !== null && node.parent?.kind === "set";
|
|
1412
1031
|
};
|
|
1413
|
-
|
|
1414
1032
|
/**
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
*/
|
|
1429
|
-
node;
|
|
1430
|
-
const sourceName = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */key.name;
|
|
1431
|
-
const oppositeKind = sourceKind === 'get' ? 'set' : 'get';
|
|
1432
|
-
const sibling = type === 'MethodDefinition' ? /** @type {import('@typescript-eslint/types').TSESTree.ClassBody} */node.parent.body : /** @type {import('@typescript-eslint/types').TSESTree.ObjectExpression} */node.parent.properties;
|
|
1433
|
-
return sibling.some(child => {
|
|
1434
|
-
const {
|
|
1435
|
-
key: ky,
|
|
1436
|
-
kind
|
|
1437
|
-
} =
|
|
1438
|
-
/**
|
|
1439
|
-
* @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
|
|
1440
|
-
* import('@typescript-eslint/types').TSESTree.Property}
|
|
1441
|
-
*/
|
|
1442
|
-
child;
|
|
1443
|
-
const name = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ky.name;
|
|
1444
|
-
return kind === oppositeKind && name === sourceName;
|
|
1445
|
-
});
|
|
1033
|
+
* @param {import('eslint').Rule.Node} node
|
|
1034
|
+
* @returns {boolean}
|
|
1035
|
+
*/
|
|
1036
|
+
const hasAccessorPair = (node) => {
|
|
1037
|
+
const { key, kind: sourceKind, type } = node;
|
|
1038
|
+
const sourceName = key.name;
|
|
1039
|
+
const oppositeKind = sourceKind === "get" ? "set" : "get";
|
|
1040
|
+
const sibling = type === "MethodDefinition" ? node.parent.body : node.parent.properties;
|
|
1041
|
+
return sibling.some((child) => {
|
|
1042
|
+
const { key: ky, kind } = child;
|
|
1043
|
+
const name = ky.name;
|
|
1044
|
+
return kind === oppositeKind && name === sourceName;
|
|
1045
|
+
});
|
|
1446
1046
|
};
|
|
1447
|
-
|
|
1448
1047
|
/**
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1048
|
+
* @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
|
|
1049
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
1050
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
1051
|
+
* @param {import('json-schema').JSONSchema4} schema
|
|
1052
|
+
* @returns {boolean}
|
|
1053
|
+
*/
|
|
1455
1054
|
const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1055
|
+
/**
|
|
1056
|
+
* @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop
|
|
1057
|
+
* @returns {boolean|"no-setter"|"no-getter"}
|
|
1058
|
+
*/
|
|
1059
|
+
const hasSchemaOption = (prop) => {
|
|
1060
|
+
const schemaProperties = schema[0].properties;
|
|
1061
|
+
return context.options[0]?.[prop] ?? (schemaProperties[prop] && schemaProperties[prop].default);
|
|
1062
|
+
};
|
|
1063
|
+
const checkGetters = hasSchemaOption("checkGetters");
|
|
1064
|
+
const checkSetters = hasSchemaOption("checkSetters");
|
|
1065
|
+
return !hasSchemaOption("checkConstructors") && (isConstructor(node) || hasATag(jsdoc, ["class", "constructor"])) || isGetter(node) && (!checkGetters || checkGetters === "no-setter" && hasAccessorPair(
|
|
1066
|
+
/** @type {import('./iterateJsdoc.js').Node} */
|
|
1067
|
+
node.parent
|
|
1068
|
+
)) || isSetter(node) && (!checkSetters || checkSetters === "no-getter" && hasAccessorPair(
|
|
1069
|
+
/** @type {import('./iterateJsdoc.js').Node} */
|
|
1070
|
+
node.parent
|
|
1071
|
+
));
|
|
1467
1072
|
};
|
|
1468
|
-
|
|
1469
1073
|
/**
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
return str.replaceAll(/\.(['"])(.*)\1/gv, '.$2');
|
|
1074
|
+
* Since path segments may be unquoted (if matching a reserved word,
|
|
1075
|
+
* identifier or numeric literal) or single or double quoted, in either
|
|
1076
|
+
* the `@param` or in source, we need to strip the quotes to give a fair
|
|
1077
|
+
* comparison.
|
|
1078
|
+
* @param {string} str
|
|
1079
|
+
* @returns {string}
|
|
1080
|
+
*/
|
|
1081
|
+
const dropPathSegmentQuotes = (str) => {
|
|
1082
|
+
return str.replaceAll(/\.(['"])(.*)\1/gv, ".$2");
|
|
1480
1083
|
};
|
|
1481
|
-
|
|
1482
1084
|
/**
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
};
|
|
1085
|
+
* @param {string} name
|
|
1086
|
+
* @returns {(otherPathName: string) => boolean}
|
|
1087
|
+
*/
|
|
1088
|
+
const comparePaths = (name) => {
|
|
1089
|
+
return (otherPathName) => {
|
|
1090
|
+
return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
|
|
1091
|
+
};
|
|
1491
1092
|
};
|
|
1492
|
-
|
|
1493
1093
|
/**
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1094
|
+
* @callback PathDoesNotBeginWith
|
|
1095
|
+
* @param {string} name
|
|
1096
|
+
* @param {string} otherPathName
|
|
1097
|
+
* @returns {boolean}
|
|
1098
|
+
*/
|
|
1500
1099
|
/** @type {PathDoesNotBeginWith} */
|
|
1501
|
-
exports.comparePaths = comparePaths;
|
|
1502
1100
|
const pathDoesNotBeginWith = (name, otherPathName) => {
|
|
1503
|
-
|
|
1101
|
+
return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
|
|
1504
1102
|
};
|
|
1505
|
-
|
|
1506
1103
|
/**
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
|
|
1104
|
+
* @param {string} regexString
|
|
1105
|
+
* @param {string} [requiredFlags]
|
|
1106
|
+
* @returns {RegExp}
|
|
1107
|
+
*/
|
|
1512
1108
|
const getRegexFromString = (regexString, requiredFlags) => {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
flags = uniqueFlags.join('');
|
|
1524
|
-
return new RegExp(regex, flags);
|
|
1109
|
+
const match = regexString.match(/^\/(.*)\/([gimyvus]*)$/sv);
|
|
1110
|
+
let flags = "v";
|
|
1111
|
+
let regex = regexString;
|
|
1112
|
+
if (match) {
|
|
1113
|
+
[, regex, flags] = match;
|
|
1114
|
+
if (!flags) flags = "v";
|
|
1115
|
+
}
|
|
1116
|
+
const uniqueFlags = [...new Set(flags + (requiredFlags || ""))];
|
|
1117
|
+
flags = uniqueFlags.join("");
|
|
1118
|
+
return new RegExp(regex, flags);
|
|
1525
1119
|
};
|
|
1120
|
+
|
|
1121
|
+
//#endregion
|
|
1122
|
+
exports.comparePaths = comparePaths;
|
|
1123
|
+
exports.dropPathSegmentQuotes = dropPathSegmentQuotes;
|
|
1124
|
+
exports.enforcedContexts = enforcedContexts;
|
|
1125
|
+
exports.exemptSpeciaMethods = exemptSpeciaMethods;
|
|
1126
|
+
exports.filterTags = filterTags;
|
|
1127
|
+
exports.flattenRoots = flattenRoots;
|
|
1128
|
+
exports.forEachPreferredTag = forEachPreferredTag;
|
|
1129
|
+
exports.getAllTags = getAllTags;
|
|
1130
|
+
exports.getContextObject = getContextObject;
|
|
1131
|
+
exports.getFunctionParameterNames = getFunctionParameterNames;
|
|
1132
|
+
exports.getIndent = getIndent;
|
|
1133
|
+
exports.getJsdocTagsDeep = getJsdocTagsDeep;
|
|
1134
|
+
exports.getPreferredTagName = getPreferredTagName;
|
|
1135
|
+
exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
|
|
1526
1136
|
exports.getRegexFromString = getRegexFromString;
|
|
1137
|
+
exports.getTagDescription = getTagDescription;
|
|
1138
|
+
exports.getTagStructureForMode = getTagStructureForMode;
|
|
1139
|
+
exports.getTags = getTags;
|
|
1140
|
+
exports.getTagsByType = getTagsByType;
|
|
1141
|
+
exports.hasATag = hasATag;
|
|
1142
|
+
exports.hasParams = hasParams;
|
|
1143
|
+
exports.hasTag = hasTag;
|
|
1144
|
+
exports.hasThrowValue = hasThrowValue;
|
|
1145
|
+
exports.hasYieldValue = hasYieldValue;
|
|
1146
|
+
exports.isConstructor = isConstructor;
|
|
1147
|
+
exports.isValidTag = isValidTag;
|
|
1148
|
+
Object.defineProperty(exports, 'jsdocUtils_exports', {
|
|
1149
|
+
enumerable: true,
|
|
1150
|
+
get: function () {
|
|
1151
|
+
return jsdocUtils_exports;
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
|
|
1155
|
+
exports.overrideTagStructure = overrideTagStructure;
|
|
1156
|
+
exports.parseClosureTemplateTag = parseClosureTemplateTag;
|
|
1157
|
+
exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
|
|
1158
|
+
exports.setTagStructure = setTagStructure;
|
|
1159
|
+
exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
|
|
1527
1160
|
//# sourceMappingURL=jsdocUtils.cjs.map
|