eslint-plugin-jsdoc 52.0.3 → 52.0.4
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 +35 -18
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/alignTransform.cjs +305 -224
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/defaultTagOrder.cjs +43 -132
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/exportParser.cjs +696 -478
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +242 -0
- package/dist/generateRule.cjs.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +288 -184
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +550 -364
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.ts +65 -68
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/index.cjs +383 -398
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/iterateJsdoc.cjs +1988 -1528
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +349 -358
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/jsdocUtils.cjs +1376 -1009
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +36 -29
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +54 -41
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +484 -327
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +65 -50
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +311 -220
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +335 -227
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +106 -78
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkSyntax.cjs +34 -21
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +210 -188
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +178 -121
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +385 -291
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +146 -100
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +306 -228
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +72 -62
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +56 -36
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs +99 -62
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +142 -105
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +105 -70
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +222 -160
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +128 -73
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +352 -235
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +86 -63
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +57 -35
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +48 -26
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +79 -52
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +165 -115
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +89 -48
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +79 -45
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +80 -59
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +388 -297
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +159 -108
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +129 -89
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +262 -201
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +104 -73
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +129 -75
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +133 -85
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +557 -384
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +526 -336
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +80 -55
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +50 -32
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +80 -55
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +42 -31
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.cjs +25 -17
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +25 -17
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +25 -17
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +203 -125
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +103 -60
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +54 -39
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +50 -32
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +178 -119
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +95 -61
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +166 -106
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +152 -96
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +444 -258
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +266 -179
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +127 -92
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +265 -252
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +170 -134
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +474 -246
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +24 -40
- package/src/WarnSettings.js +34 -0
- package/src/alignTransform.js +358 -0
- package/src/defaultTagOrder.js +169 -0
- package/src/exportParser.js +978 -0
- package/src/getDefaultTagStructureForMode.js +969 -0
- package/src/getJsdocProcessorPlugin.js +672 -0
- package/src/index.js +530 -0
- package/src/iterateJsdoc.js +2518 -0
- package/src/jsdocUtils.js +1896 -0
- package/src/rules/checkAccess.js +45 -0
- package/src/rules/checkAlignment.js +63 -0
- package/src/rules/checkExamples.js +589 -0
- package/src/rules/checkIndentation.js +75 -0
- package/src/rules/checkLineAlignment.js +372 -0
- package/src/rules/checkParamNames.js +474 -0
- package/src/rules/checkPropertyNames.js +152 -0
- package/src/rules/checkSyntax.js +30 -0
- package/src/rules/checkTagNames.js +314 -0
- package/src/rules/checkTemplateNames.js +204 -0
- package/src/rules/checkTypes.js +535 -0
- package/src/rules/checkValues.js +248 -0
- package/src/rules/convertToJsdocComments.js +398 -0
- package/src/rules/emptyTags.js +98 -0
- package/src/rules/implementsOnClasses.js +64 -0
- package/src/rules/importsAsDependencies.js +133 -0
- package/src/rules/informativeDocs.js +189 -0
- package/src/rules/linesBeforeBlock.js +134 -0
- package/src/rules/matchDescription.js +286 -0
- package/src/rules/matchName.js +151 -0
- package/src/rules/multilineBlocks.js +493 -0
- package/src/rules/noBadBlocks.js +119 -0
- package/src/rules/noBlankBlockDescriptions.js +69 -0
- package/src/rules/noBlankBlocks.js +53 -0
- package/src/rules/noDefaults.js +85 -0
- package/src/rules/noMissingSyntax.js +195 -0
- package/src/rules/noMultiAsterisks.js +134 -0
- package/src/rules/noRestrictedSyntax.js +91 -0
- package/src/rules/noTypes.js +93 -0
- package/src/rules/noUndefinedTypes.js +543 -0
- package/src/rules/requireAsteriskPrefix.js +190 -0
- package/src/rules/requireDescription.js +161 -0
- package/src/rules/requireDescriptionCompleteSentence.js +335 -0
- package/src/rules/requireExample.js +118 -0
- package/src/rules/requireFileOverview.js +154 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +176 -0
- package/src/rules/requireJsdoc.js +743 -0
- package/src/rules/requireParam.js +602 -0
- package/src/rules/requireParamDescription.js +89 -0
- package/src/rules/requireParamName.js +55 -0
- package/src/rules/requireParamType.js +89 -0
- package/src/rules/requireProperty.js +48 -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/requireReturns.js +238 -0
- package/src/rules/requireReturnsCheck.js +145 -0
- package/src/rules/requireReturnsDescription.js +59 -0
- package/src/rules/requireReturnsType.js +51 -0
- package/src/rules/requireTemplate.js +201 -0
- package/src/rules/requireThrows.js +111 -0
- package/src/rules/requireYields.js +216 -0
- package/src/rules/requireYieldsCheck.js +208 -0
- package/src/rules/sortTags.js +558 -0
- package/src/rules/tagLines.js +359 -0
- package/src/rules/textEscaping.js +154 -0
- package/src/rules/validTypes.js +401 -0
- package/src/tagNames.js +238 -0
- package/src/utils/hasReturnValue.js +572 -0
- package/dist/WarnSettings.js +0 -20
- package/dist/WarnSettings.js.map +0 -1
- package/dist/_virtual/rolldown_runtime.cjs +0 -32
- package/dist/_virtual/rolldown_runtime.js +0 -11
- package/dist/alignTransform.js +0 -241
- package/dist/alignTransform.js.map +0 -1
- package/dist/defaultTagOrder.js +0 -134
- package/dist/defaultTagOrder.js.map +0 -1
- package/dist/exportParser.js +0 -518
- package/dist/exportParser.js.map +0 -1
- package/dist/getDefaultTagStructureForMode.js +0 -188
- package/dist/getDefaultTagStructureForMode.js.map +0 -1
- package/dist/getJsdocProcessorPlugin.d.cts +0 -70
- package/dist/getJsdocProcessorPlugin.d.cts.map +0 -1
- package/dist/getJsdocProcessorPlugin.js +0 -383
- package/dist/getJsdocProcessorPlugin.js.map +0 -1
- package/dist/index.d.cts +0 -22
- package/dist/index.d.cts.map +0 -1
- package/dist/index.js +0 -425
- package/dist/index.js.map +0 -1
- package/dist/iterateJsdoc.d.cts +0 -471
- package/dist/iterateJsdoc.d.cts.map +0 -1
- package/dist/iterateJsdoc.js +0 -1617
- package/dist/iterateJsdoc.js.map +0 -1
- package/dist/jsdocUtils.js +0 -1123
- package/dist/jsdocUtils.js.map +0 -1
- package/dist/rules/checkAccess.js +0 -33
- package/dist/rules/checkAccess.js.map +0 -1
- package/dist/rules/checkAlignment.js +0 -47
- package/dist/rules/checkAlignment.js.map +0 -1
- package/dist/rules/checkExamples.js +0 -348
- package/dist/rules/checkExamples.js.map +0 -1
- package/dist/rules/checkIndentation.js +0 -59
- package/dist/rules/checkIndentation.js.map +0 -1
- package/dist/rules/checkLineAlignment.js +0 -229
- package/dist/rules/checkLineAlignment.js.map +0 -1
- package/dist/rules/checkParamNames.js +0 -237
- package/dist/rules/checkParamNames.js.map +0 -1
- package/dist/rules/checkPropertyNames.js +0 -88
- package/dist/rules/checkPropertyNames.js.map +0 -1
- package/dist/rules/checkSyntax.js +0 -25
- package/dist/rules/checkSyntax.js.map +0 -1
- package/dist/rules/checkTagNames.js +0 -191
- package/dist/rules/checkTagNames.js.map +0 -1
- package/dist/rules/checkTemplateNames.js +0 -124
- package/dist/rules/checkTemplateNames.js.map +0 -1
- package/dist/rules/checkTypes.js +0 -299
- package/dist/rules/checkTypes.js.map +0 -1
- package/dist/rules/checkValues.js +0 -103
- package/dist/rules/checkValues.js.map +0 -1
- package/dist/rules/convertToJsdocComments.js +0 -231
- package/dist/rules/convertToJsdocComments.js.map +0 -1
- package/dist/rules/emptyTags.js +0 -67
- package/dist/rules/emptyTags.js.map +0 -1
- package/dist/rules/implementsOnClasses.js +0 -40
- package/dist/rules/implementsOnClasses.js.map +0 -1
- package/dist/rules/importsAsDependencies.js +0 -68
- package/dist/rules/importsAsDependencies.js.map +0 -1
- package/dist/rules/informativeDocs.js +0 -110
- package/dist/rules/informativeDocs.js.map +0 -1
- package/dist/rules/linesBeforeBlock.js +0 -75
- package/dist/rules/linesBeforeBlock.js.map +0 -1
- package/dist/rules/matchDescription.js +0 -167
- package/dist/rules/matchDescription.js.map +0 -1
- package/dist/rules/matchName.js +0 -77
- package/dist/rules/matchName.js.map +0 -1
- package/dist/rules/multilineBlocks.js +0 -245
- package/dist/rules/multilineBlocks.js.map +0 -1
- package/dist/rules/noBadBlocks.js +0 -68
- package/dist/rules/noBadBlocks.js.map +0 -1
- package/dist/rules/noBlankBlockDescriptions.js +0 -41
- package/dist/rules/noBlankBlockDescriptions.js.map +0 -1
- package/dist/rules/noBlankBlocks.js +0 -30
- package/dist/rules/noBlankBlocks.js.map +0 -1
- package/dist/rules/noDefaults.js +0 -56
- package/dist/rules/noDefaults.js.map +0 -1
- package/dist/rules/noMissingSyntax.js +0 -126
- package/dist/rules/noMissingSyntax.js.map +0 -1
- package/dist/rules/noMultiAsterisks.js +0 -58
- package/dist/rules/noMultiAsterisks.js.map +0 -1
- package/dist/rules/noRestrictedSyntax.js +0 -49
- package/dist/rules/noRestrictedSyntax.js.map +0 -1
- package/dist/rules/noTypes.js +0 -65
- package/dist/rules/noTypes.js.map +0 -1
- package/dist/rules/noUndefinedTypes.js +0 -303
- package/dist/rules/noUndefinedTypes.js.map +0 -1
- package/dist/rules/requireAsteriskPrefix.js +0 -112
- package/dist/rules/requireAsteriskPrefix.js.map +0 -1
- package/dist/rules/requireDescription.js +0 -95
- package/dist/rules/requireDescription.js.map +0 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +0 -220
- package/dist/rules/requireDescriptionCompleteSentence.js.map +0 -1
- package/dist/rules/requireExample.js +0 -77
- package/dist/rules/requireExample.js.map +0 -1
- package/dist/rules/requireFileOverview.js +0 -81
- package/dist/rules/requireFileOverview.js.map +0 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +0 -89
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +0 -1
- package/dist/rules/requireJsdoc.js +0 -404
- package/dist/rules/requireJsdoc.js.map +0 -1
- package/dist/rules/requireParam.js +0 -344
- package/dist/rules/requireParam.js.map +0 -1
- package/dist/rules/requireParamDescription.js +0 -59
- package/dist/rules/requireParamDescription.js.map +0 -1
- package/dist/rules/requireParamName.js +0 -36
- package/dist/rules/requireParamName.js.map +0 -1
- package/dist/rules/requireParamType.js +0 -59
- package/dist/rules/requireParamType.js.map +0 -1
- package/dist/rules/requireProperty.js +0 -35
- package/dist/rules/requireProperty.js.map +0 -1
- package/dist/rules/requirePropertyDescription.js +0 -21
- package/dist/rules/requirePropertyDescription.js.map +0 -1
- package/dist/rules/requirePropertyName.js +0 -21
- package/dist/rules/requirePropertyName.js.map +0 -1
- package/dist/rules/requirePropertyType.js +0 -21
- package/dist/rules/requirePropertyType.js.map +0 -1
- package/dist/rules/requireReturns.js +0 -131
- package/dist/rules/requireReturns.js.map +0 -1
- package/dist/rules/requireReturnsCheck.js +0 -66
- package/dist/rules/requireReturnsCheck.js.map +0 -1
- package/dist/rules/requireReturnsDescription.js +0 -43
- package/dist/rules/requireReturnsDescription.js.map +0 -1
- package/dist/rules/requireReturnsType.js +0 -36
- package/dist/rules/requireReturnsType.js.map +0 -1
- package/dist/rules/requireTemplate.js +0 -122
- package/dist/rules/requireTemplate.js.map +0 -1
- package/dist/rules/requireThrows.js +0 -67
- package/dist/rules/requireThrows.js.map +0 -1
- package/dist/rules/requireYields.js +0 -115
- package/dist/rules/requireYields.js.map +0 -1
- package/dist/rules/requireYieldsCheck.js +0 -105
- package/dist/rules/requireYieldsCheck.js.map +0 -1
- package/dist/rules/sortTags.js +0 -262
- package/dist/rules/sortTags.js.map +0 -1
- package/dist/rules/tagLines.js +0 -183
- package/dist/rules/tagLines.js.map +0 -1
- package/dist/rules/textEscaping.js +0 -102
- package/dist/rules/textEscaping.js.map +0 -1
- package/dist/rules/validTypes.js +0 -259
- package/dist/rules/validTypes.js.map +0 -1
- package/dist/tagNames.js +0 -144
- package/dist/tagNames.js.map +0 -1
- package/dist/utils/hasReturnValue.js +0 -265
- package/dist/utils/hasReturnValue.js.map +0 -1
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requirePropertyName.js
|
|
4
|
-
var requirePropertyName_default = iterateJsdoc(({ report, utils }) => {
|
|
5
|
-
utils.forEachPreferredTag("property", (jsdoc, targetTagName) => {
|
|
6
|
-
if (jsdoc.tag && jsdoc.name === "") report(`There must be an identifier after @${targetTagName} ${jsdoc.type === "" ? "type" : "tag"}.`, null, jsdoc);
|
|
7
|
-
});
|
|
8
|
-
}, {
|
|
9
|
-
iterateAllJsdocs: true,
|
|
10
|
-
meta: {
|
|
11
|
-
docs: {
|
|
12
|
-
description: "Requires that all function `@property` tags have names.",
|
|
13
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header"
|
|
14
|
-
},
|
|
15
|
-
type: "suggestion"
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { requirePropertyName_default as default };
|
|
21
|
-
//# sourceMappingURL=requirePropertyName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requirePropertyName.js","names":[],"sources":["../../src/rules/requirePropertyName.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.tag && jsdoc.name === '') {\n report(\n `There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that all function `@property` tags have names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header',\n },\n type: 'suggestion',\n },\n});\n"],"mappings":";;;AAEA,kCAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;CACJ,MAAM,oBAAoB,YAAY,CAAC,OAAO,kBAAkB;AAC9D,MAAI,MAAM,OAAO,MAAM,SAAS,IAC9B,OACE,CAAC,mCAAmC,EAAE,cAAc,CAAC,EAAE,MAAM,SAAS,KAAK,SAAS,MAAM,CAAC,CAAC,EAC5F,MACA,MACD;CAEJ,EAAC;AACH,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requirePropertyType.js
|
|
4
|
-
var requirePropertyType_default = iterateJsdoc(({ report, utils }) => {
|
|
5
|
-
utils.forEachPreferredTag("property", (jsdoc, targetTagName) => {
|
|
6
|
-
if (!jsdoc.type) report(`Missing JSDoc @${targetTagName} "${jsdoc.name}" type.`, null, jsdoc);
|
|
7
|
-
});
|
|
8
|
-
}, {
|
|
9
|
-
iterateAllJsdocs: true,
|
|
10
|
-
meta: {
|
|
11
|
-
docs: {
|
|
12
|
-
description: "Requires that each `@property` tag has a `type` value.",
|
|
13
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header"
|
|
14
|
-
},
|
|
15
|
-
type: "suggestion"
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { requirePropertyType_default as default };
|
|
21
|
-
//# sourceMappingURL=requirePropertyType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requirePropertyType.js","names":[],"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.',\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":";;;AAEA,kCAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;CACJ,MAAM,oBAAoB,YAAY,CAAC,OAAO,kBAAkB;AAC9D,MAAI,CAAC,MAAM,MACT,OACE,CAAC,eAAe,EAAE,cAAc,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,EACvD,MACA,MACD;CAEJ,EAAC;AACH,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
import exportParser_default from "../exportParser.js";
|
|
3
|
-
|
|
4
|
-
//#region src/rules/requireReturns.js
|
|
5
|
-
/**
|
|
6
|
-
* We can skip checking for a return value, in case the documentation is inherited
|
|
7
|
-
* or the method is either a constructor or an abstract method.
|
|
8
|
-
*
|
|
9
|
-
* In either of these cases the return value is optional or not defined.
|
|
10
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
11
|
-
* a reference to the utils which are used to probe if a tag is present or not.
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
* true in case deep checking can be skipped; otherwise false.
|
|
14
|
-
*/
|
|
15
|
-
const canSkip = (utils) => {
|
|
16
|
-
return utils.hasATag([
|
|
17
|
-
"abstract",
|
|
18
|
-
"virtual",
|
|
19
|
-
"class",
|
|
20
|
-
"constructor",
|
|
21
|
-
"type",
|
|
22
|
-
"interface"
|
|
23
|
-
]) || utils.avoidDocs();
|
|
24
|
-
};
|
|
25
|
-
var requireReturns_default = iterateJsdoc(({ context, info: { comment }, node, report, settings, utils }) => {
|
|
26
|
-
const { contexts, enableFixer = false, forceRequireReturn = false, forceReturnsWithAsync = false, publicOnly = false } = context.options[0] || {};
|
|
27
|
-
if (canSkip(utils)) return;
|
|
28
|
-
/** @type {boolean|undefined} */
|
|
29
|
-
let forceRequireReturnContext;
|
|
30
|
-
if (contexts) {
|
|
31
|
-
const { foundContext } = utils.findContext(contexts, comment);
|
|
32
|
-
if (typeof foundContext === "object") forceRequireReturnContext = foundContext.forceRequireReturn;
|
|
33
|
-
}
|
|
34
|
-
const tagName = utils.getPreferredTagName({ tagName: "returns" });
|
|
35
|
-
if (!tagName) return;
|
|
36
|
-
const tags = utils.getTags(tagName);
|
|
37
|
-
if (tags.length > 1) report(`Found more than one @${tagName} declaration.`);
|
|
38
|
-
const iteratingFunction = utils.isIteratingFunction();
|
|
39
|
-
const [tag] = tags;
|
|
40
|
-
const missingReturnTag = typeof tag === "undefined" || tag === null;
|
|
41
|
-
const shouldReport = () => {
|
|
42
|
-
if (!missingReturnTag) return false;
|
|
43
|
-
if (publicOnly) {
|
|
44
|
-
/** @type {import('./requireJsdoc.js').RequireJsdocOpts} */
|
|
45
|
-
const opt = {
|
|
46
|
-
ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
|
|
47
|
-
esm: Boolean(publicOnly?.esm ?? true),
|
|
48
|
-
initModuleExports: Boolean(publicOnly?.cjs ?? true),
|
|
49
|
-
initWindow: Boolean(publicOnly?.window ?? false)
|
|
50
|
-
};
|
|
51
|
-
/* c8 ignore next -- Fallback to deprecated method */
|
|
52
|
-
const { sourceCode = context.getSourceCode() } = context;
|
|
53
|
-
const exported = exportParser_default.isUncommentedExport(node, sourceCode, opt, settings);
|
|
54
|
-
if (!exported) return false;
|
|
55
|
-
}
|
|
56
|
-
if ((forceRequireReturn || forceRequireReturnContext) && (iteratingFunction || utils.isVirtualFunction())) return true;
|
|
57
|
-
const isAsync = !iteratingFunction && utils.hasTag("async") || iteratingFunction && utils.isAsync();
|
|
58
|
-
if (forceReturnsWithAsync && isAsync) return true;
|
|
59
|
-
return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync);
|
|
60
|
-
};
|
|
61
|
-
if (shouldReport()) utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {
|
|
62
|
-
utils.addTag(tagName);
|
|
63
|
-
} : null);
|
|
64
|
-
}, {
|
|
65
|
-
contextDefaults: true,
|
|
66
|
-
meta: {
|
|
67
|
-
docs: {
|
|
68
|
-
description: "Requires that returns are documented.",
|
|
69
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header"
|
|
70
|
-
},
|
|
71
|
-
fixable: "code",
|
|
72
|
-
schema: [{
|
|
73
|
-
additionalProperties: false,
|
|
74
|
-
properties: {
|
|
75
|
-
checkConstructors: {
|
|
76
|
-
default: false,
|
|
77
|
-
type: "boolean"
|
|
78
|
-
},
|
|
79
|
-
checkGetters: {
|
|
80
|
-
default: true,
|
|
81
|
-
type: "boolean"
|
|
82
|
-
},
|
|
83
|
-
contexts: {
|
|
84
|
-
items: { anyOf: [{ type: "string" }, {
|
|
85
|
-
additionalProperties: false,
|
|
86
|
-
properties: {
|
|
87
|
-
comment: { type: "string" },
|
|
88
|
-
context: { type: "string" },
|
|
89
|
-
forceRequireReturn: { type: "boolean" }
|
|
90
|
-
},
|
|
91
|
-
type: "object"
|
|
92
|
-
}] },
|
|
93
|
-
type: "array"
|
|
94
|
-
},
|
|
95
|
-
enableFixer: { type: "boolean" },
|
|
96
|
-
exemptedBy: {
|
|
97
|
-
items: { type: "string" },
|
|
98
|
-
type: "array"
|
|
99
|
-
},
|
|
100
|
-
forceRequireReturn: {
|
|
101
|
-
default: false,
|
|
102
|
-
type: "boolean"
|
|
103
|
-
},
|
|
104
|
-
forceReturnsWithAsync: {
|
|
105
|
-
default: false,
|
|
106
|
-
type: "boolean"
|
|
107
|
-
},
|
|
108
|
-
publicOnly: { oneOf: [{
|
|
109
|
-
default: false,
|
|
110
|
-
type: "boolean"
|
|
111
|
-
}, {
|
|
112
|
-
additionalProperties: false,
|
|
113
|
-
default: {},
|
|
114
|
-
properties: {
|
|
115
|
-
ancestorsOnly: { type: "boolean" },
|
|
116
|
-
cjs: { type: "boolean" },
|
|
117
|
-
esm: { type: "boolean" },
|
|
118
|
-
window: { type: "boolean" }
|
|
119
|
-
},
|
|
120
|
-
type: "object"
|
|
121
|
-
}] }
|
|
122
|
-
},
|
|
123
|
-
type: "object"
|
|
124
|
-
}],
|
|
125
|
-
type: "suggestion"
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
//#endregion
|
|
130
|
-
export { requireReturns_default as default };
|
|
131
|
-
//# sourceMappingURL=requireReturns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturns.js","names":["exportParser"],"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 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.',\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 type: 'boolean',\n },\n checkGetters: {\n default: true,\n type: 'boolean',\n },\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 forceRequireReturn: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n type: 'boolean',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n type: 'boolean',\n },\n publicOnly: {\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,MAAM,UAAU,CAAC,UAAU;AACzB,QAAO,MAAM,QAAQ;EAMnB;EACA;EAIA;EACA;EAGA;EAGA;CACD,EAAC,IACA,MAAM,WAAW;AACpB;AAED,6BAAe,aAAa,CAAC,EAC3B,SACA,MAAM,EACJ,SACD,EACD,MACA,QACA,UACA,OACD,KAAK;CACJ,MAAM,EACJ,UACA,cAAc,OACd,qBAAqB,OACrB,wBAAwB,OACxB,aAAa,OACd,GAAG,QAAQ,QAAQ,MAAM,CAAE;AAI5B,KAAI,QAAQ,MAAM,CAChB;;CAIF,IAAI;AACJ,KAAI,UAAU;EACZ,MAAM,EACJ,cACD,GAAG,MAAM,YAAY,UAAU,QAAQ;AACxC,MAAI,OAAO,iBAAiB,UAC1B,4BAA4B,aAAa;CAE5C;CAED,MAAM,UAAiC,MAAM,oBAAoB,EAC/D,SAAS,UACV,EAAC;AACF,KAAI,CAAC,QACH;CAGF,MAAM,OAAO,MAAM,QAAQ,QAAQ;AAEnC,KAAI,KAAK,SAAS,GAChB,OAAO,CAAC,qBAAqB,EAAE,QAAQ,aAAa,CAAC,CAAC;CAGxD,MAAM,oBAAoB,MAAM,qBAAqB;CAGrD,MAAM,CACJ,IACD,GAAG;CACJ,MAAM,mBAAmB,OAAO,QAAQ,eAAe,QAAQ;CAE/D,MAAM,eAAe,MAAM;AACzB,MAAI,CAAC,iBACH,QAAO;AAGT,MAAI,YAAY;;GAEd,MAAM,MAAM;IACV,eAAe,QAAQ,YAAY,iBAAiB,MAAM;IAC1D,KAAK,QAAQ,YAAY,OAAO,KAAK;IACrC,mBAAmB,QAAQ,YAAY,OAAO,KAAK;IACnD,YAAY,QAAQ,YAAY,UAAU,MAAM;GACjD;;GAED,MAAM,EACJ,aAAa,QAAQ,eAAe,EACrC,GAAG;GACJ,MAAM,WAAWA,qBAAa,oBACe,MAAO,YAAY,KAAK,SACpE;AAED,OAAI,CAAC,SACH,QAAO;EAEV;AAED,OAAK,sBAAsB,+BACzB,qBAAqB,MAAM,mBAAmB,EAE9C,QAAO;EAGT,MAAM,UAAU,CAAC,qBAAqB,MAAM,OAAO,QAAQ,IACzD,qBAAqB,MAAM,SAAS;AAEtC,MAAI,yBAAyB,QAC3B,QAAO;AAGT,SAAO,qBAAqB,MAAM,0CAChC,sBACD;CACF;AAED,KAAI,cAAc,EAChB,MAAM,YAAY,CAAC,eAAe,EAAE,QAAQ,aAAa,CAAC,EAAE,MAAM,cAAc,MAAM;EACpF,MAAM,OAAO,QAAQ;CACtB,IAAG,KAAK;AAEZ,GAAE;CACD,iBAAiB;CACjB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,SAAS;EACT,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY;IACV,mBAAmB;KACjB,SAAS;KACT,MAAM;IACP;IACD,cAAc;KACZ,SAAS;KACT,MAAM;IACP;IACD,UAAU;KACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;MACE,sBAAsB;MACtB,YAAY;OACV,SAAS,EACP,MAAM,SACP;OACD,SAAS,EACP,MAAM,SACP;OACD,oBAAoB,EAClB,MAAM,UACP;MACF;MACD,MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,aAAa,EACX,MAAM,UACP;IACD,YAAY;KACV,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;IACD,oBAAoB;KAClB,SAAS;KACT,MAAM;IACP;IACD,uBAAuB;KACrB,SAAS;KACT,MAAM;IACP;IACD,YAAY,EACV,OAAO,CACL;KACE,SAAS;KACT,MAAM;IACP,GACD;KACE,sBAAsB;KACtB,SAAS,CAAE;KACX,YAAY;MACV,eAAe,EACb,MAAM,UACP;MACD,KAAK,EACH,MAAM,UACP;MACD,KAAK,EACH,MAAM,UACP;MACD,QAAQ,EACN,MAAM,UACP;KACF;KACD,MAAM;IACP,CACF,EACF;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requireReturnsCheck.js
|
|
4
|
-
/**
|
|
5
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
6
|
-
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
7
|
-
* @returns {boolean}
|
|
8
|
-
*/
|
|
9
|
-
const canSkip = (utils, settings) => {
|
|
10
|
-
const voidingTags = [
|
|
11
|
-
"abstract",
|
|
12
|
-
"virtual",
|
|
13
|
-
"class",
|
|
14
|
-
"constructor",
|
|
15
|
-
"interface"
|
|
16
|
-
];
|
|
17
|
-
if (settings.mode === "closure") voidingTags.push("record");
|
|
18
|
-
return utils.hasATag(voidingTags) || utils.isConstructor() || utils.classHasTag("interface") || settings.mode === "closure" && utils.classHasTag("record");
|
|
19
|
-
};
|
|
20
|
-
var requireReturnsCheck_default = iterateJsdoc(({ context, node, report, settings, utils }) => {
|
|
21
|
-
const { exemptAsync = true, exemptGenerators = settings.mode === "typescript", reportMissingReturnForUndefinedTypes = false } = context.options[0] || {};
|
|
22
|
-
if (canSkip(utils, settings)) return;
|
|
23
|
-
if (exemptAsync && utils.isAsync()) return;
|
|
24
|
-
const tagName = utils.getPreferredTagName({ tagName: "returns" });
|
|
25
|
-
if (!tagName) return;
|
|
26
|
-
const tags = utils.getTags(tagName);
|
|
27
|
-
if (tags.length === 0) return;
|
|
28
|
-
if (tags.length > 1) {
|
|
29
|
-
report(`Found more than one @${tagName} declaration.`);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const [tag] = tags;
|
|
33
|
-
const type = tag.type.trim();
|
|
34
|
-
if (/asserts\s/v.test(type)) return;
|
|
35
|
-
const returnNever = type === "never";
|
|
36
|
-
if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {
|
|
37
|
-
report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!returnNever && (reportMissingReturnForUndefinedTypes || !utils.mayBeUndefinedTypeTag(tag)) && (tag.type === "" && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) || tag.type !== "" && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true)) && Boolean(!exemptGenerators || !node || !("generator" in node) || !node.generator)) report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
|
|
41
|
-
}, { meta: {
|
|
42
|
-
docs: {
|
|
43
|
-
description: "Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.",
|
|
44
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header"
|
|
45
|
-
},
|
|
46
|
-
schema: [{
|
|
47
|
-
additionalProperties: false,
|
|
48
|
-
properties: {
|
|
49
|
-
exemptAsync: {
|
|
50
|
-
default: true,
|
|
51
|
-
type: "boolean"
|
|
52
|
-
},
|
|
53
|
-
exemptGenerators: { type: "boolean" },
|
|
54
|
-
reportMissingReturnForUndefinedTypes: {
|
|
55
|
-
default: false,
|
|
56
|
-
type: "boolean"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
type: "object"
|
|
60
|
-
}],
|
|
61
|
-
type: "suggestion"
|
|
62
|
-
} });
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
export { requireReturnsCheck_default as default };
|
|
66
|
-
//# sourceMappingURL=requireReturnsCheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsCheck.js","names":[],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Settings} settings\n * @returns {boolean}\n */\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\n// eslint-disable-next-line complexity -- Temporary\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.isAsync()) {\n return;\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 === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/v.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n Boolean(\n !exemptGenerators || !node ||\n !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||\n !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,\n )\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;AAOA,MAAM,UAAU,CAAC,OAAO,aAAa;CACnC,MAAM,cAAc;EAMlB;EACA;EAIA;EACA;EACA;CACD;AAED,KAAI,SAAS,SAAS,WAEpB,YAAY,KAAK,SAAS;AAG5B,QAAO,MAAM,QAAQ,YAAY,IAC/B,MAAM,eAAe,IACrB,MAAM,YAAY,YAAY,IAC9B,SAAS,SAAS,aAAa,MAAM,YAAY,SAAS;AAC7D;AAGD,kCAAe,aAAa,CAAC,EAC3B,SACA,MACA,QACA,UACA,OACD,KAAK;CACJ,MAAM,EACJ,cAAc,MACd,mBAAmB,SAAS,SAAS,cACrC,uCAAuC,OACxC,GAAG,QAAQ,QAAQ,MAAM,CAAE;AAE5B,KAAI,QAAQ,OAAO,SAAS,CAC1B;AAGF,KAAI,eAAe,MAAM,SAAS,CAChC;CAGF,MAAM,UAAiC,MAAM,oBAAoB,EAC/D,SAAS,UACV,EAAC;AACF,KAAI,CAAC,QACH;CAGF,MAAM,OAAO,MAAM,QAAQ,QAAQ;AAEnC,KAAI,KAAK,WAAW,EAClB;AAGF,KAAI,KAAK,SAAS,GAAG;EACnB,OAAO,CAAC,qBAAqB,EAAE,QAAQ,aAAa,CAAC,CAAC;AAEtD;CACD;CAED,MAAM,CACJ,IACD,GAAG;CAEJ,MAAM,OAAO,IAAI,KAAK,MAAM;AAG5B,KAAI,aAAa,KAAK,KAAK,CACzB;CAGF,MAAM,cAAc,SAAS;AAE7B,KAAI,eAAe,MAAM,0CAA0C,MAAM,EAAE;EACzE,OAAO,CAAC,OAAO,EAAE,QAAQ,2EAA2E,CAAC,CAAC;AAEtG;CACD;AAGD,KACE,CAAC,gBAEC,wCACA,CAAC,MAAM,sBAAsB,IAAI,MAElC,IAAI,SAAS,MAAM,CAAC,MAAM,0CACzB,YACD,IACD,IAAI,SAAS,MAAM,CAAC,MAAM,0CACxB,aACA,KACD,KACD,QACE,CAAC,oBAAoB,CAAC,QACtB,EAAE,eAAiE,SACnE,CAAkF,KAAO,UAC1F,EAED,OAAO,CAAC,OAAO,EAAE,QAAQ,qEAAqE,CAAC,CAAC;AAEnG,GAAE,EACD,MAAM;CACJ,MAAM;EACJ,aAAa;EACb,KAAK;CACN;CACD,QAAQ,CACN;EACE,sBAAsB;EACtB,YAAY;GACV,aAAa;IACX,SAAS;IACT,MAAM;GACP;GACD,kBAAkB,EAChB,MAAM,UACP;GACD,sCAAsC;IACpC,SAAS;IACT,MAAM;GACP;EACF;EACD,MAAM;CACP,CACF;CACD,MAAM;AACP,EACF,EAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requireReturnsDescription.js
|
|
4
|
-
var requireReturnsDescription_default = iterateJsdoc(({ report, utils }) => {
|
|
5
|
-
utils.forEachPreferredTag("returns", (jsdocTag, targetTagName) => {
|
|
6
|
-
const type = jsdocTag.type && jsdocTag.type.trim();
|
|
7
|
-
if ([
|
|
8
|
-
"Promise<undefined>",
|
|
9
|
-
"Promise<void>",
|
|
10
|
-
"undefined",
|
|
11
|
-
"void"
|
|
12
|
-
].includes(type)) return;
|
|
13
|
-
if (!jsdocTag.description.trim()) report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag);
|
|
14
|
-
});
|
|
15
|
-
}, {
|
|
16
|
-
contextDefaults: true,
|
|
17
|
-
meta: {
|
|
18
|
-
docs: {
|
|
19
|
-
description: "Requires that the `@returns` tag has a `description` value.",
|
|
20
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header"
|
|
21
|
-
},
|
|
22
|
-
schema: [{
|
|
23
|
-
additionalProperties: false,
|
|
24
|
-
properties: { contexts: {
|
|
25
|
-
items: { anyOf: [{ type: "string" }, {
|
|
26
|
-
additionalProperties: false,
|
|
27
|
-
properties: {
|
|
28
|
-
comment: { type: "string" },
|
|
29
|
-
context: { type: "string" }
|
|
30
|
-
},
|
|
31
|
-
type: "object"
|
|
32
|
-
}] },
|
|
33
|
-
type: "array"
|
|
34
|
-
} },
|
|
35
|
-
type: "object"
|
|
36
|
-
}],
|
|
37
|
-
type: "suggestion"
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { requireReturnsDescription_default as default };
|
|
43
|
-
//# sourceMappingURL=requireReturnsDescription.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsDescription.js","names":[],"sources":["../../src/rules/requireReturnsDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n const type = jsdocTag.type && jsdocTag.type.trim();\n\n if ([\n 'Promise<undefined>', 'Promise<void>', 'undefined', 'void',\n ].includes(type)) {\n return;\n }\n\n if (!jsdocTag.description.trim()) {\n report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that the `@returns` tag has a `description` value.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.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 },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;AAEA,wCAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;CACJ,MAAM,oBAAoB,WAAW,CAAC,UAAU,kBAAkB;EAChE,MAAM,OAAO,SAAS,QAAQ,SAAS,KAAK,MAAM;AAElD,MAAI;GACF;GAAsB;GAAiB;GAAa;EACrD,EAAC,SAAS,KAAK,CACd;AAGF,MAAI,CAAC,SAAS,YAAY,MAAM,EAC9B,OAAO,CAAC,eAAe,EAAE,cAAc,aAAa,CAAC,EAAE,MAAM,SAAS;CAEzE,EAAC;AACH,GAAE;CACD,iBAAiB;CACjB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY,EACV,UAAU;IACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;KACE,sBAAsB;KACtB,YAAY;MACV,SAAS,EACP,MAAM,SACP;MACD,SAAS,EACP,MAAM,SACP;KACF;KACD,MAAM;IACP,CACF,EACF;IACD,MAAM;GACP,EACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requireReturnsType.js
|
|
4
|
-
var requireReturnsType_default = iterateJsdoc(({ report, utils }) => {
|
|
5
|
-
utils.forEachPreferredTag("returns", (jsdocTag, targetTagName) => {
|
|
6
|
-
if (!jsdocTag.type) report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag);
|
|
7
|
-
});
|
|
8
|
-
}, {
|
|
9
|
-
contextDefaults: true,
|
|
10
|
-
meta: {
|
|
11
|
-
docs: {
|
|
12
|
-
description: "Requires that `@returns` tag has `type` value.",
|
|
13
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header"
|
|
14
|
-
},
|
|
15
|
-
schema: [{
|
|
16
|
-
additionalProperties: false,
|
|
17
|
-
properties: { contexts: {
|
|
18
|
-
items: { anyOf: [{ type: "string" }, {
|
|
19
|
-
additionalProperties: false,
|
|
20
|
-
properties: {
|
|
21
|
-
comment: { type: "string" },
|
|
22
|
-
context: { type: "string" }
|
|
23
|
-
},
|
|
24
|
-
type: "object"
|
|
25
|
-
}] },
|
|
26
|
-
type: "array"
|
|
27
|
-
} },
|
|
28
|
-
type: "object"
|
|
29
|
-
}],
|
|
30
|
-
type: "suggestion"
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { requireReturnsType_default as default };
|
|
36
|
-
//# sourceMappingURL=requireReturnsType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsType.js","names":[],"sources":["../../src/rules/requireReturnsType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n if (!jsdocTag.type) {\n report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that `@returns` tag has `type` value.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.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 },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;AAEA,iCAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;CACJ,MAAM,oBAAoB,WAAW,CAAC,UAAU,kBAAkB;AAChE,MAAI,CAAC,SAAS,MACZ,OAAO,CAAC,eAAe,EAAE,cAAc,MAAM,CAAC,EAAE,MAAM,SAAS;CAElE,EAAC;AACH,GAAE;CACD,iBAAiB;CACjB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY,EACV,UAAU;IACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;KACE,sBAAsB;KACtB,YAAY;MACV,SAAS,EACP,MAAM,SACP;MACD,SAAS,EACP,MAAM,SACP;KACF;KACD,MAAM;IACP,CACF,EACF;IACD,MAAM;GACP,EACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
import { parse, traverse, tryParse } from "@es-joy/jsdoccomment";
|
|
3
|
-
|
|
4
|
-
//#region src/rules/requireTemplate.js
|
|
5
|
-
var requireTemplate_default = iterateJsdoc(({ context, node, report, settings, utils }) => {
|
|
6
|
-
const { requireSeparateTemplates = false } = context.options[0] || {};
|
|
7
|
-
const { mode } = settings;
|
|
8
|
-
const usedNames = /* @__PURE__ */ new Set();
|
|
9
|
-
const templateTags = utils.getTags("template");
|
|
10
|
-
const templateNames = templateTags.flatMap((tag) => {
|
|
11
|
-
return utils.parseClosureTemplateTag(tag);
|
|
12
|
-
});
|
|
13
|
-
if (requireSeparateTemplates) for (const tag of templateTags) {
|
|
14
|
-
const { name } = tag;
|
|
15
|
-
const names = name.split(/,\s*/v);
|
|
16
|
-
if (names.length > 1) report(`Missing separate @template for ${names[1]}`, null, tag);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
20
|
-
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
21
|
-
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
22
|
-
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
23
|
-
*/
|
|
24
|
-
const checkTypeParams = (aliasDeclaration) => {
|
|
25
|
-
const { params } = aliasDeclaration.typeParameters ?? { params: [] };
|
|
26
|
-
for (const { name: { name } } of params) usedNames.add(name);
|
|
27
|
-
for (const usedName of usedNames) if (!templateNames.includes(usedName)) report(`Missing @template ${usedName}`);
|
|
28
|
-
};
|
|
29
|
-
const handleTypes = () => {
|
|
30
|
-
const nde = node;
|
|
31
|
-
if (!nde) return;
|
|
32
|
-
switch (nde.type) {
|
|
33
|
-
case "ClassDeclaration":
|
|
34
|
-
case "FunctionDeclaration":
|
|
35
|
-
case "TSInterfaceDeclaration":
|
|
36
|
-
case "TSTypeAliasDeclaration":
|
|
37
|
-
checkTypeParams(nde);
|
|
38
|
-
break;
|
|
39
|
-
case "ExportDefaultDeclaration":
|
|
40
|
-
switch (nde.declaration?.type) {
|
|
41
|
-
case "ClassDeclaration":
|
|
42
|
-
case "FunctionDeclaration":
|
|
43
|
-
case "TSInterfaceDeclaration":
|
|
44
|
-
checkTypeParams(nde.declaration);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
case "ExportNamedDeclaration":
|
|
49
|
-
switch (nde.declaration?.type) {
|
|
50
|
-
case "ClassDeclaration":
|
|
51
|
-
case "FunctionDeclaration":
|
|
52
|
-
case "TSInterfaceDeclaration":
|
|
53
|
-
case "TSTypeAliasDeclaration":
|
|
54
|
-
checkTypeParams(nde.declaration);
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const usedNameToTag = /* @__PURE__ */ new Map();
|
|
61
|
-
/**
|
|
62
|
-
* @param {import('comment-parser').Spec} potentialTag
|
|
63
|
-
*/
|
|
64
|
-
const checkForUsedTypes = (potentialTag) => {
|
|
65
|
-
let parsedType;
|
|
66
|
-
try {
|
|
67
|
-
parsedType = mode === "permissive" ? tryParse(potentialTag.type) : parse(potentialTag.type, mode);
|
|
68
|
-
} catch {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
traverse(parsedType, (nde) => {
|
|
72
|
-
const { type, value } = nde;
|
|
73
|
-
if (type === "JsdocTypeName" && /^[A-Z]$/v.test(value)) {
|
|
74
|
-
usedNames.add(value);
|
|
75
|
-
if (!usedNameToTag.has(value)) usedNameToTag.set(value, potentialTag);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* @param {string[]} tagNames
|
|
81
|
-
*/
|
|
82
|
-
const checkTagsAndTemplates = (tagNames) => {
|
|
83
|
-
for (const tagName of tagNames) {
|
|
84
|
-
const preferredTagName = utils.getPreferredTagName({ tagName });
|
|
85
|
-
const matchingTags = utils.getTags(preferredTagName);
|
|
86
|
-
for (const matchingTag of matchingTags) checkForUsedTypes(matchingTag);
|
|
87
|
-
}
|
|
88
|
-
for (const usedName of usedNames) if (!templateNames.includes(usedName)) report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));
|
|
89
|
-
};
|
|
90
|
-
const callbackTags = utils.getTags("callback");
|
|
91
|
-
const functionTags = utils.getTags("function");
|
|
92
|
-
if (callbackTags.length || functionTags.length) {
|
|
93
|
-
checkTagsAndTemplates(["param", "returns"]);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const typedefTags = utils.getTags("typedef");
|
|
97
|
-
if (!typedefTags.length || typedefTags.length >= 2) {
|
|
98
|
-
handleTypes();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const potentialTypedef = typedefTags[0];
|
|
102
|
-
checkForUsedTypes(potentialTypedef);
|
|
103
|
-
checkTagsAndTemplates(["property"]);
|
|
104
|
-
}, {
|
|
105
|
-
iterateAllJsdocs: true,
|
|
106
|
-
meta: {
|
|
107
|
-
docs: {
|
|
108
|
-
description: "Requires template tags for each generic type parameter",
|
|
109
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header"
|
|
110
|
-
},
|
|
111
|
-
schema: [{
|
|
112
|
-
additionalProperties: false,
|
|
113
|
-
properties: { requireSeparateTemplates: { type: "boolean" } },
|
|
114
|
-
type: "object"
|
|
115
|
-
}],
|
|
116
|
-
type: "suggestion"
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
export { requireTemplate_default as default };
|
|
122
|
-
//# sourceMappingURL=requireTemplate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requireTemplate.js","names":["tryParseType","parseType"],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode,\n } = settings;\n\n const usedNames = new Set();\n const templateTags = utils.getTags('template');\n const templateNames = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n if (requireSeparateTemplates) {\n for (const tag of templateTags) {\n const {\n name,\n } = tag;\n const names = name.split(/,\\s*/v);\n if (names.length > 1) {\n report(`Missing separate @template for ${names[1]}`, null, tag);\n }\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkTypeParams = (aliasDeclaration) => {\n const {\n params,\n /* c8 ignore next -- Guard */\n } = aliasDeclaration.typeParameters ?? {\n /* c8 ignore next -- Guard */\n params: [],\n };\n for (const {\n name: {\n name,\n },\n } of params) {\n usedNames.add(name);\n }\n\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`);\n }\n }\n };\n\n const handleTypes = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n\n switch (nde.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde);\n break;\n case 'ExportDefaultDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n }\n };\n\n const usedNameToTag = new Map();\n\n /**\n * @param {import('comment-parser').Spec} potentialTag\n */\n const checkForUsedTypes = (potentialTag) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialTag.type)) :\n parseType(/** @type {string} */ (potentialTag.type), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName' && (/^[A-Z]$/v).test(value)) {\n usedNames.add(value);\n if (!usedNameToTag.has(value)) {\n usedNameToTag.set(value, potentialTag);\n }\n }\n });\n };\n\n /**\n * @param {string[]} tagNames\n */\n const checkTagsAndTemplates = (tagNames) => {\n for (const tagName of tagNames) {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n const matchingTags = utils.getTags(preferredTagName);\n for (const matchingTag of matchingTags) {\n checkForUsedTypes(matchingTag);\n }\n }\n\n // Could check against whitelist/blacklist\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));\n }\n }\n };\n\n const callbackTags = utils.getTags('callback');\n const functionTags = utils.getTags('function');\n if (callbackTags.length || functionTags.length) {\n checkTagsAndTemplates([\n 'param', 'returns',\n ]);\n return;\n }\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypes();\n return;\n }\n\n const potentialTypedef = typedefTags[0];\n checkForUsedTypes(potentialTypedef);\n\n checkTagsAndTemplates([\n 'property',\n ]);\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires template tags for each generic type parameter',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n requireSeparateTemplates: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;AAOA,8BAAe,aAAa,CAAC,EAC3B,SACA,MACA,QACA,UACA,OACD,KAAK;CACJ,MAAM,EACJ,2BAA2B,OAC5B,GAAG,QAAQ,QAAQ,MAAM,CAAE;CAE5B,MAAM,EACJ,MACD,GAAG;CAEJ,MAAM,4BAAY,IAAI;CACtB,MAAM,eAAe,MAAM,QAAQ,WAAW;CAC9C,MAAM,gBAAgB,aAAa,QAAQ,CAAC,QAAQ;AAClD,SAAO,MAAM,wBAAwB,IAAI;CAC1C,EAAC;AAEF,KAAI,yBACF,MAAK,MAAM,OAAO,cAAc;EAC9B,MAAM,EACJ,MACD,GAAG;EACJ,MAAM,QAAQ,KAAK,MAAM,QAAQ;AACjC,MAAI,MAAM,SAAS,GACjB,OAAO,CAAC,+BAA+B,EAAE,MAAM,IAAI,EAAE,MAAM,IAAI;CAElE;;;;;;;CASH,MAAM,kBAAkB,CAAC,qBAAqB;EAC5C,MAAM,EACJ,QAED,GAAG,iBAAiB,kBAAkB,EAErC,QAAQ,CAAE,EACX;AACD,OAAK,MAAM,EACT,MAAM,EACJ,MACD,EACF,IAAI,QACH,UAAU,IAAI,KAAK;AAGrB,OAAK,MAAM,YAAY,UACrB,KAAI,CAAC,cAAc,SAAS,SAAS,EACnC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC;CAG5C;CAED,MAAM,cAAc,MAAM;EACxB,MAAM,MACJ;AAEF,MAAI,CAAC,IACH;AAGF,UAAQ,IAAI,MAAZ;GACE,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;IACH,gBAAgB,IAAI;AACpB;GACF,KAAK;AACH,YAAQ,IAAI,aAAa,MAAzB;KACE,KAAK;KACL,KAAK;KACL,KAAK;MACH,gBAAgB,IAAI,YAAY;AAChC;IACH;AAED;GACF,KAAK;AACH,YAAQ,IAAI,aAAa,MAAzB;KACE,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK;MACH,gBAAgB,IAAI,YAAY;AAChC;IACH;AAED;EACH;CACF;CAED,MAAM,gCAAgB,IAAI;;;;CAK1B,MAAM,oBAAoB,CAAC,iBAAiB;EAC1C,IAAI;AACJ,MAAI;GACF,aAAa,SAAS,eACpBA,SAAoC,aAAa,KAAM,GACvDC,MAAiC,aAAa,MAAO,KAAK;EAC7D,QAAO;AACN;EACD;EAED,SAAS,YAAY,CAAC,QAAQ;GAC5B,MAAM,EACJ,MACA,OACD,GAAgE;AACjE,OAAI,SAAS,mBAAoB,WAAY,KAAK,MAAM,EAAE;IACxD,UAAU,IAAI,MAAM;AACpB,QAAI,CAAC,cAAc,IAAI,MAAM,EAC3B,cAAc,IAAI,OAAO,aAAa;GAEzC;EACF,EAAC;CACH;;;;CAKD,MAAM,wBAAwB,CAAC,aAAa;AAC1C,OAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,mBAA0C,MAAM,oBAAoB,EACxE,QACD,EAAC;GACF,MAAM,eAAe,MAAM,QAAQ,iBAAiB;AACpD,QAAK,MAAM,eAAe,cACxB,kBAAkB,YAAY;EAEjC;AAGD,OAAK,MAAM,YAAY,UACrB,KAAI,CAAC,cAAc,SAAS,SAAS,EACnC,OAAO,CAAC,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,IAAI,SAAS,CAAC;CAG/E;CAED,MAAM,eAAe,MAAM,QAAQ,WAAW;CAC9C,MAAM,eAAe,MAAM,QAAQ,WAAW;AAC9C,KAAI,aAAa,UAAU,aAAa,QAAQ;EAC9C,sBAAsB,CACpB,SAAS,SACV,EAAC;AACF;CACD;CAED,MAAM,cAAc,MAAM,QAAQ,UAAU;AAC5C,KAAI,CAAC,YAAY,UAAU,YAAY,UAAU,GAAG;EAClD,aAAa;AACb;CACD;CAED,MAAM,mBAAmB,YAAY;CACrC,kBAAkB,iBAAiB;CAEnC,sBAAsB,CACpB,UACD,EAAC;AACH,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY,EACV,0BAA0B,EACxB,MAAM,UACP,EACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/requireThrows.js
|
|
4
|
-
/**
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|