@depup/eslint-plugin-jsdoc 62.8.0-depup.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/LICENSE +24 -0
- package/README.md +33 -0
- package/changes.json +18 -0
- package/dist/WarnSettings.cjs +38 -0
- package/dist/WarnSettings.cjs.map +1 -0
- package/dist/WarnSettings.d.ts +17 -0
- package/dist/alignTransform.cjs +402 -0
- package/dist/alignTransform.cjs.map +1 -0
- package/dist/alignTransform.d.ts +34 -0
- package/dist/buildForbidRuleDefinition.cjs +101 -0
- package/dist/buildForbidRuleDefinition.cjs.map +1 -0
- package/dist/buildForbidRuleDefinition.d.ts +15 -0
- package/dist/buildRejectOrPreferRuleDefinition.cjs +352 -0
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -0
- package/dist/buildRejectOrPreferRuleDefinition.d.ts +9 -0
- package/dist/cjs/WarnSettings.d.ts +16 -0
- package/dist/cjs/alignTransform.d.ts +33 -0
- package/dist/cjs/buildForbidRuleDefinition.d.ts +14 -0
- package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +8 -0
- package/dist/cjs/defaultTagOrder.d.ts +4 -0
- package/dist/cjs/exportParser.d.ts +40 -0
- package/dist/cjs/getDefaultTagStructureForMode.d.ts +10 -0
- package/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -0
- package/dist/cjs/getJsdocProcessorPlugin.d.ts +66 -0
- package/dist/cjs/index-cjs.d.ts +23 -0
- package/dist/cjs/index.cjs.d.cts +2 -0
- package/dist/cjs/iterateJsdoc.d.cts +7 -0
- package/dist/cjs/iterateJsdoc.d.ts +495 -0
- package/dist/cjs/jsdocUtils.d.ts +493 -0
- package/dist/cjs/rules/checkAccess.d.ts +2 -0
- package/dist/cjs/rules/checkAlignment.d.ts +2 -0
- package/dist/cjs/rules/checkExamples.d.ts +3 -0
- package/dist/cjs/rules/checkIndentation.d.ts +2 -0
- package/dist/cjs/rules/checkLineAlignment.d.ts +9 -0
- package/dist/cjs/rules/checkParamNames.d.ts +2 -0
- package/dist/cjs/rules/checkPropertyNames.d.ts +2 -0
- package/dist/cjs/rules/checkSyntax.d.ts +2 -0
- package/dist/cjs/rules/checkTagNames.d.ts +2 -0
- package/dist/cjs/rules/checkTemplateNames.d.ts +2 -0
- package/dist/cjs/rules/checkTypes.d.ts +7 -0
- package/dist/cjs/rules/checkValues.d.ts +2 -0
- package/dist/cjs/rules/convertToJsdocComments.d.ts +266 -0
- package/dist/cjs/rules/emptyTags.d.ts +2 -0
- package/dist/cjs/rules/escapeInlineTags.d.ts +2 -0
- package/dist/cjs/rules/implementsOnClasses.d.ts +2 -0
- package/dist/cjs/rules/importsAsDependencies.d.ts +2 -0
- package/dist/cjs/rules/informativeDocs.d.ts +2 -0
- package/dist/cjs/rules/linesBeforeBlock.d.ts +2 -0
- package/dist/cjs/rules/matchDescription.d.ts +2 -0
- package/dist/cjs/rules/matchName.d.ts +2 -0
- package/dist/cjs/rules/multilineBlocks.d.ts +2 -0
- package/dist/cjs/rules/noBadBlocks.d.ts +2 -0
- package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +2 -0
- package/dist/cjs/rules/noBlankBlocks.d.ts +2 -0
- package/dist/cjs/rules/noDefaults.d.ts +2 -0
- package/dist/cjs/rules/noMissingSyntax.d.ts +9 -0
- package/dist/cjs/rules/noMultiAsterisks.d.ts +2 -0
- package/dist/cjs/rules/noRestrictedSyntax.d.ts +2 -0
- package/dist/cjs/rules/noTypes.d.ts +2 -0
- package/dist/cjs/rules/noUndefinedTypes.d.ts +2 -0
- package/dist/cjs/rules/preferImportTag.d.ts +2 -0
- package/dist/cjs/rules/requireAsteriskPrefix.d.ts +2 -0
- package/dist/cjs/rules/requireDescription.d.ts +2 -0
- package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +2 -0
- package/dist/cjs/rules/requireExample.d.ts +2 -0
- package/dist/cjs/rules/requireFileOverview.d.ts +2 -0
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +2 -0
- package/dist/cjs/rules/requireJsdoc.d.ts +24 -0
- package/dist/cjs/rules/requireParam.d.ts +3 -0
- package/dist/cjs/rules/requireParamDescription.d.ts +2 -0
- package/dist/cjs/rules/requireParamName.d.ts +2 -0
- package/dist/cjs/rules/requireParamType.d.ts +2 -0
- package/dist/cjs/rules/requireProperty.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyDescription.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyName.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyType.d.ts +2 -0
- package/dist/cjs/rules/requireRejects.d.ts +2 -0
- package/dist/cjs/rules/requireReturns.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsCheck.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsDescription.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsType.d.ts +2 -0
- package/dist/cjs/rules/requireTags.d.ts +2 -0
- package/dist/cjs/rules/requireTemplate.d.ts +2 -0
- package/dist/cjs/rules/requireThrows.d.ts +2 -0
- package/dist/cjs/rules/requireYields.d.ts +2 -0
- package/dist/cjs/rules/requireYieldsCheck.d.ts +2 -0
- package/dist/cjs/rules/sortTags.d.ts +2 -0
- package/dist/cjs/rules/tagLines.d.ts +2 -0
- package/dist/cjs/rules/textEscaping.d.ts +2 -0
- package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +2 -0
- package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +2 -0
- package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +2 -0
- package/dist/cjs/rules/tsPreferFunctionType.d.ts +2 -0
- package/dist/cjs/rules/typeFormatting.d.ts +2 -0
- package/dist/cjs/rules/validTypes.d.ts +2 -0
- package/dist/cjs/tagNames.d.ts +15 -0
- package/dist/cjs/utils/hasReturnValue.d.ts +19 -0
- package/dist/defaultTagOrder.cjs +46 -0
- package/dist/defaultTagOrder.cjs.map +1 -0
- package/dist/defaultTagOrder.d.ts +5 -0
- package/dist/exportParser.cjs +732 -0
- package/dist/exportParser.cjs.map +1 -0
- package/dist/exportParser.d.ts +41 -0
- package/dist/generateDocs.cjs +342 -0
- package/dist/generateDocs.cjs.map +1 -0
- package/dist/generateOptions.cjs +62 -0
- package/dist/generateOptions.cjs.map +1 -0
- package/dist/generateRule.cjs +248 -0
- package/dist/generateRule.cjs.map +1 -0
- package/dist/generateRuleTypes.cjs +24 -0
- package/dist/generateRuleTypes.cjs.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +289 -0
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -0
- package/dist/getDefaultTagStructureForMode.d.ts +11 -0
- package/dist/getJsdocProcessorPlugin.cjs +587 -0
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -0
- package/dist/getJsdocProcessorPlugin.cts +5 -0
- package/dist/getJsdocProcessorPlugin.d.ts +67 -0
- package/dist/index-cjs.cjs +595 -0
- package/dist/index-cjs.cjs.map +1 -0
- package/dist/index-cjs.d.ts +24 -0
- package/dist/index-esm.cjs +162 -0
- package/dist/index-esm.cjs.map +1 -0
- package/dist/index-esm.d.ts +72 -0
- package/dist/index.cjs +743 -0
- package/dist/index.cjs.cts +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/iterateJsdoc.cjs +2150 -0
- package/dist/iterateJsdoc.cjs.map +1 -0
- package/dist/iterateJsdoc.cts +7 -0
- package/dist/iterateJsdoc.d.ts +496 -0
- package/dist/jsdocUtils.cjs +1725 -0
- package/dist/jsdocUtils.cjs.map +1 -0
- package/dist/jsdocUtils.d.ts +494 -0
- package/dist/rules/checkAccess.cjs +40 -0
- package/dist/rules/checkAccess.cjs.map +1 -0
- package/dist/rules/checkAccess.d.ts +3 -0
- package/dist/rules/checkAlignment.cjs +78 -0
- package/dist/rules/checkAlignment.cjs.map +1 -0
- package/dist/rules/checkAlignment.d.ts +3 -0
- package/dist/rules/checkExamples.cjs +521 -0
- package/dist/rules/checkExamples.cjs.map +1 -0
- package/dist/rules/checkExamples.d.ts +4 -0
- package/dist/rules/checkIndentation.cjs +170 -0
- package/dist/rules/checkIndentation.cjs.map +1 -0
- package/dist/rules/checkIndentation.d.ts +3 -0
- package/dist/rules/checkLineAlignment.cjs +398 -0
- package/dist/rules/checkLineAlignment.cjs.map +1 -0
- package/dist/rules/checkLineAlignment.d.ts +10 -0
- package/dist/rules/checkParamNames.cjs +407 -0
- package/dist/rules/checkParamNames.cjs.map +1 -0
- package/dist/rules/checkParamNames.d.ts +3 -0
- package/dist/rules/checkPropertyNames.cjs +135 -0
- package/dist/rules/checkPropertyNames.cjs.map +1 -0
- package/dist/rules/checkPropertyNames.d.ts +3 -0
- package/dist/rules/checkSyntax.cjs +38 -0
- package/dist/rules/checkSyntax.cjs.map +1 -0
- package/dist/rules/checkSyntax.d.ts +3 -0
- package/dist/rules/checkTagNames.cjs +312 -0
- package/dist/rules/checkTagNames.cjs.map +1 -0
- package/dist/rules/checkTagNames.d.ts +3 -0
- package/dist/rules/checkTemplateNames.cjs +185 -0
- package/dist/rules/checkTemplateNames.cjs.map +1 -0
- package/dist/rules/checkTemplateNames.d.ts +3 -0
- package/dist/rules/checkTypes.cjs +111 -0
- package/dist/rules/checkTypes.cjs.map +1 -0
- package/dist/rules/checkTypes.d.ts +8 -0
- package/dist/rules/checkValues.cjs +166 -0
- package/dist/rules/checkValues.cjs.map +1 -0
- package/dist/rules/checkValues.d.ts +3 -0
- package/dist/rules/convertToJsdocComments.cjs +356 -0
- package/dist/rules/convertToJsdocComments.cjs.map +1 -0
- package/dist/rules/convertToJsdocComments.d.ts +267 -0
- package/dist/rules/emptyTags.cjs +85 -0
- package/dist/rules/emptyTags.cjs.map +1 -0
- package/dist/rules/emptyTags.d.ts +3 -0
- package/dist/rules/escapeInlineTags.cjs +149 -0
- package/dist/rules/escapeInlineTags.cjs.map +1 -0
- package/dist/rules/escapeInlineTags.d.ts +3 -0
- package/dist/rules/implementsOnClasses.cjs +74 -0
- package/dist/rules/implementsOnClasses.cjs.map +1 -0
- package/dist/rules/implementsOnClasses.d.ts +3 -0
- package/dist/rules/importsAsDependencies.cjs +104 -0
- package/dist/rules/importsAsDependencies.cjs.map +1 -0
- package/dist/rules/importsAsDependencies.d.ts +3 -0
- package/dist/rules/informativeDocs.cjs +187 -0
- package/dist/rules/informativeDocs.cjs.map +1 -0
- package/dist/rules/informativeDocs.d.ts +3 -0
- package/dist/rules/linesBeforeBlock.cjs +120 -0
- package/dist/rules/linesBeforeBlock.cjs.map +1 -0
- package/dist/rules/linesBeforeBlock.d.ts +3 -0
- package/dist/rules/matchDescription.cjs +356 -0
- package/dist/rules/matchDescription.cjs.map +1 -0
- package/dist/rules/matchDescription.d.ts +3 -0
- package/dist/rules/matchName.cjs +160 -0
- package/dist/rules/matchName.cjs.map +1 -0
- package/dist/rules/matchName.d.ts +3 -0
- package/dist/rules/multilineBlocks.cjs +431 -0
- package/dist/rules/multilineBlocks.cjs.map +1 -0
- package/dist/rules/multilineBlocks.d.ts +3 -0
- package/dist/rules/noBadBlocks.cjs +100 -0
- package/dist/rules/noBadBlocks.cjs.map +1 -0
- package/dist/rules/noBadBlocks.d.ts +3 -0
- package/dist/rules/noBlankBlockDescriptions.cjs +63 -0
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -0
- package/dist/rules/noBlankBlockDescriptions.d.ts +3 -0
- package/dist/rules/noBlankBlocks.cjs +54 -0
- package/dist/rules/noBlankBlocks.cjs.map +1 -0
- package/dist/rules/noBlankBlocks.d.ts +3 -0
- package/dist/rules/noDefaults.cjs +102 -0
- package/dist/rules/noDefaults.cjs.map +1 -0
- package/dist/rules/noDefaults.d.ts +3 -0
- package/dist/rules/noMissingSyntax.cjs +196 -0
- package/dist/rules/noMissingSyntax.cjs.map +1 -0
- package/dist/rules/noMissingSyntax.d.ts +10 -0
- package/dist/rules/noMultiAsterisks.cjs +126 -0
- package/dist/rules/noMultiAsterisks.cjs.map +1 -0
- package/dist/rules/noMultiAsterisks.d.ts +3 -0
- package/dist/rules/noRestrictedSyntax.cjs +68 -0
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -0
- package/dist/rules/noRestrictedSyntax.d.ts +3 -0
- package/dist/rules/noTypes.cjs +101 -0
- package/dist/rules/noTypes.cjs.map +1 -0
- package/dist/rules/noTypes.d.ts +3 -0
- package/dist/rules/noUndefinedTypes.cjs +588 -0
- package/dist/rules/noUndefinedTypes.cjs.map +1 -0
- package/dist/rules/noUndefinedTypes.d.ts +3 -0
- package/dist/rules/preferImportTag.cjs +362 -0
- package/dist/rules/preferImportTag.cjs.map +1 -0
- package/dist/rules/preferImportTag.d.ts +3 -0
- package/dist/rules/requireAsteriskPrefix.cjs +190 -0
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -0
- package/dist/rules/requireAsteriskPrefix.d.ts +3 -0
- package/dist/rules/requireDescription.cjs +164 -0
- package/dist/rules/requireDescription.cjs.map +1 -0
- package/dist/rules/requireDescription.d.ts +3 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs +321 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -0
- package/dist/rules/requireDescriptionCompleteSentence.d.ts +3 -0
- package/dist/rules/requireExample.cjs +133 -0
- package/dist/rules/requireExample.cjs.map +1 -0
- package/dist/rules/requireExample.d.ts +3 -0
- package/dist/rules/requireFileOverview.cjs +194 -0
- package/dist/rules/requireFileOverview.cjs.map +1 -0
- package/dist/rules/requireFileOverview.d.ts +3 -0
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +166 -0
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -0
- package/dist/rules/requireHyphenBeforeParamDescription.d.ts +3 -0
- package/dist/rules/requireJsdoc.cjs +722 -0
- package/dist/rules/requireJsdoc.cjs.map +1 -0
- package/dist/rules/requireJsdoc.d.ts +25 -0
- package/dist/rules/requireParam.cjs +772 -0
- package/dist/rules/requireParam.cjs.map +1 -0
- package/dist/rules/requireParam.d.ts +4 -0
- package/dist/rules/requireParamDescription.cjs +105 -0
- package/dist/rules/requireParamDescription.cjs.map +1 -0
- package/dist/rules/requireParamDescription.d.ts +3 -0
- package/dist/rules/requireParamName.cjs +68 -0
- package/dist/rules/requireParamName.cjs.map +1 -0
- package/dist/rules/requireParamName.d.ts +3 -0
- package/dist/rules/requireParamType.cjs +104 -0
- package/dist/rules/requireParamType.cjs.map +1 -0
- package/dist/rules/requireParamType.d.ts +3 -0
- package/dist/rules/requireProperty.cjs +63 -0
- package/dist/rules/requireProperty.cjs.map +1 -0
- package/dist/rules/requireProperty.d.ts +3 -0
- package/dist/rules/requirePropertyDescription.cjs +29 -0
- package/dist/rules/requirePropertyDescription.cjs.map +1 -0
- package/dist/rules/requirePropertyDescription.d.ts +3 -0
- package/dist/rules/requirePropertyName.cjs +29 -0
- package/dist/rules/requirePropertyName.cjs.map +1 -0
- package/dist/rules/requirePropertyName.d.ts +3 -0
- package/dist/rules/requirePropertyType.cjs +29 -0
- package/dist/rules/requirePropertyType.cjs.map +1 -0
- package/dist/rules/requirePropertyType.d.ts +3 -0
- package/dist/rules/requireRejects.cjs +226 -0
- package/dist/rules/requireRejects.cjs.map +1 -0
- package/dist/rules/requireRejects.d.ts +3 -0
- package/dist/rules/requireReturns.cjs +262 -0
- package/dist/rules/requireReturns.cjs.map +1 -0
- package/dist/rules/requireReturns.d.ts +3 -0
- package/dist/rules/requireReturnsCheck.cjs +140 -0
- package/dist/rules/requireReturnsCheck.cjs.map +1 -0
- package/dist/rules/requireReturnsCheck.d.ts +3 -0
- package/dist/rules/requireReturnsDescription.cjs +72 -0
- package/dist/rules/requireReturnsDescription.cjs.map +1 -0
- package/dist/rules/requireReturnsDescription.d.ts +3 -0
- package/dist/rules/requireReturnsType.cjs +68 -0
- package/dist/rules/requireReturnsType.cjs.map +1 -0
- package/dist/rules/requireReturnsType.d.ts +3 -0
- package/dist/rules/requireTags.cjs +74 -0
- package/dist/rules/requireTags.cjs.map +1 -0
- package/dist/rules/requireTags.d.ts +3 -0
- package/dist/rules/requireTemplate.cjs +220 -0
- package/dist/rules/requireTemplate.cjs.map +1 -0
- package/dist/rules/requireTemplate.d.ts +3 -0
- package/dist/rules/requireThrows.cjs +118 -0
- package/dist/rules/requireThrows.cjs.map +1 -0
- package/dist/rules/requireThrows.d.ts +3 -0
- package/dist/rules/requireYields.cjs +224 -0
- package/dist/rules/requireYields.cjs.map +1 -0
- package/dist/rules/requireYields.d.ts +3 -0
- package/dist/rules/requireYieldsCheck.cjs +179 -0
- package/dist/rules/requireYieldsCheck.cjs.map +1 -0
- package/dist/rules/requireYieldsCheck.d.ts +3 -0
- package/dist/rules/sortTags.cjs +656 -0
- package/dist/rules/sortTags.cjs.map +1 -0
- package/dist/rules/sortTags.d.ts +3 -0
- package/dist/rules/tagLines.cjs +374 -0
- package/dist/rules/tagLines.cjs.map +1 -0
- package/dist/rules/tagLines.d.ts +3 -0
- package/dist/rules/textEscaping.cjs +141 -0
- package/dist/rules/textEscaping.cjs.map +1 -0
- package/dist/rules/textEscaping.d.ts +3 -0
- package/dist/rules/tsMethodSignatureStyle.cjs +240 -0
- package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -0
- package/dist/rules/tsMethodSignatureStyle.d.ts +3 -0
- package/dist/rules/tsNoEmptyObjectType.cjs +62 -0
- package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -0
- package/dist/rules/tsNoEmptyObjectType.d.ts +3 -0
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +104 -0
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -0
- package/dist/rules/tsNoUnnecessaryTemplateExpression.d.ts +3 -0
- package/dist/rules/tsPreferFunctionType.cjs +110 -0
- package/dist/rules/tsPreferFunctionType.cjs.map +1 -0
- package/dist/rules/tsPreferFunctionType.d.ts +3 -0
- package/dist/rules/typeFormatting.cjs +607 -0
- package/dist/rules/typeFormatting.cjs.map +1 -0
- package/dist/rules/typeFormatting.d.ts +3 -0
- package/dist/rules/validTypes.cjs +328 -0
- package/dist/rules/validTypes.cjs.map +1 -0
- package/dist/rules/validTypes.d.ts +3 -0
- package/dist/rules.d.ts +3203 -0
- package/dist/tagNames.cjs +244 -0
- package/dist/tagNames.cjs.map +1 -0
- package/dist/tagNames.d.ts +16 -0
- package/dist/to-valid-identifier.cjs +263 -0
- package/dist/utils/hasReturnValue.cjs +495 -0
- package/dist/utils/hasReturnValue.cjs.map +1 -0
- package/dist/utils/hasReturnValue.d.ts +20 -0
- package/package.json +220 -0
- package/rollup.config.js +16 -0
- package/src/WarnSettings.js +34 -0
- package/src/alignTransform.js +444 -0
- package/src/buildForbidRuleDefinition.js +106 -0
- package/src/buildRejectOrPreferRuleDefinition.js +481 -0
- package/src/defaultTagOrder.js +169 -0
- package/src/exportParser.js +973 -0
- package/src/getDefaultTagStructureForMode.js +968 -0
- package/src/getJsdocProcessorPlugin.cts +5 -0
- package/src/getJsdocProcessorPlugin.js +692 -0
- package/src/index-cjs.js +755 -0
- package/src/index-esm.js +196 -0
- package/src/index.cjs.cts +3 -0
- package/src/index.js +940 -0
- package/src/iterateJsdoc.cts +7 -0
- package/src/iterateJsdoc.js +2612 -0
- package/src/jsdocUtils.js +2158 -0
- package/src/rules/checkAccess.js +45 -0
- package/src/rules/checkAlignment.js +82 -0
- package/src/rules/checkExamples.js +613 -0
- package/src/rules/checkIndentation.js +176 -0
- package/src/rules/checkLineAlignment.js +453 -0
- package/src/rules/checkParamNames.js +541 -0
- package/src/rules/checkPropertyNames.js +174 -0
- package/src/rules/checkSyntax.js +30 -0
- package/src/rules/checkTagNames.js +414 -0
- package/src/rules/checkTemplateNames.js +208 -0
- package/src/rules/checkTypes.js +130 -0
- package/src/rules/checkValues.js +264 -0
- package/src/rules/convertToJsdocComments.js +444 -0
- package/src/rules/emptyTags.js +106 -0
- package/src/rules/escapeInlineTags.js +189 -0
- package/src/rules/implementsOnClasses.js +78 -0
- package/src/rules/importsAsDependencies.js +132 -0
- package/src/rules/informativeDocs.js +228 -0
- package/src/rules/linesBeforeBlock.js +144 -0
- package/src/rules/matchDescription.js +413 -0
- package/src/rules/matchName.js +179 -0
- package/src/rules/multilineBlocks.js +562 -0
- package/src/rules/noBadBlocks.js +127 -0
- package/src/rules/noBlankBlockDescriptions.js +69 -0
- package/src/rules/noBlankBlocks.js +55 -0
- package/src/rules/noDefaults.js +104 -0
- package/src/rules/noMissingSyntax.js +215 -0
- package/src/rules/noMultiAsterisks.js +162 -0
- package/src/rules/noRestrictedSyntax.js +72 -0
- package/src/rules/noTypes.js +108 -0
- package/src/rules/noUndefinedTypes.js +797 -0
- package/src/rules/preferImportTag.js +521 -0
- package/src/rules/requireAsteriskPrefix.js +217 -0
- package/src/rules/requireDescription.js +190 -0
- package/src/rules/requireDescriptionCompleteSentence.js +376 -0
- package/src/rules/requireExample.js +143 -0
- package/src/rules/requireFileOverview.js +213 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +210 -0
- package/src/rules/requireJsdoc.js +897 -0
- package/src/rules/requireParam.js +848 -0
- package/src/rules/requireParamDescription.js +110 -0
- package/src/rules/requireParamName.js +69 -0
- package/src/rules/requireParamType.js +109 -0
- package/src/rules/requireProperty.js +66 -0
- package/src/rules/requirePropertyDescription.js +25 -0
- package/src/rules/requirePropertyName.js +25 -0
- package/src/rules/requirePropertyType.js +25 -0
- package/src/rules/requireRejects.js +246 -0
- package/src/rules/requireReturns.js +291 -0
- package/src/rules/requireReturnsCheck.js +180 -0
- package/src/rules/requireReturnsDescription.js +73 -0
- package/src/rules/requireReturnsType.js +65 -0
- package/src/rules/requireTags.js +85 -0
- package/src/rules/requireTemplate.js +246 -0
- package/src/rules/requireThrows.js +128 -0
- package/src/rules/requireYields.js +265 -0
- package/src/rules/requireYieldsCheck.js +226 -0
- package/src/rules/sortTags.js +766 -0
- package/src/rules/tagLines.js +486 -0
- package/src/rules/textEscaping.js +158 -0
- package/src/rules/tsMethodSignatureStyle.js +300 -0
- package/src/rules/tsNoEmptyObjectType.js +61 -0
- package/src/rules/tsNoUnnecessaryTemplateExpression.js +130 -0
- package/src/rules/tsPreferFunctionType.js +127 -0
- package/src/rules/typeFormatting.js +690 -0
- package/src/rules/validTypes.js +466 -0
- package/src/rules.d.ts +3203 -0
- package/src/tagNames.js +301 -0
- package/src/utils/hasReturnValue.js +572 -0
- package/typings/babel__eslint-parser.d.ts +1 -0
- package/typings/gitdown.d.ts +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirePropertyType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdoc","targetTagName","type","name","iterateAllJsdocs","meta","docs","description","url","module"],"sources":["../../src/rules/requirePropertyType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {\n if (!jsdoc.type) {\n report(\n `Missing JSDoc @${targetTagName} \"${jsdoc.name}\" type.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that each `@property` tag has a type value (in curly brackets).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header',\n },\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,MAAM;EACNC;AACF,CAAC,KAAK;EACJA,KAAK,CAACC,mBAAmB,CAAC,UAAU,EAAE,CAACC,KAAK,EAAEC,aAAa,KAAK;IAC9D,IAAI,CAACD,KAAK,CAACE,IAAI,EAAE;MACfL,MAAM,CACJ,kBAAkBI,aAAa,KAAKD,KAAK,CAACG,IAAI,SAAS,EACvD,IAAI,EACJH,KACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDI,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,0EAA0E;MACvFC,GAAG,EAAE;IACP,CAAC;IACDN,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAO,MAAA,CAAAd,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
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 }; }
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a node or its children contain Promise rejection patterns
|
|
11
|
+
* @param {import('eslint').Rule.Node} node
|
|
12
|
+
* @param {boolean} [innerFunction]
|
|
13
|
+
* @param {boolean} [isAsync]
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line complexity -- Temporary
|
|
17
|
+
const hasRejectValue = (node, innerFunction, isAsync) => {
|
|
18
|
+
if (!node) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
switch (node.type) {
|
|
22
|
+
case 'ArrowFunctionExpression':
|
|
23
|
+
case 'FunctionDeclaration':
|
|
24
|
+
case 'FunctionExpression':
|
|
25
|
+
{
|
|
26
|
+
// For inner functions in async contexts, check if they throw
|
|
27
|
+
// (they could be called and cause rejection)
|
|
28
|
+
if (innerFunction) {
|
|
29
|
+
// Check inner functions for throws - if called from async context, throws become rejections
|
|
30
|
+
const innerIsAsync = node.async;
|
|
31
|
+
// Pass isAsync=true if the inner function is async OR if we're already in an async context
|
|
32
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, false, innerIsAsync || isAsync);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// This is the top-level function we're checking
|
|
36
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, true, node.async);
|
|
37
|
+
}
|
|
38
|
+
case 'BlockStatement':
|
|
39
|
+
{
|
|
40
|
+
return node.body.some(bodyNode => {
|
|
41
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */bodyNode, innerFunction, isAsync);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
case 'CallExpression':
|
|
45
|
+
{
|
|
46
|
+
// Check for Promise.reject()
|
|
47
|
+
if (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.object.name === 'Promise' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'reject') {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check for reject() call (in Promise executor context)
|
|
52
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'reject') {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Check if this is calling an inner function that might reject
|
|
57
|
+
if (innerFunction && node.callee.type === 'Identifier') {
|
|
58
|
+
// We found a function call inside - check if it could be calling a function that rejects
|
|
59
|
+
// We'll handle this in function body traversal
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
case 'DoWhileStatement':
|
|
65
|
+
case 'ForInStatement':
|
|
66
|
+
case 'ForOfStatement':
|
|
67
|
+
case 'ForStatement':
|
|
68
|
+
case 'LabeledStatement':
|
|
69
|
+
case 'WhileStatement':
|
|
70
|
+
case 'WithStatement':
|
|
71
|
+
{
|
|
72
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, innerFunction, isAsync);
|
|
73
|
+
}
|
|
74
|
+
case 'ExpressionStatement':
|
|
75
|
+
{
|
|
76
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.expression, innerFunction, isAsync);
|
|
77
|
+
}
|
|
78
|
+
case 'IfStatement':
|
|
79
|
+
{
|
|
80
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.consequent, innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */node.alternate, innerFunction, isAsync);
|
|
81
|
+
}
|
|
82
|
+
case 'NewExpression':
|
|
83
|
+
{
|
|
84
|
+
// Check for new Promise((resolve, reject) => { reject(...) })
|
|
85
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'Promise' && node.arguments.length > 0) {
|
|
86
|
+
const executor = node.arguments[0];
|
|
87
|
+
if (executor.type === 'ArrowFunctionExpression' || executor.type === 'FunctionExpression') {
|
|
88
|
+
// Check if the executor has reject() calls
|
|
89
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */executor.body, false, false);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
case 'ReturnStatement':
|
|
95
|
+
{
|
|
96
|
+
if (node.argument) {
|
|
97
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.argument, innerFunction, isAsync);
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
case 'SwitchStatement':
|
|
102
|
+
{
|
|
103
|
+
return node.cases.some(someCase => {
|
|
104
|
+
return someCase.consequent.some(nde => {
|
|
105
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */nde, innerFunction, isAsync);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Throw statements in async functions become rejections
|
|
111
|
+
case 'ThrowStatement':
|
|
112
|
+
{
|
|
113
|
+
return isAsync === true;
|
|
114
|
+
}
|
|
115
|
+
case 'TryStatement':
|
|
116
|
+
{
|
|
117
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.handler && node.handler.body, innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */node.finalizer, innerFunction, isAsync);
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
{
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* We can skip checking for a rejects value, in case the documentation is inherited
|
|
128
|
+
* or the method is abstract.
|
|
129
|
+
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
130
|
+
* @returns {boolean}
|
|
131
|
+
*/
|
|
132
|
+
const canSkip = utils => {
|
|
133
|
+
return utils.hasATag(['abstract', 'virtual', 'type']) || utils.avoidDocs();
|
|
134
|
+
};
|
|
135
|
+
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
136
|
+
node,
|
|
137
|
+
report,
|
|
138
|
+
utils
|
|
139
|
+
}) => {
|
|
140
|
+
if (canSkip(utils)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const tagName = /** @type {string} */utils.getPreferredTagName({
|
|
144
|
+
tagName: 'rejects'
|
|
145
|
+
});
|
|
146
|
+
if (!tagName) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const tags = utils.getTags(tagName);
|
|
150
|
+
const iteratingFunction = utils.isIteratingFunction();
|
|
151
|
+
const [tag] = tags;
|
|
152
|
+
const missingRejectsTag = typeof tag === 'undefined' || tag === null;
|
|
153
|
+
const shouldReport = () => {
|
|
154
|
+
if (!missingRejectsTag) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Check if this is an async function or returns a Promise
|
|
159
|
+
const isAsync = utils.isAsync();
|
|
160
|
+
if (!isAsync && !iteratingFunction) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// For async functions, check for throw statements
|
|
165
|
+
// For regular functions, check for Promise.reject or reject calls
|
|
166
|
+
return hasRejectValue(/** @type {import('eslint').Rule.Node} */node);
|
|
167
|
+
};
|
|
168
|
+
if (shouldReport()) {
|
|
169
|
+
report('Promise-rejecting function requires `@rejects` tag');
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
contextDefaults: true,
|
|
173
|
+
meta: {
|
|
174
|
+
docs: {
|
|
175
|
+
description: 'Requires that Promise rejections are documented with `@rejects` tags.',
|
|
176
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header'
|
|
177
|
+
},
|
|
178
|
+
schema: [{
|
|
179
|
+
additionalProperties: false,
|
|
180
|
+
properties: {
|
|
181
|
+
contexts: {
|
|
182
|
+
description: `Set this to an array of strings representing the AST context
|
|
183
|
+
(or objects with optional \`context\` and \`comment\` properties) where you wish
|
|
184
|
+
the rule to be applied.
|
|
185
|
+
|
|
186
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
187
|
+
|
|
188
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
189
|
+
\`FunctionExpression\`).`,
|
|
190
|
+
items: {
|
|
191
|
+
anyOf: [{
|
|
192
|
+
type: 'string'
|
|
193
|
+
}, {
|
|
194
|
+
additionalProperties: false,
|
|
195
|
+
properties: {
|
|
196
|
+
comment: {
|
|
197
|
+
type: 'string'
|
|
198
|
+
},
|
|
199
|
+
context: {
|
|
200
|
+
type: 'string'
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
type: 'object'
|
|
204
|
+
}]
|
|
205
|
+
},
|
|
206
|
+
type: 'array'
|
|
207
|
+
},
|
|
208
|
+
exemptedBy: {
|
|
209
|
+
description: `Array of tags (e.g., \`['type']\`) whose presence on the
|
|
210
|
+
document block avoids the need for a \`@rejects\`. Defaults to an array
|
|
211
|
+
with \`abstract\`, \`virtual\`, and \`type\`. If you set this array, it will overwrite the default,
|
|
212
|
+
so be sure to add back those tags if you wish their presence to cause
|
|
213
|
+
exemption of the rule.`,
|
|
214
|
+
items: {
|
|
215
|
+
type: 'string'
|
|
216
|
+
},
|
|
217
|
+
type: 'array'
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
type: 'object'
|
|
221
|
+
}],
|
|
222
|
+
type: 'suggestion'
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
module.exports = exports.default;
|
|
226
|
+
//# sourceMappingURL=requireRejects.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireRejects.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","hasRejectValue","node","innerFunction","isAsync","type","innerIsAsync","async","body","some","bodyNode","callee","object","name","property","expression","consequent","alternate","arguments","length","executor","argument","cases","someCase","nde","handler","finalizer","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingRejectsTag","shouldReport","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"sources":["../../src/rules/requireRejects.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * Checks if a node or its children contain Promise rejection patterns\n * @param {import('eslint').Rule.Node} node\n * @param {boolean} [innerFunction]\n * @param {boolean} [isAsync]\n * @returns {boolean}\n */\n// eslint-disable-next-line complexity -- Temporary\nconst hasRejectValue = (node, innerFunction, isAsync) => {\n if (!node) {\n return false;\n }\n\n switch (node.type) {\n case 'ArrowFunctionExpression':\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n // For inner functions in async contexts, check if they throw\n // (they could be called and cause rejection)\n if (innerFunction) {\n // Check inner functions for throws - if called from async context, throws become rejections\n const innerIsAsync = node.async;\n // Pass isAsync=true if the inner function is async OR if we're already in an async context\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), false, innerIsAsync || isAsync);\n }\n\n // This is the top-level function we're checking\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), true, node.async);\n }\n\n case 'BlockStatement': {\n return node.body.some((bodyNode) => {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (bodyNode), innerFunction, isAsync);\n });\n }\n\n case 'CallExpression': {\n // Check for Promise.reject()\n if (node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'Promise' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'reject') {\n return true;\n }\n\n // Check for reject() call (in Promise executor context)\n if (node.callee.type === 'Identifier' && node.callee.name === 'reject') {\n return true;\n }\n\n // Check if this is calling an inner function that might reject\n if (innerFunction && node.callee.type === 'Identifier') {\n // We found a function call inside - check if it could be calling a function that rejects\n // We'll handle this in function body traversal\n return false;\n }\n\n return false;\n }\n\n case 'DoWhileStatement':\n case 'ForInStatement':\n case 'ForOfStatement':\n case 'ForStatement':\n case 'LabeledStatement':\n case 'WhileStatement':\n\n case 'WithStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), innerFunction, isAsync);\n }\n\n case 'ExpressionStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.expression), innerFunction, isAsync);\n }\n\n case 'IfStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.consequent), innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.alternate), innerFunction, isAsync);\n }\n\n case 'NewExpression': {\n // Check for new Promise((resolve, reject) => { reject(...) })\n if (node.callee.type === 'Identifier' && node.callee.name === 'Promise' && node.arguments.length > 0) {\n const executor = node.arguments[0];\n if (executor.type === 'ArrowFunctionExpression' || executor.type === 'FunctionExpression') {\n // Check if the executor has reject() calls\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (executor.body), false, false);\n }\n }\n\n return false;\n }\n\n case 'ReturnStatement': {\n if (node.argument) {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.argument), innerFunction, isAsync);\n }\n\n return false;\n }\n\n case 'SwitchStatement': {\n return node.cases.some(\n (someCase) => {\n return someCase.consequent.some((nde) => {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (nde), innerFunction, isAsync);\n });\n },\n );\n }\n\n // Throw statements in async functions become rejections\n case 'ThrowStatement': {\n return isAsync === true;\n }\n\n case 'TryStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.handler && node.handler.body), innerFunction, isAsync) ||\n hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.finalizer), innerFunction, isAsync);\n }\n\n default: {\n return false;\n }\n }\n};\n\n/**\n * We can skip checking for a rejects value, in case the documentation is inherited\n * or the method is abstract.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @returns {boolean}\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n 'abstract',\n 'virtual',\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n node,\n report,\n utils,\n}) => {\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'rejects',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n tag,\n ] = tags;\n const missingRejectsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingRejectsTag) {\n return false;\n }\n\n // Check if this is an async function or returns a Promise\n const isAsync = utils.isAsync();\n if (!isAsync && !iteratingFunction) {\n return false;\n }\n\n // For async functions, check for throw statements\n // For regular functions, check for Promise.reject or reject calls\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node));\n };\n\n if (shouldReport()) {\n report('Promise-rejecting function requires `@rejects` tag');\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that Promise rejections are documented with `@rejects` tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`).`,\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 description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@rejects\\`. Defaults to an array\nwith \\`abstract\\`, \\`virtual\\`, and \\`type\\`. If you set this array, it will overwrite the default,\nso be sure to add back those tags if you wish their presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAGA,CAACC,IAAI,EAAEC,aAAa,EAAEC,OAAO,KAAK;EACvD,IAAI,CAACF,IAAI,EAAE;IACT,OAAO,KAAK;EACd;EAEA,QAAQA,IAAI,CAACG,IAAI;IACf,KAAK,yBAAyB;IAC9B,KAAK,qBAAqB;IAC1B,KAAK,oBAAoB;MAAE;QACzB;QACA;QACA,IAAIF,aAAa,EAAE;UACjB;UACA,MAAMG,YAAY,GAAGJ,IAAI,CAACK,KAAK;UAC/B;UACA,OAAON,cAAc,CAAC,yCAA2CC,IAAI,CAACM,IAAI,EAAG,KAAK,EAAEF,YAAY,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exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _exportParser = _interopRequireDefault(require("../exportParser.cjs"));
|
|
8
|
+
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/**
|
|
11
|
+
* We can skip checking for a return value, in case the documentation is inherited
|
|
12
|
+
* or the method is either a constructor or an abstract method.
|
|
13
|
+
*
|
|
14
|
+
* In either of these cases the return value is optional or not defined.
|
|
15
|
+
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
16
|
+
* a reference to the utils which are used to probe if a tag is present or not.
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
* true in case deep checking can be skipped; otherwise false.
|
|
19
|
+
*/
|
|
20
|
+
const canSkip = utils => {
|
|
21
|
+
return utils.hasATag([
|
|
22
|
+
// inheritdoc implies that all documentation is inherited
|
|
23
|
+
// see https://jsdoc.app/tags-inheritdoc.html
|
|
24
|
+
//
|
|
25
|
+
// Abstract methods are by definition incomplete,
|
|
26
|
+
// so it is not an error if it declares a return value but does not implement it.
|
|
27
|
+
'abstract', 'virtual',
|
|
28
|
+
// Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)
|
|
29
|
+
// So we can bail out here, too.
|
|
30
|
+
'class', 'constructor',
|
|
31
|
+
// Return type is specified by type in @type
|
|
32
|
+
'type',
|
|
33
|
+
// This seems to imply a class as well
|
|
34
|
+
'interface']) || utils.avoidDocs();
|
|
35
|
+
};
|
|
36
|
+
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
37
|
+
context,
|
|
38
|
+
info: {
|
|
39
|
+
comment
|
|
40
|
+
},
|
|
41
|
+
node,
|
|
42
|
+
report,
|
|
43
|
+
settings,
|
|
44
|
+
utils
|
|
45
|
+
}) => {
|
|
46
|
+
const {
|
|
47
|
+
contexts,
|
|
48
|
+
enableFixer = false,
|
|
49
|
+
forceRequireReturn = false,
|
|
50
|
+
forceReturnsWithAsync = false,
|
|
51
|
+
publicOnly = false
|
|
52
|
+
} = context.options[0] || {};
|
|
53
|
+
|
|
54
|
+
// A preflight check. We do not need to run a deep check
|
|
55
|
+
// in case the @returns comment is optional or undefined.
|
|
56
|
+
if (canSkip(utils)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @type {boolean|undefined} */
|
|
61
|
+
let forceRequireReturnContext;
|
|
62
|
+
if (contexts) {
|
|
63
|
+
const {
|
|
64
|
+
foundContext
|
|
65
|
+
} = utils.findContext(contexts, comment);
|
|
66
|
+
if (typeof foundContext === 'object') {
|
|
67
|
+
forceRequireReturnContext = foundContext.forceRequireReturn;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const tagName = /** @type {string} */utils.getPreferredTagName({
|
|
71
|
+
tagName: 'returns'
|
|
72
|
+
});
|
|
73
|
+
if (!tagName) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const tags = utils.getTags(tagName);
|
|
77
|
+
if (tags.length > 1) {
|
|
78
|
+
report(`Found more than one @${tagName} declaration.`);
|
|
79
|
+
}
|
|
80
|
+
const iteratingFunction = utils.isIteratingFunction();
|
|
81
|
+
|
|
82
|
+
// In case the code returns something, we expect a return value in JSDoc.
|
|
83
|
+
const [tag] = tags;
|
|
84
|
+
const missingReturnTag = typeof tag === 'undefined' || tag === null;
|
|
85
|
+
const shouldReport = () => {
|
|
86
|
+
if (!missingReturnTag) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (publicOnly) {
|
|
90
|
+
/** @type {import('./requireJsdoc.js').RequireJsdocOpts} */
|
|
91
|
+
const opt = {
|
|
92
|
+
ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
|
|
93
|
+
esm: Boolean(publicOnly?.esm ?? true),
|
|
94
|
+
initModuleExports: Boolean(publicOnly?.cjs ?? true),
|
|
95
|
+
initWindow: Boolean(publicOnly?.window ?? false)
|
|
96
|
+
};
|
|
97
|
+
/* c8 ignore next -- Fallback to deprecated method */
|
|
98
|
+
const {
|
|
99
|
+
// @ts-expect-error ESLint < 10
|
|
100
|
+
sourceCode = context.getSourceCode()
|
|
101
|
+
} = context;
|
|
102
|
+
const exported = _exportParser.default.isUncommentedExport(/** @type {import('eslint').Rule.Node} */node, sourceCode, opt, settings);
|
|
103
|
+
if (!exported) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if ((forceRequireReturn || forceRequireReturnContext) && (iteratingFunction || utils.isVirtualFunction())) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const isAsync = !iteratingFunction && utils.hasTag('async') || iteratingFunction && utils.isAsync();
|
|
111
|
+
if (forceReturnsWithAsync && isAsync) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync);
|
|
115
|
+
};
|
|
116
|
+
if (shouldReport()) {
|
|
117
|
+
utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {
|
|
118
|
+
utils.addTag(tagName);
|
|
119
|
+
} : null);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
contextDefaults: true,
|
|
123
|
+
meta: {
|
|
124
|
+
docs: {
|
|
125
|
+
description: 'Requires that returns are documented with `@returns`.',
|
|
126
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header'
|
|
127
|
+
},
|
|
128
|
+
fixable: 'code',
|
|
129
|
+
schema: [{
|
|
130
|
+
additionalProperties: false,
|
|
131
|
+
properties: {
|
|
132
|
+
checkConstructors: {
|
|
133
|
+
default: false,
|
|
134
|
+
description: `A value indicating whether \`constructor\`s should
|
|
135
|
+
be checked for \`@returns\` tags. Defaults to \`false\`.`,
|
|
136
|
+
type: 'boolean'
|
|
137
|
+
},
|
|
138
|
+
checkGetters: {
|
|
139
|
+
default: true,
|
|
140
|
+
description: `Boolean to determine whether getter methods should
|
|
141
|
+
be checked for \`@returns\` tags. Defaults to \`true\`.`,
|
|
142
|
+
type: 'boolean'
|
|
143
|
+
},
|
|
144
|
+
contexts: {
|
|
145
|
+
description: `Set this to an array of strings representing the AST context
|
|
146
|
+
(or objects with optional \`context\` and \`comment\` properties) where you wish
|
|
147
|
+
the rule to be applied.
|
|
148
|
+
|
|
149
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
150
|
+
|
|
151
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
152
|
+
\`FunctionExpression\`). Set to \`"any"\` if you want
|
|
153
|
+
the rule to apply to any JSDoc block throughout your files (as is necessary
|
|
154
|
+
for finding function blocks not attached to a function declaration or
|
|
155
|
+
expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
|
|
156
|
+
\`@method\`) (including those associated with an \`@interface\`). This
|
|
157
|
+
rule will only apply on non-default contexts when there is such a tag
|
|
158
|
+
present and the \`forceRequireReturn\` option is set or if the
|
|
159
|
+
\`forceReturnsWithAsync\` option is set with a present \`@async\` tag
|
|
160
|
+
(since we are not checking against the actual \`return\` values in these
|
|
161
|
+
cases).`,
|
|
162
|
+
items: {
|
|
163
|
+
anyOf: [{
|
|
164
|
+
type: 'string'
|
|
165
|
+
}, {
|
|
166
|
+
additionalProperties: false,
|
|
167
|
+
properties: {
|
|
168
|
+
comment: {
|
|
169
|
+
type: 'string'
|
|
170
|
+
},
|
|
171
|
+
context: {
|
|
172
|
+
type: 'string'
|
|
173
|
+
},
|
|
174
|
+
forceRequireReturn: {
|
|
175
|
+
type: 'boolean'
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
type: 'object'
|
|
179
|
+
}]
|
|
180
|
+
},
|
|
181
|
+
type: 'array'
|
|
182
|
+
},
|
|
183
|
+
enableFixer: {
|
|
184
|
+
description: `Whether to enable the fixer to add a blank \`@returns\`.
|
|
185
|
+
Defaults to \`false\`.`,
|
|
186
|
+
type: 'boolean'
|
|
187
|
+
},
|
|
188
|
+
exemptedBy: {
|
|
189
|
+
description: `Array of tags (e.g., \`['type']\`) whose presence on the
|
|
190
|
+
document block avoids the need for a \`@returns\`. Defaults to an array
|
|
191
|
+
with \`inheritdoc\`. If you set this array, it will overwrite the default,
|
|
192
|
+
so be sure to add back \`inheritdoc\` if you wish its presence to cause
|
|
193
|
+
exemption of the rule.`,
|
|
194
|
+
items: {
|
|
195
|
+
type: 'string'
|
|
196
|
+
},
|
|
197
|
+
type: 'array'
|
|
198
|
+
},
|
|
199
|
+
forceRequireReturn: {
|
|
200
|
+
default: false,
|
|
201
|
+
description: `Set to \`true\` to always insist on
|
|
202
|
+
\`@returns\` documentation regardless of implicit or explicit \`return\`'s
|
|
203
|
+
in the function. May be desired to flag that a project is aware of an
|
|
204
|
+
\`undefined\`/\`void\` return. Defaults to \`false\`.`,
|
|
205
|
+
type: 'boolean'
|
|
206
|
+
},
|
|
207
|
+
forceReturnsWithAsync: {
|
|
208
|
+
default: false,
|
|
209
|
+
description: `By default \`async\` functions that do not explicitly
|
|
210
|
+
return a value pass this rule as an \`async\` function will always return a
|
|
211
|
+
\`Promise\`, even if the \`Promise\` resolves to void. You can force all
|
|
212
|
+
\`async\` functions (including ones with an explicit \`Promise\` but no
|
|
213
|
+
detected non-\`undefined\` \`resolve\` value) to require \`@return\`
|
|
214
|
+
documentation by setting \`forceReturnsWithAsync\` to \`true\` on the options
|
|
215
|
+
object. This may be useful for flagging that there has been consideration
|
|
216
|
+
of return type. Defaults to \`false\`.`,
|
|
217
|
+
type: 'boolean'
|
|
218
|
+
},
|
|
219
|
+
publicOnly: {
|
|
220
|
+
description: `This option will insist that missing \`@returns\` are only reported for
|
|
221
|
+
function bodies / class declarations that are exported from the module.
|
|
222
|
+
May be a boolean or object. If set to \`true\`, the defaults below will be
|
|
223
|
+
used. If unset, \`@returns\` reporting will not be limited to exports.
|
|
224
|
+
|
|
225
|
+
This object supports the following optional boolean keys (\`false\` unless
|
|
226
|
+
otherwise noted):
|
|
227
|
+
|
|
228
|
+
- \`ancestorsOnly\` - Optimization to only check node ancestors to check if node is exported
|
|
229
|
+
- \`esm\` - ESM exports are checked for \`@returns\` JSDoc comments (Defaults to \`true\`)
|
|
230
|
+
- \`cjs\` - CommonJS exports are checked for \`@returns\` JSDoc comments (Defaults to \`true\`)
|
|
231
|
+
- \`window\` - Window global exports are checked for \`@returns\` JSDoc comments`,
|
|
232
|
+
oneOf: [{
|
|
233
|
+
default: false,
|
|
234
|
+
type: 'boolean'
|
|
235
|
+
}, {
|
|
236
|
+
additionalProperties: false,
|
|
237
|
+
default: {},
|
|
238
|
+
properties: {
|
|
239
|
+
ancestorsOnly: {
|
|
240
|
+
type: 'boolean'
|
|
241
|
+
},
|
|
242
|
+
cjs: {
|
|
243
|
+
type: 'boolean'
|
|
244
|
+
},
|
|
245
|
+
esm: {
|
|
246
|
+
type: 'boolean'
|
|
247
|
+
},
|
|
248
|
+
window: {
|
|
249
|
+
type: 'boolean'
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
type: 'object'
|
|
253
|
+
}]
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
type: 'object'
|
|
257
|
+
}],
|
|
258
|
+
type: 'suggestion'
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
module.exports = exports.default;
|
|
262
|
+
//# sourceMappingURL=requireReturns.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireReturns.cjs","names":["_exportParser","_interopRequireDefault","require","_iterateJsdoc","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","context","info","comment","node","report","settings","contexts","enableFixer","forceRequireReturn","forceReturnsWithAsync","publicOnly","options","forceRequireReturnContext","foundContext","findContext","tagName","getPreferredTagName","tags","getTags","length","iteratingFunction","isIteratingFunction","tag","missingReturnTag","shouldReport","opt","ancestorsOnly","Boolean","esm","initModuleExports","cjs","initWindow","window","sourceCode","getSourceCode","exported","exportParser","isUncommentedExport","isVirtualFunction","isAsync","hasTag","hasValueOrExecutorHasNonEmptyResolveValue","reportJSDoc","addTag","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","checkConstructors","type","checkGetters","items","anyOf","exemptedBy","oneOf","module"],"sources":["../../src/rules/requireReturns.js"],"sourcesContent":["import exportParser from '../exportParser.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a return value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * In either of these cases the return value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean}\n * 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 return value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)\n // So we can bail out here, too.\n 'class',\n 'constructor',\n\n // Return type is specified by type in @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n contexts,\n enableFixer = false,\n forceRequireReturn = false,\n forceReturnsWithAsync = false,\n publicOnly = false,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @returns comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n /** @type {boolean|undefined} */\n let forceRequireReturnContext;\n if (contexts) {\n const {\n foundContext,\n } = utils.findContext(contexts, comment);\n if (typeof foundContext === 'object') {\n forceRequireReturnContext = foundContext.forceRequireReturn;\n }\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n }\n\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 missingReturnTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingReturnTag) {\n return false;\n }\n\n if (publicOnly) {\n /** @type {import('./requireJsdoc.js').RequireJsdocOpts} */\n const opt = {\n ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),\n esm: Boolean(publicOnly?.esm ?? true),\n initModuleExports: Boolean(publicOnly?.cjs ?? true),\n initWindow: Boolean(publicOnly?.window ?? false),\n };\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n // @ts-expect-error ESLint < 10\n sourceCode = context.getSourceCode(),\n } = context;\n const exported = exportParser.isUncommentedExport(\n /** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings,\n );\n\n if (!exported) {\n return false;\n }\n }\n\n if ((forceRequireReturn || forceRequireReturnContext) && (\n iteratingFunction || utils.isVirtualFunction()\n )) {\n return true;\n }\n\n const isAsync = !iteratingFunction && utils.hasTag('async') ||\n iteratingFunction && utils.isAsync();\n\n if (forceReturnsWithAsync && isAsync) {\n return true;\n }\n\n return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(\n forceReturnsWithAsync,\n );\n };\n\n if (shouldReport()) {\n utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {\n utils.addTag(tagName);\n } : null);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that returns are documented with `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: false,\n description: `A value indicating whether \\`constructor\\`s should\nbe checked for \\`@returns\\` tags. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n checkGetters: {\n default: true,\n description: `Boolean to determine whether getter methods should\nbe checked for \\`@returns\\` tags. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`). This\nrule will only apply on non-default contexts when there is such a tag\npresent and the \\`forceRequireReturn\\` option is set or if the\n\\`forceReturnsWithAsync\\` option is set with a present \\`@async\\` tag\n(since we are not checking against the actual \\`return\\` values in these\ncases).`,\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 forceRequireReturn: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n description: `Whether to enable the fixer to add a blank \\`@returns\\`.\nDefaults to \\`false\\`.`,\n type: 'boolean',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@returns\\`. Defaults to an array\nwith \\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n description: `Set to \\`true\\` to always insist on\n\\`@returns\\` documentation regardless of implicit or explicit \\`return\\`'s\nin the function. May be desired to flag that a project is aware of an\n\\`undefined\\`/\\`void\\` return. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n description: `By default \\`async\\` functions that do not explicitly\nreturn a value pass this rule as an \\`async\\` function will always return a\n\\`Promise\\`, even if the \\`Promise\\` resolves to void. You can force all\n\\`async\\` functions (including ones with an explicit \\`Promise\\` but no\ndetected non-\\`undefined\\` \\`resolve\\` value) to require \\`@return\\`\ndocumentation by setting \\`forceReturnsWithAsync\\` to \\`true\\` on the options\nobject. This may be useful for flagging that there has been consideration\nof return type. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n publicOnly: {\n description: `This option will insist that missing \\`@returns\\` are only reported for\nfunction bodies / class declarations that are exported from the module.\nMay be a boolean or object. If set to \\`true\\`, the defaults below will be\nused. If unset, \\`@returns\\` reporting will not be limited to exports.\n\nThis object supports the following optional boolean keys (\\`false\\` unless\notherwise noted):\n\n- \\`ancestorsOnly\\` - Optimization to only check node ancestors to check if node is exported\n- \\`esm\\` - ESM exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`cjs\\` - CommonJS exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`window\\` - Window global exports are checked for \\`@returns\\` JSDoc comments`,\n oneOf: [\n {\n default: false,\n type: 'boolean',\n },\n {\n additionalProperties: false,\n default: {},\n properties: {\n ancestorsOnly: {\n type: 'boolean',\n },\n cjs: {\n type: 'boolean',\n },\n esm: {\n type: 'boolean',\n },\n window: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,C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