eslint-plugin-jsdoc 52.0.4 → 53.0.0
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 +1528 -1988
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.cts +471 -0
- package/dist/iterateJsdoc.d.cts.map +1 -0
- package/dist/iterateJsdoc.d.ts +358 -349
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/iterateJsdoc.js +1617 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireThrows.cjs","names":["
|
|
1
|
+
{"version":3,"file":"requireThrows.cjs","names":["iterateJsdoc"],"sources":["../../src/rules/requireThrows.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'throws',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {\n report(`JSDoc @${tagName} declaration set to \"never\" but throw value found.`);\n }\n\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;;AAQA,MAAM,UAAU,CAAC,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
|
5
|
+
* We can skip checking for a throws value, in case the documentation is inherited
|
|
6
|
+
* or the method is either a constructor or an abstract method.
|
|
7
|
+
* @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.
|
|
8
|
+
* @returns {boolean} true in case deep checking can be skipped; otherwise false.
|
|
9
|
+
*/
|
|
10
|
+
const canSkip = (utils) => {
|
|
11
|
+
return utils.hasATag([
|
|
12
|
+
"abstract",
|
|
13
|
+
"virtual",
|
|
14
|
+
"type"
|
|
15
|
+
]) || utils.avoidDocs();
|
|
16
|
+
};
|
|
17
|
+
var requireThrows_default = iterateJsdoc(({ report, utils }) => {
|
|
18
|
+
if (canSkip(utils)) return;
|
|
19
|
+
const tagName = utils.getPreferredTagName({ tagName: "throws" });
|
|
20
|
+
if (!tagName) return;
|
|
21
|
+
const tags = utils.getTags(tagName);
|
|
22
|
+
const iteratingFunction = utils.isIteratingFunction();
|
|
23
|
+
const [tag] = tags;
|
|
24
|
+
const missingThrowsTag = typeof tag === "undefined" || tag === null;
|
|
25
|
+
const shouldReport = () => {
|
|
26
|
+
if (!missingThrowsTag) {
|
|
27
|
+
if (tag.type.trim() === "never" && iteratingFunction && utils.hasThrowValue()) report(`JSDoc @${tagName} declaration set to "never" but throw value found.`);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return iteratingFunction && utils.hasThrowValue();
|
|
31
|
+
};
|
|
32
|
+
if (shouldReport()) report(`Missing JSDoc @${tagName} declaration.`);
|
|
33
|
+
}, {
|
|
34
|
+
contextDefaults: true,
|
|
35
|
+
meta: {
|
|
36
|
+
docs: {
|
|
37
|
+
description: "Requires that throw statements are documented.",
|
|
38
|
+
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header"
|
|
39
|
+
},
|
|
40
|
+
schema: [{
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
properties: {
|
|
43
|
+
contexts: {
|
|
44
|
+
items: { anyOf: [{ type: "string" }, {
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
comment: { type: "string" },
|
|
48
|
+
context: { type: "string" }
|
|
49
|
+
},
|
|
50
|
+
type: "object"
|
|
51
|
+
}] },
|
|
52
|
+
type: "array"
|
|
53
|
+
},
|
|
54
|
+
exemptedBy: {
|
|
55
|
+
items: { type: "string" },
|
|
56
|
+
type: "array"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
type: "object"
|
|
60
|
+
}],
|
|
61
|
+
type: "suggestion"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { requireThrows_default as default };
|
|
67
|
+
//# sourceMappingURL=requireThrows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireThrows.js","names":[],"sources":["../../src/rules/requireThrows.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'throws',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {\n report(`JSDoc @${tagName} declaration set to \"never\" but throw value found.`);\n }\n\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;;AAQA,MAAM,UAAU,CAAC,UAAU;AACzB,QAAO,MAAM,QAAQ;EAMnB;EACA;EAGA;CACD,EAAC,IACA,MAAM,WAAW;AACpB;AAED,4BAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;AAGJ,KAAI,QAAQ,MAAM,CAChB;CAGF,MAAM,UAAiC,MAAM,oBAAoB,EAC/D,SAAS,SACV,EAAC;AACF,KAAI,CAAC,QACH;CAGF,MAAM,OAAO,MAAM,QAAQ,QAAQ;CACnC,MAAM,oBAAoB,MAAM,qBAAqB;CAGrD,MAAM,CACJ,IACD,GAAG;CACJ,MAAM,mBAAmB,OAAO,QAAQ,eAAe,QAAQ;CAE/D,MAAM,eAAe,MAAM;AACzB,MAAI,CAAC,kBAAkB;AACrB,OAAI,IAAI,KAAK,MAAM,KAAK,WAAW,qBAAqB,MAAM,eAAe,EAC3E,OAAO,CAAC,OAAO,EAAE,QAAQ,kDAAkD,CAAC,CAAC;AAG/E,UAAO;EACR;AAED,SAAO,qBAAqB,MAAM,eAAe;CAClD;AAED,KAAI,cAAc,EAChB,OAAO,CAAC,eAAe,EAAE,QAAQ,aAAa,CAAC,CAAC;AAEnD,GAAE;CACD,iBAAiB;CACjB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY;IACV,UAAU;KACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;MACE,sBAAsB;MACtB,YAAY;OACV,SAAS,EACP,MAAM,SACP;OACD,SAAS,EACP,MAAM,SACP;MACF;MACD,MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,YAAY;KACV,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,175 +1,115 @@
|
|
|
1
|
-
|
|
1
|
+
const require_iterateJsdoc = require('../iterateJsdoc.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
3
|
+
//#region src/rules/requireYields.js
|
|
9
4
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const canSkip = utils => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// so we can bail out here, too.
|
|
27
|
-
'class', 'constructor',
|
|
28
|
-
// Yield (and any `next`) type is specified accompanying the targeted
|
|
29
|
-
// @type
|
|
30
|
-
'type',
|
|
31
|
-
// This seems to imply a class as well
|
|
32
|
-
'interface']) || utils.avoidDocs();
|
|
5
|
+
* We can skip checking for a yield value, in case the documentation is inherited
|
|
6
|
+
* or the method has a constructor or abstract tag.
|
|
7
|
+
*
|
|
8
|
+
* In either of these cases the yield value is optional or not defined.
|
|
9
|
+
* @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.
|
|
10
|
+
* @returns {boolean} true in case deep checking can be skipped; otherwise false.
|
|
11
|
+
*/
|
|
12
|
+
const canSkip = (utils) => {
|
|
13
|
+
return utils.hasATag([
|
|
14
|
+
"abstract",
|
|
15
|
+
"virtual",
|
|
16
|
+
"class",
|
|
17
|
+
"constructor",
|
|
18
|
+
"type",
|
|
19
|
+
"interface"
|
|
20
|
+
]) || utils.avoidDocs();
|
|
33
21
|
};
|
|
34
|
-
|
|
35
22
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
24
|
+
* @param {import('../iterateJsdoc.js').Report} report
|
|
25
|
+
* @param {string} tagName
|
|
26
|
+
* @returns {[preferredTagName?: string, missingTag?: boolean]}
|
|
27
|
+
*/
|
|
41
28
|
const checkTagName = (utils, report, tagName) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (tags.length > 1) {
|
|
50
|
-
report(`Found more than one @${preferredTagName} declaration.`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// In case the code yields something, we expect a yields value in JSDoc.
|
|
54
|
-
const [tag] = tags;
|
|
55
|
-
const missingTag = typeof tag === 'undefined' || tag === null;
|
|
56
|
-
return [preferredTagName, missingTag];
|
|
29
|
+
const preferredTagName = utils.getPreferredTagName({ tagName });
|
|
30
|
+
if (!preferredTagName) return [];
|
|
31
|
+
const tags = utils.getTags(preferredTagName);
|
|
32
|
+
if (tags.length > 1) report(`Found more than one @${preferredTagName} declaration.`);
|
|
33
|
+
const [tag] = tags;
|
|
34
|
+
const missingTag = typeof tag === "undefined" || tag === null;
|
|
35
|
+
return [preferredTagName, missingTag];
|
|
57
36
|
};
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
if (withGeneratorTag && utils.hasTag('generator') || forceRequireYields && iteratingFunction && utils.isGenerator()) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();
|
|
87
|
-
};
|
|
88
|
-
if (shouldReportYields()) {
|
|
89
|
-
report(`Missing JSDoc @${preferredYieldTagName} declaration.`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (next || nextWithGeneratorTag || forceRequireNext) {
|
|
93
|
-
const [preferredNextTagName, missingNextTag] = checkTagName(utils, report, 'next');
|
|
94
|
-
if (!preferredNextTagName) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const shouldReportNext = () => {
|
|
98
|
-
if (!missingNextTag) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
if (nextWithGeneratorTag && utils.hasTag('generator')) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (!next && !forceRequireNext || !iteratingFunction || !utils.isGenerator()) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return forceRequireNext || utils.hasYieldReturnValue();
|
|
108
|
-
};
|
|
109
|
-
if (shouldReportNext()) {
|
|
110
|
-
report(`Missing JSDoc @${preferredNextTagName} declaration.`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
37
|
+
var requireYields_default = require_iterateJsdoc.default(({ context, report, utils }) => {
|
|
38
|
+
const { forceRequireNext = false, forceRequireYields = false, next = false, nextWithGeneratorTag = false, withGeneratorTag = true } = context.options[0] || {};
|
|
39
|
+
if (canSkip(utils)) return;
|
|
40
|
+
const iteratingFunction = utils.isIteratingFunction();
|
|
41
|
+
const [preferredYieldTagName, missingYieldTag] = checkTagName(utils, report, "yields");
|
|
42
|
+
if (preferredYieldTagName) {
|
|
43
|
+
const shouldReportYields = () => {
|
|
44
|
+
if (!missingYieldTag) return false;
|
|
45
|
+
if (withGeneratorTag && utils.hasTag("generator") || forceRequireYields && iteratingFunction && utils.isGenerator()) return true;
|
|
46
|
+
return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();
|
|
47
|
+
};
|
|
48
|
+
if (shouldReportYields()) report(`Missing JSDoc @${preferredYieldTagName} declaration.`);
|
|
49
|
+
}
|
|
50
|
+
if (next || nextWithGeneratorTag || forceRequireNext) {
|
|
51
|
+
const [preferredNextTagName, missingNextTag] = checkTagName(utils, report, "next");
|
|
52
|
+
if (!preferredNextTagName) return;
|
|
53
|
+
const shouldReportNext = () => {
|
|
54
|
+
if (!missingNextTag) return false;
|
|
55
|
+
if (nextWithGeneratorTag && utils.hasTag("generator")) return true;
|
|
56
|
+
if (!next && !forceRequireNext || !iteratingFunction || !utils.isGenerator()) return false;
|
|
57
|
+
return forceRequireNext || utils.hasYieldReturnValue();
|
|
58
|
+
};
|
|
59
|
+
if (shouldReportNext()) report(`Missing JSDoc @${preferredNextTagName} declaration.`);
|
|
60
|
+
}
|
|
113
61
|
}, {
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
withGeneratorTag: {
|
|
165
|
-
default: true,
|
|
166
|
-
type: 'boolean'
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
type: 'object'
|
|
170
|
-
}],
|
|
171
|
-
type: 'suggestion'
|
|
172
|
-
}
|
|
62
|
+
contextDefaults: true,
|
|
63
|
+
meta: {
|
|
64
|
+
docs: {
|
|
65
|
+
description: "Requires yields are documented.",
|
|
66
|
+
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header"
|
|
67
|
+
},
|
|
68
|
+
schema: [{
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties: {
|
|
71
|
+
contexts: {
|
|
72
|
+
items: { anyOf: [{ type: "string" }, {
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
comment: { type: "string" },
|
|
76
|
+
context: { type: "string" }
|
|
77
|
+
},
|
|
78
|
+
type: "object"
|
|
79
|
+
}] },
|
|
80
|
+
type: "array"
|
|
81
|
+
},
|
|
82
|
+
exemptedBy: {
|
|
83
|
+
items: { type: "string" },
|
|
84
|
+
type: "array"
|
|
85
|
+
},
|
|
86
|
+
forceRequireNext: {
|
|
87
|
+
default: false,
|
|
88
|
+
type: "boolean"
|
|
89
|
+
},
|
|
90
|
+
forceRequireYields: {
|
|
91
|
+
default: false,
|
|
92
|
+
type: "boolean"
|
|
93
|
+
},
|
|
94
|
+
next: {
|
|
95
|
+
default: false,
|
|
96
|
+
type: "boolean"
|
|
97
|
+
},
|
|
98
|
+
nextWithGeneratorTag: {
|
|
99
|
+
default: false,
|
|
100
|
+
type: "boolean"
|
|
101
|
+
},
|
|
102
|
+
withGeneratorTag: {
|
|
103
|
+
default: true,
|
|
104
|
+
type: "boolean"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
type: "object"
|
|
108
|
+
}],
|
|
109
|
+
type: "suggestion"
|
|
110
|
+
}
|
|
173
111
|
});
|
|
174
|
-
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.default = requireYields_default;
|
|
175
115
|
//# sourceMappingURL=requireYields.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireYields.cjs","names":["
|
|
1
|
+
{"version":3,"file":"requireYields.cjs","names":["iterateJsdoc"],"sources":["../../src/rules/requireYields.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a yield value, in case the documentation is inherited\n * or the method has a constructor or abstract tag.\n *\n * In either of these cases the yield value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a yield value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a yield value\n // so we can bail out here, too.\n 'class',\n 'constructor',\n\n // Yield (and any `next`) type is specified accompanying the targeted\n // @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @param {string} tagName\n * @returns {[preferredTagName?: string, missingTag?: boolean]}\n */\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n }\n\n // In case the code yields something, we expect a yields value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingTag = typeof tag === 'undefined' || tag === null;\n\n return [\n preferredTagName, missingTag,\n ];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n utils,\n}) => {\n const {\n forceRequireNext = false,\n forceRequireYields = false,\n next = false,\n nextWithGeneratorTag = false,\n withGeneratorTag = true,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @yield comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n preferredYieldTagName,\n missingYieldTag,\n ] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (!missingYieldTag) {\n return false;\n }\n\n if (\n withGeneratorTag && utils.hasTag('generator') ||\n forceRequireYields && iteratingFunction && utils.isGenerator()\n ) {\n return true;\n }\n\n return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();\n };\n\n if (shouldReportYields()) {\n report(`Missing JSDoc @${preferredYieldTagName} declaration.`);\n }\n }\n\n if (next || nextWithGeneratorTag || forceRequireNext) {\n const [\n preferredNextTagName,\n missingNextTag,\n ] = checkTagName(\n utils, report, 'next',\n );\n if (!preferredNextTagName) {\n return;\n }\n\n const shouldReportNext = () => {\n if (!missingNextTag) {\n return false;\n }\n\n if (\n nextWithGeneratorTag && utils.hasTag('generator')) {\n return true;\n }\n\n if (\n !next && !forceRequireNext ||\n !iteratingFunction ||\n !utils.isGenerator()\n ) {\n return false;\n }\n\n return forceRequireNext || utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`Missing JSDoc @${preferredNextTagName} declaration.`);\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires yields are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireNext: {\n default: false,\n type: 'boolean',\n },\n forceRequireYields: {\n default: false,\n type: 'boolean',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n nextWithGeneratorTag: {\n default: false,\n type: 'boolean',\n },\n withGeneratorTag: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,UAAU,CAAC,UAAU;AACzB,QAAO,MAAM,QAAQ;EAMnB;EACA;EAIA;EACA;EAIA;EAGA;CACD,EAAC,IACA,MAAM,WAAW;AACpB;;;;;;;AAQD,MAAM,eAAe,CAAC,OAAO,QAAQ,YAAY;CAC/C,MAAM,mBAA0C,MAAM,oBAAoB,EACxE,QACD,EAAC;AACF,KAAI,CAAC,iBACH,QAAO,CAAE;CAGX,MAAM,OAAO,MAAM,QAAQ,iBAAiB;AAE5C,KAAI,KAAK,SAAS,GAChB,OAAO,CAAC,qBAAqB,EAAE,iBAAiB,aAAa,CAAC,CAAC;CAIjE,MAAM,CACJ,IACD,GAAG;CACJ,MAAM,aAAa,OAAO,QAAQ,eAAe,QAAQ;AAEzD,QAAO,CACL,kBAAkB,UACnB;AACF;AAED,4BAAeA,6BAAa,CAAC,EAC3B,SACA,QACA,OACD,KAAK;CACJ,M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MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,YAAY;KACV,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;IACD,kBAAkB;KAChB,SAAS;KACT,MAAM;IACP;IACD,oBAAoB;KAClB,SAAS;KACT,MAAM;IACP;IACD,MAAM;KACJ,SAAS;KACT,MAAM;IACP;IACD,sBAAsB;KACpB,SAAS;KACT,MAAM;IACP;IACD,kBAAkB;KAChB,SAAS;KACT,MAAM;IACP;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
+
|
|
3
|
+
//#region src/rules/requireYields.js
|
|
4
|
+
/**
|
|
5
|
+
* We can skip checking for a yield value, in case the documentation is inherited
|
|
6
|
+
* or the method has a constructor or abstract tag.
|
|
7
|
+
*
|
|
8
|
+
* In either of these cases the yield value is optional or not defined.
|
|
9
|
+
* @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.
|
|
10
|
+
* @returns {boolean} true in case deep checking can be skipped; otherwise false.
|
|
11
|
+
*/
|
|
12
|
+
const canSkip = (utils) => {
|
|
13
|
+
return utils.hasATag([
|
|
14
|
+
"abstract",
|
|
15
|
+
"virtual",
|
|
16
|
+
"class",
|
|
17
|
+
"constructor",
|
|
18
|
+
"type",
|
|
19
|
+
"interface"
|
|
20
|
+
]) || utils.avoidDocs();
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
24
|
+
* @param {import('../iterateJsdoc.js').Report} report
|
|
25
|
+
* @param {string} tagName
|
|
26
|
+
* @returns {[preferredTagName?: string, missingTag?: boolean]}
|
|
27
|
+
*/
|
|
28
|
+
const checkTagName = (utils, report, tagName) => {
|
|
29
|
+
const preferredTagName = utils.getPreferredTagName({ tagName });
|
|
30
|
+
if (!preferredTagName) return [];
|
|
31
|
+
const tags = utils.getTags(preferredTagName);
|
|
32
|
+
if (tags.length > 1) report(`Found more than one @${preferredTagName} declaration.`);
|
|
33
|
+
const [tag] = tags;
|
|
34
|
+
const missingTag = typeof tag === "undefined" || tag === null;
|
|
35
|
+
return [preferredTagName, missingTag];
|
|
36
|
+
};
|
|
37
|
+
var requireYields_default = iterateJsdoc(({ context, report, utils }) => {
|
|
38
|
+
const { forceRequireNext = false, forceRequireYields = false, next = false, nextWithGeneratorTag = false, withGeneratorTag = true } = context.options[0] || {};
|
|
39
|
+
if (canSkip(utils)) return;
|
|
40
|
+
const iteratingFunction = utils.isIteratingFunction();
|
|
41
|
+
const [preferredYieldTagName, missingYieldTag] = checkTagName(utils, report, "yields");
|
|
42
|
+
if (preferredYieldTagName) {
|
|
43
|
+
const shouldReportYields = () => {
|
|
44
|
+
if (!missingYieldTag) return false;
|
|
45
|
+
if (withGeneratorTag && utils.hasTag("generator") || forceRequireYields && iteratingFunction && utils.isGenerator()) return true;
|
|
46
|
+
return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();
|
|
47
|
+
};
|
|
48
|
+
if (shouldReportYields()) report(`Missing JSDoc @${preferredYieldTagName} declaration.`);
|
|
49
|
+
}
|
|
50
|
+
if (next || nextWithGeneratorTag || forceRequireNext) {
|
|
51
|
+
const [preferredNextTagName, missingNextTag] = checkTagName(utils, report, "next");
|
|
52
|
+
if (!preferredNextTagName) return;
|
|
53
|
+
const shouldReportNext = () => {
|
|
54
|
+
if (!missingNextTag) return false;
|
|
55
|
+
if (nextWithGeneratorTag && utils.hasTag("generator")) return true;
|
|
56
|
+
if (!next && !forceRequireNext || !iteratingFunction || !utils.isGenerator()) return false;
|
|
57
|
+
return forceRequireNext || utils.hasYieldReturnValue();
|
|
58
|
+
};
|
|
59
|
+
if (shouldReportNext()) report(`Missing JSDoc @${preferredNextTagName} declaration.`);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
contextDefaults: true,
|
|
63
|
+
meta: {
|
|
64
|
+
docs: {
|
|
65
|
+
description: "Requires yields are documented.",
|
|
66
|
+
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header"
|
|
67
|
+
},
|
|
68
|
+
schema: [{
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties: {
|
|
71
|
+
contexts: {
|
|
72
|
+
items: { anyOf: [{ type: "string" }, {
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
comment: { type: "string" },
|
|
76
|
+
context: { type: "string" }
|
|
77
|
+
},
|
|
78
|
+
type: "object"
|
|
79
|
+
}] },
|
|
80
|
+
type: "array"
|
|
81
|
+
},
|
|
82
|
+
exemptedBy: {
|
|
83
|
+
items: { type: "string" },
|
|
84
|
+
type: "array"
|
|
85
|
+
},
|
|
86
|
+
forceRequireNext: {
|
|
87
|
+
default: false,
|
|
88
|
+
type: "boolean"
|
|
89
|
+
},
|
|
90
|
+
forceRequireYields: {
|
|
91
|
+
default: false,
|
|
92
|
+
type: "boolean"
|
|
93
|
+
},
|
|
94
|
+
next: {
|
|
95
|
+
default: false,
|
|
96
|
+
type: "boolean"
|
|
97
|
+
},
|
|
98
|
+
nextWithGeneratorTag: {
|
|
99
|
+
default: false,
|
|
100
|
+
type: "boolean"
|
|
101
|
+
},
|
|
102
|
+
withGeneratorTag: {
|
|
103
|
+
default: true,
|
|
104
|
+
type: "boolean"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
type: "object"
|
|
108
|
+
}],
|
|
109
|
+
type: "suggestion"
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { requireYields_default as default };
|
|
115
|
+
//# sourceMappingURL=requireYields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireYields.js","names":[],"sources":["../../src/rules/requireYields.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a yield value, in case the documentation is inherited\n * or the method has a constructor or abstract tag.\n *\n * In either of these cases the yield value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a yield value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a yield value\n // so we can bail out here, too.\n 'class',\n 'constructor',\n\n // Yield (and any `next`) type is specified accompanying the targeted\n // @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @param {string} tagName\n * @returns {[preferredTagName?: string, missingTag?: boolean]}\n */\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n }\n\n // In case the code yields something, we expect a yields value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingTag = typeof tag === 'undefined' || tag === null;\n\n return [\n preferredTagName, missingTag,\n ];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n utils,\n}) => {\n const {\n forceRequireNext = false,\n forceRequireYields = false,\n next = false,\n nextWithGeneratorTag = false,\n withGeneratorTag = true,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @yield comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n preferredYieldTagName,\n missingYieldTag,\n ] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (!missingYieldTag) {\n return false;\n }\n\n if (\n withGeneratorTag && utils.hasTag('generator') ||\n forceRequireYields && iteratingFunction && utils.isGenerator()\n ) {\n return true;\n }\n\n return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();\n };\n\n if (shouldReportYields()) {\n report(`Missing JSDoc @${preferredYieldTagName} declaration.`);\n }\n }\n\n if (next || nextWithGeneratorTag || forceRequireNext) {\n const [\n preferredNextTagName,\n missingNextTag,\n ] = checkTagName(\n utils, report, 'next',\n );\n if (!preferredNextTagName) {\n return;\n }\n\n const shouldReportNext = () => {\n if (!missingNextTag) {\n return false;\n }\n\n if (\n nextWithGeneratorTag && utils.hasTag('generator')) {\n return true;\n }\n\n if (\n !next && !forceRequireNext ||\n !iteratingFunction ||\n !utils.isGenerator()\n ) {\n return false;\n }\n\n return forceRequireNext || utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`Missing JSDoc @${preferredNextTagName} declaration.`);\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires yields are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireNext: {\n default: false,\n type: 'boolean',\n },\n forceRequireYields: {\n default: false,\n type: 'boolean',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n nextWithGeneratorTag: {\n default: false,\n type: 'boolean',\n },\n withGeneratorTag: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,UAAU,CAAC,UAAU;AACzB,QAAO,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