eslint-plugin-jsdoc 58.1.1 → 59.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -69
- package/dist/buildForbidRuleDefinition.cjs +0 -1
- package/dist/buildForbidRuleDefinition.cjs.map +1 -1
- package/dist/buildRejectOrPreferRuleDefinition.cjs +7 -2
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
- package/dist/cjs/rules/convertToJsdocComments.d.ts +7 -0
- package/dist/generateDocs.cjs +129 -3
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/generateRule.cjs +3 -1
- package/dist/generateRule.cjs.map +1 -1
- package/dist/generateRuleTypes.cjs +5 -5
- package/dist/generateRuleTypes.cjs.map +1 -1
- package/dist/index-cjs.cjs +30 -0
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +1 -1
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +4 -1
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +1 -1
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +19 -0
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +25 -1
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +62 -1
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +6 -0
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +71 -0
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +16 -1
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +17 -1
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +48 -0
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.d.ts +7 -0
- package/dist/rules/emptyTags.cjs +10 -1
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +15 -1
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +45 -0
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +14 -0
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +129 -0
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +30 -0
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +78 -6
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +11 -2
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +3 -1
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +19 -0
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +22 -2
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +29 -0
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +17 -1
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +17 -1
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +11 -1
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +28 -0
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +30 -1
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +27 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +26 -1
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +61 -0
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +20 -2
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +82 -3
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +213 -1
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +21 -0
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +16 -1
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +21 -1
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +1 -1
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +1 -1
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +54 -1
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +22 -1
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +15 -1
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +15 -1
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +17 -1
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +18 -1
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +50 -1
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +25 -7
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +200 -1
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +32 -2
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +5 -1
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/typeFormatting.cjs +47 -10
- package/dist/rules/typeFormatting.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +8 -1
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/rules.d.ts +2130 -32
- package/package.json +2 -2
- package/src/buildForbidRuleDefinition.js +0 -1
- package/src/buildRejectOrPreferRuleDefinition.js +12 -2
- package/src/index-cjs.js +36 -0
- package/src/index.js +36 -0
- package/src/rules/checkAccess.js +1 -1
- package/src/rules/checkAlignment.js +3 -0
- package/src/rules/checkExamples.js +1 -1
- package/src/rules/checkIndentation.js +19 -0
- package/src/rules/checkLineAlignment.js +24 -0
- package/src/rules/checkParamNames.js +62 -1
- package/src/rules/checkPropertyNames.js +6 -0
- package/src/rules/checkTagNames.js +71 -0
- package/src/rules/checkTypes.js +16 -1
- package/src/rules/checkValues.js +16 -0
- package/src/rules/convertToJsdocComments.js +48 -0
- package/src/rules/emptyTags.js +10 -1
- package/src/rules/implementsOnClasses.js +15 -1
- package/src/rules/informativeDocs.js +45 -0
- package/src/rules/linesBeforeBlock.js +14 -0
- package/src/rules/matchDescription.js +129 -0
- package/src/rules/matchName.js +30 -0
- package/src/rules/multilineBlocks.js +77 -5
- package/src/rules/noBadBlocks.js +11 -2
- package/src/rules/noBlankBlockDescriptions.js +1 -1
- package/src/rules/noBlankBlocks.js +2 -0
- package/src/rules/noDefaults.js +19 -0
- package/src/rules/noMissingSyntax.js +22 -2
- package/src/rules/noMultiAsterisks.js +29 -0
- package/src/rules/noRestrictedSyntax.js +17 -1
- package/src/rules/noTypes.js +17 -1
- package/src/rules/noUndefinedTypes.js +11 -1
- package/src/rules/requireAsteriskPrefix.js +28 -0
- package/src/rules/requireDescription.js +30 -1
- package/src/rules/requireDescriptionCompleteSentence.js +27 -0
- package/src/rules/requireExample.js +26 -1
- package/src/rules/requireFileOverview.js +61 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +19 -1
- package/src/rules/requireJsdoc.js +80 -1
- package/src/rules/requireParam.js +213 -1
- package/src/rules/requireParamDescription.js +21 -0
- package/src/rules/requireParamName.js +16 -1
- package/src/rules/requireParamType.js +21 -1
- package/src/rules/requirePropertyName.js +1 -1
- package/src/rules/requirePropertyType.js +1 -1
- package/src/rules/requireReturns.js +54 -1
- package/src/rules/requireReturnsCheck.js +22 -1
- package/src/rules/requireReturnsDescription.js +15 -1
- package/src/rules/requireReturnsType.js +15 -1
- package/src/rules/requireTemplate.js +17 -1
- package/src/rules/requireThrows.js +18 -1
- package/src/rules/requireYields.js +50 -1
- package/src/rules/requireYieldsCheck.js +25 -7
- package/src/rules/sortTags.js +200 -1
- package/src/rules/tagLines.js +30 -0
- package/src/rules/textEscaping.js +5 -1
- package/src/rules/typeFormatting.js +44 -7
- package/src/rules/validTypes.js +8 -1
- package/src/rules.d.ts +2130 -32
- package/typings/gitdown.d.ts +4 -0
|
@@ -80,7 +80,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
80
80
|
}, {
|
|
81
81
|
meta: {
|
|
82
82
|
docs: {
|
|
83
|
-
description: 'Requires a return statement in function body if a `@returns` tag is specified in
|
|
83
|
+
description: 'Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present).',
|
|
84
84
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header'
|
|
85
85
|
},
|
|
86
86
|
schema: [{
|
|
@@ -88,13 +88,34 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
88
88
|
properties: {
|
|
89
89
|
exemptAsync: {
|
|
90
90
|
default: true,
|
|
91
|
+
description: `By default, functions which return a \`Promise\` that are not
|
|
92
|
+
detected as resolving with a non-\`undefined\` value and \`async\` functions
|
|
93
|
+
(even ones that do not explicitly return a value, as these are returning a
|
|
94
|
+
\`Promise\` implicitly) will be exempted from reporting by this rule.
|
|
95
|
+
If you wish to insist that only \`Promise\`'s which resolve to
|
|
96
|
+
non-\`undefined\` values or \`async\` functions with explicit \`return\`'s will
|
|
97
|
+
be exempted from reporting (i.e., that \`async\` functions can be reported
|
|
98
|
+
if they lack an explicit (non-\`undefined\`) \`return\` when a \`@returns\` is
|
|
99
|
+
present), you can set \`exemptAsync\` to \`false\` on the options object.`,
|
|
91
100
|
type: 'boolean'
|
|
92
101
|
},
|
|
93
102
|
exemptGenerators: {
|
|
103
|
+
description: `Because a generator might be labeled as having a
|
|
104
|
+
\`IterableIterator\` \`@returns\` value (along with an iterator type
|
|
105
|
+
corresponding to the type of any \`yield\` statements), projects might wish to
|
|
106
|
+
leverage \`@returns\` in generators even without a \`return\` statement. This
|
|
107
|
+
option is therefore \`true\` by default in \`typescript\` mode (in "jsdoc" mode,
|
|
108
|
+
one might be more likely to take advantage of \`@yields\`). Set it to \`false\`
|
|
109
|
+
if you wish for a missing \`return\` to be flagged regardless.`,
|
|
94
110
|
type: 'boolean'
|
|
95
111
|
},
|
|
96
112
|
reportMissingReturnForUndefinedTypes: {
|
|
97
113
|
default: false,
|
|
114
|
+
description: `If \`true\` and no return or
|
|
115
|
+
resolve value is found, this setting will even insist that reporting occur
|
|
116
|
+
with \`void\` or \`undefined\` (including as an indicated \`Promise\` type).
|
|
117
|
+
Unlike \`require-returns\`, with this option in the rule, one can
|
|
118
|
+
*discourage* the labeling of \`undefined\` types. Defaults to \`false\`.`,
|
|
98
119
|
type: 'boolean'
|
|
99
120
|
}
|
|
100
121
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","_default","exports","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"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\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
|
|
1
|
+
{"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","_default","exports","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"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\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(and reports if multiple `@returns` tags are present).',\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 description: `By default, functions which return a \\`Promise\\` that are not\ndetected as resolving with a non-\\`undefined\\` value and \\`async\\` functions\n(even ones that do not explicitly return a value, as these are returning a\n\\`Promise\\` implicitly) will be exempted from reporting by this rule.\nIf you wish to insist that only \\`Promise\\`'s which resolve to\nnon-\\`undefined\\` values or \\`async\\` functions with explicit \\`return\\`'s will\nbe exempted from reporting (i.e., that \\`async\\` functions can be reported\nif they lack an explicit (non-\\`undefined\\`) \\`return\\` when a \\`@returns\\` is\npresent), you can set \\`exemptAsync\\` to \\`false\\` on the options object.`,\n type: 'boolean',\n },\n exemptGenerators: {\n description: `Because a generator might be labeled as having a\n\\`IterableIterator\\` \\`@returns\\` value (along with an iterator type\ncorresponding to the type of any \\`yield\\` statements), projects might wish to\nleverage \\`@returns\\` in generators even without a \\`return\\` statement. This\noption is therefore \\`true\\` by default in \\`typescript\\` mode (in \"jsdoc\" mode,\none might be more likely to take advantage of \\`@yields\\`). Set it to \\`false\\`\nif you wish for a missing \\`return\\` to be flagged regardless.`,\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n description: `If \\`true\\` and no return or\nresolve value is found, this setting will even insist that reporting occur\nwith \\`void\\` or \\`undefined\\` (including as an indicated \\`Promise\\` type).\nUnlike \\`require-returns\\`, with this option in the rule, one can\n*discourage* the labeling of \\`undefined\\` types. Defaults to \\`false\\`.`,\n type: 'boolean',\n },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C,UAAUM,OAAO,uEAAuE,CAAC;EAClG;AACF,CAAC,EAAE;EACDc,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,sJAAsJ;MACnKC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVzB,WAAW,EAAE;UACXhB,OAAO,EAAE,IAAI;UACbqC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;UAC9DV,IAAI,EAAE;QACR,CAAC;QACDV,gBAAgB,EAAE;UAChBoB,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,+DAA+D;UACnDV,IAAI,EAAE;QACR,CAAC;QACDT,oCAAoC,EAAE;UACpClB,OAAO,EAAE,KAAK;UACdqC,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7DV,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAe,MAAA,CAAA/B,OAAA,GAAAA,OAAA,CAAAX,OAAA","ignoreList":[]}
|
|
@@ -23,13 +23,27 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
23
23
|
contextDefaults: true,
|
|
24
24
|
meta: {
|
|
25
25
|
docs: {
|
|
26
|
-
description: 'Requires that the `@returns` tag has a `description` value.',
|
|
26
|
+
description: 'Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns).',
|
|
27
27
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header'
|
|
28
28
|
},
|
|
29
29
|
schema: [{
|
|
30
30
|
additionalProperties: false,
|
|
31
31
|
properties: {
|
|
32
32
|
contexts: {
|
|
33
|
+
description: `Set this to an array of strings representing the AST context (or an object with
|
|
34
|
+
optional \`context\` and \`comment\` properties) where you wish the rule to be applied.
|
|
35
|
+
|
|
36
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
37
|
+
|
|
38
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
39
|
+
\`FunctionExpression\`). Set to \`"any"\` if you want
|
|
40
|
+
the rule to apply to any JSDoc block throughout your files (as is necessary
|
|
41
|
+
for finding function blocks not attached to a function declaration or
|
|
42
|
+
expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
|
|
43
|
+
\`@method\`) (including those associated with an \`@interface\`).
|
|
44
|
+
|
|
45
|
+
See the ["AST and Selectors"](../#advanced-ast-and-selectors)
|
|
46
|
+
section of our Advanced docs for more on the expected format.`,
|
|
33
47
|
items: {
|
|
34
48
|
anyOf: [{
|
|
35
49
|
type: 'string'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","trim","includes","description","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"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":";;;;;;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,SAAS,EAAE,CAACC,QAAQ,EAAEC,aAAa,KAAK;IAChE,MAAMC,IAAI,GAAGF,QAAQ,CAACE,IAAI,IAAIF,QAAQ,CAACE,IAAI,CAACC,IAAI,CAAC,CAAC;IAElD,IAAI,CACF,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,CAC3D,CAACC,QAAQ,CAACF,IAAI,CAAC,EAAE;MAChB;IACF;IAEA,IAAI,CAACF,QAAQ,CAACK,WAAW,CAACF,IAAI,CAAC,CAAC,EAAE;MAChCN,MAAM,CAAC,kBAAkBI,aAAa,eAAe,EAAE,IAAI,EAAED,QAAQ,CAAC;IACxE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDM,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJH,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"requireReturnsDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","trim","includes","description","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"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 (not including `void`/`undefined` type returns).',\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 description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the 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\\`).\n\nSee the [\"AST and Selectors\"](../#advanced-ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\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":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAA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AC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAgB,MAAA,CAAAvB,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -19,13 +19,27 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
19
19
|
contextDefaults: true,
|
|
20
20
|
meta: {
|
|
21
21
|
docs: {
|
|
22
|
-
description: 'Requires that `@returns` tag has
|
|
22
|
+
description: 'Requires that `@returns` tag has type value (in curly brackets).',
|
|
23
23
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header'
|
|
24
24
|
},
|
|
25
25
|
schema: [{
|
|
26
26
|
additionalProperties: false,
|
|
27
27
|
properties: {
|
|
28
28
|
contexts: {
|
|
29
|
+
description: `Set this to an array of strings representing the AST context (or an object with
|
|
30
|
+
optional \`context\` and \`comment\` properties) where you wish the rule to be applied.
|
|
31
|
+
|
|
32
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
33
|
+
|
|
34
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
35
|
+
\`FunctionExpression\`). Set to \`"any"\` if you want
|
|
36
|
+
the rule to apply to any JSDoc block throughout your files (as is necessary
|
|
37
|
+
for finding function blocks not attached to a function declaration or
|
|
38
|
+
expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
|
|
39
|
+
\`@method\`) (including those associated with an \`@interface\`).
|
|
40
|
+
|
|
41
|
+
See the ["AST and Selectors"](../#advanced-ast-and-selectors)
|
|
42
|
+
section of our Advanced docs for more on the expected format.`,
|
|
29
43
|
items: {
|
|
30
44
|
anyOf: [{
|
|
31
45
|
type: 'string'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"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
|
|
1
|
+
{"version":3,"file":"requireReturnsType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"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 (in curly brackets).',\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 description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the 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\\`).\n\nSee the [\"AST and Selectors\"](../#advanced-ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\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":";;;;;;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,SAAS,EAAE,CAACC,QAAQ,EAAEC,aAAa,KAAK;IAChE,IAAI,CAACD,QAAQ,CAACE,IAAI,EAAE;MAClBL,MAAM,CAAC,kBAAkBI,aAAa,QAAQ,EAAE,IAAI,EAAED,QAAQ,CAAC;IACjE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDG,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kEAAkE;MAC/EC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;UAClDM,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEX,IAAI,EAAE;YACR,CAAC,EACD;cACEO,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPZ,IAAI,EAAE;gBACR,CAAC;gBACDa,OAAO,EAAE;kBACPb,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAc,MAAA,CAAArB,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -166,19 +166,35 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
166
166
|
iterateAllJsdocs: true,
|
|
167
167
|
meta: {
|
|
168
168
|
docs: {
|
|
169
|
-
description: 'Requires template tags
|
|
169
|
+
description: 'Requires `@template` tags be present when type parameters are used.',
|
|
170
170
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header'
|
|
171
171
|
},
|
|
172
172
|
schema: [{
|
|
173
173
|
additionalProperties: false,
|
|
174
174
|
properties: {
|
|
175
175
|
exemptedBy: {
|
|
176
|
+
description: `Array of tags (e.g., \`['type']\`) whose presence on the document
|
|
177
|
+
block avoids the need for a \`@template\`. Defaults to an array with
|
|
178
|
+
\`inheritdoc\`. If you set this array, it will overwrite the default,
|
|
179
|
+
so be sure to add back \`inheritdoc\` if you wish its presence to cause
|
|
180
|
+
exemption of the rule.`,
|
|
176
181
|
items: {
|
|
177
182
|
type: 'string'
|
|
178
183
|
},
|
|
179
184
|
type: 'array'
|
|
180
185
|
},
|
|
181
186
|
requireSeparateTemplates: {
|
|
187
|
+
description: `Requires that each template have its own separate line, i.e., preventing
|
|
188
|
+
templates of this format:
|
|
189
|
+
|
|
190
|
+
\`\`\`js
|
|
191
|
+
/**
|
|
192
|
+
* @template T, U, V
|
|
193
|
+
*/
|
|
194
|
+
\`\`\`
|
|
195
|
+
|
|
196
|
+
Defaults to \`false\`.
|
|
197
|
+
`,
|
|
182
198
|
type: 'boolean'
|
|
183
199
|
}
|
|
184
200
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireTemplate.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","e","__esModule","default","_default","exports","iterateJsdoc","context","node","report","settings","utils","avoidDocs","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","tag","parseClosureTemplateTag","names","length","checkTypeParams","aliasDeclaration","params","typeParameters","name","add","usedName","includes","handleTypes","nde","type","declaration","usedNameToTag","Map","checkForUsedTypes","potentialTag","parsedType","tryParseType","parseType","traverse","value","test","has","set","checkTagsAndTemplates","tagNames","tagName","preferredTagName","getPreferredTagName","matchingTags","matchingTag","get","callbackTags","functionTags","typedefTags","potentialTypedef","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","exemptedBy","items","module"],"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 if (utils.avoidDocs()) {\n return;\n }\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 names = utils.parseClosureTemplateTag(tag);\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.TSDeclareFunction|\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 'TSDeclareFunction':\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 'TSDeclareFunction':\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 exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n requireSeparateTemplates: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAI8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEf,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,IAAI;EACJC,MAAM;EACNC,QAAQ;EACRC;AAC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W,CAACnC,MAAM,IAAImC,WAAW,CAACnC,MAAM,IAAI,CAAC,EAAE;IAClDS,WAAW,CAAC,CAAC;IACb;EACF;EAEA,MAAM2B,gBAAgB,GAAGD,WAAW,CAAC,CAAC,CAAC;EACvCpB,iBAAiB,CAACqB,gBAAgB,CAAC;EAEnCX,qBAAqB,CAAC,CACpB,UAAU,CACX,CAAC;AACJ,CAAC,EAAE;EACDY,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,wDAAwD;MACrEC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,UAAU,EAAE;UACVC,KAAK,EAAE;YACLnC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,wBAAwB,EAAE;UACxBuB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoC,MAAA,CAAAnE,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireTemplate.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","e","__esModule","default","_default","exports","iterateJsdoc","context","node","report","settings","utils","avoidDocs","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","tag","parseClosureTemplateTag","names","length","checkTypeParams","aliasDeclaration","params","typeParameters","name","add","usedName","includes","handleTypes","nde","type","declaration","usedNameToTag","Map","checkForUsedTypes","potentialTag","parsedType","tryParseType","parseType","traverse","value","test","has","set","checkTagsAndTemplates","tagNames","tagName","preferredTagName","getPreferredTagName","matchingTags","matchingTag","get","callbackTags","functionTags","typedefTags","potentialTypedef","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","exemptedBy","items","module"],"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 if (utils.avoidDocs()) {\n return;\n }\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 names = utils.parseClosureTemplateTag(tag);\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.TSDeclareFunction|\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 'TSDeclareFunction':\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 'TSDeclareFunction':\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 be present when type parameters are used.',\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 exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the document\nblock avoids the need for a \\`@template\\`. Defaults to an array with\n\\`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 requireSeparateTemplates: {\n description: `Requires that each template have its own separate line, i.e., preventing\ntemplates of this format:\n\n\\`\\`\\`js\n/**\n * @template T, U, V\n */\n\\`\\`\\`\n\nDefaults to \\`false\\`.\n`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAI8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEf,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,IAAI;EACJC,MAAM;EACNC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,IAAIA,KAAK,CAACC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;EAEA,MAAM;IACJC,wBAAwB,GAAG;EAC7B,CAAC,GAAGN,OAAO,CAACO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC;EACF,CAAC,GAAGL,QAAQ;EAEZ,MAAMM,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B,MAAMC,YAAY,GAAGP,KAAK,CAACQ,OAAO,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W,EAAE,qEAAqE;MAClFC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,UAAU,EAAE;UACVL,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXM,KAAK,EAAE;YACLnC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,wBAAwB,EAAE;UACxBoD,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACW7B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoC,MAAA,CAAAnE,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -60,13 +60,25 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
60
60
|
contextDefaults: true,
|
|
61
61
|
meta: {
|
|
62
62
|
docs: {
|
|
63
|
-
description: 'Requires that throw statements are documented.',
|
|
63
|
+
description: 'Requires that throw statements are documented with `@throws` tags.',
|
|
64
64
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header'
|
|
65
65
|
},
|
|
66
66
|
schema: [{
|
|
67
67
|
additionalProperties: false,
|
|
68
68
|
properties: {
|
|
69
69
|
contexts: {
|
|
70
|
+
description: `Set this to an array of strings representing the AST context
|
|
71
|
+
(or objects with optional \`context\` and \`comment\` properties) where you wish
|
|
72
|
+
the rule to be applied.
|
|
73
|
+
|
|
74
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
75
|
+
|
|
76
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
77
|
+
\`FunctionExpression\`). Set to \`"any"\` if you want
|
|
78
|
+
the rule to apply to any JSDoc block throughout your files (as is necessary
|
|
79
|
+
for finding function blocks not attached to a function declaration or
|
|
80
|
+
expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
|
|
81
|
+
\`@method\`) (including those associated with an \`@interface\`).`,
|
|
70
82
|
items: {
|
|
71
83
|
anyOf: [{
|
|
72
84
|
type: 'string'
|
|
@@ -86,6 +98,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
86
98
|
type: 'array'
|
|
87
99
|
},
|
|
88
100
|
exemptedBy: {
|
|
101
|
+
description: `Array of tags (e.g., \`['type']\`) whose presence on the
|
|
102
|
+
document block avoids the need for a \`@throws\`. Defaults to an array
|
|
103
|
+
with \`inheritdoc\`. If you set this array, it will overwrite the default,
|
|
104
|
+
so be sure to add back \`inheritdoc\` if you wish its presence to cause
|
|
105
|
+
exemption of the rule.`,
|
|
89
106
|
items: {
|
|
90
107
|
type: 'string'
|
|
91
108
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireThrows.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","type","trim","hasThrowValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"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":";;;;;;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,MAAMG,OAAO,GAAIC,KAAK,IAAK;EACzB,OAAOA,KAAK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AAW,EAAE,
|
|
1
|
+
{"version":3,"file":"requireThrows.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","type","trim","hasThrowValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"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 with `@throws` tags.',\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 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\\`).`,\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 \\`@throws\\`. 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 },\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,MAAMG,OAAO,GAAIC,KAAK,IAAK;EACzB,OAAOA,KAAK,CAACC,OAAO,CAAC;EACnB;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,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE;UACtDM,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEb,IAAI,EAAE;YACR,CAAC,EACD;cACES,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPd,IAAI,EAAE;gBACR,CAAC;gBACDe,OAAO,EAAE;kBACPf,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDgB,UAAU,EAAE;UACVV,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXM,KAAK,EAAE;YACLZ,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiB,MAAA,CAAA7B,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
|
|
@@ -114,13 +114,30 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
114
114
|
contextDefaults: true,
|
|
115
115
|
meta: {
|
|
116
116
|
docs: {
|
|
117
|
-
description: 'Requires yields are documented.',
|
|
117
|
+
description: 'Requires yields are documented with `@yields` tags.',
|
|
118
118
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header'
|
|
119
119
|
},
|
|
120
120
|
schema: [{
|
|
121
121
|
additionalProperties: false,
|
|
122
122
|
properties: {
|
|
123
123
|
contexts: {
|
|
124
|
+
description: `Set this to an array of strings representing the AST context
|
|
125
|
+
(or objects with optional \`context\` and \`comment\` properties) where you wish
|
|
126
|
+
the rule to be applied.
|
|
127
|
+
|
|
128
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
129
|
+
|
|
130
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
131
|
+
\`FunctionExpression\`). Set to \`"any"\` if you want
|
|
132
|
+
the rule to apply to any JSDoc block throughout your files (as is necessary
|
|
133
|
+
for finding function blocks not attached to a function declaration or
|
|
134
|
+
expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
|
|
135
|
+
\`@method\`) (including those associated with an \`@interface\`). This
|
|
136
|
+
rule will only apply on non-default contexts when there is such a tag
|
|
137
|
+
present and the \`forceRequireYields\` option is set or if the
|
|
138
|
+
\`withGeneratorTag\` option is set with a present \`@generator\` tag
|
|
139
|
+
(since we are not checking against the actual \`yield\` values in these
|
|
140
|
+
cases).`,
|
|
124
141
|
items: {
|
|
125
142
|
anyOf: [{
|
|
126
143
|
type: 'string'
|
|
@@ -140,6 +157,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
140
157
|
type: 'array'
|
|
141
158
|
},
|
|
142
159
|
exemptedBy: {
|
|
160
|
+
description: `Array of tags (e.g., \`['type']\`) whose presence on the
|
|
161
|
+
document block avoids the need for a \`@yields\`. Defaults to an array
|
|
162
|
+
with \`inheritdoc\`. If you set this array, it will overwrite the default,
|
|
163
|
+
so be sure to add back \`inheritdoc\` if you wish its presence to cause
|
|
164
|
+
exemption of the rule.`,
|
|
143
165
|
items: {
|
|
144
166
|
type: 'string'
|
|
145
167
|
},
|
|
@@ -147,22 +169,49 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
147
169
|
},
|
|
148
170
|
forceRequireNext: {
|
|
149
171
|
default: false,
|
|
172
|
+
description: `Set to \`true\` to always insist on
|
|
173
|
+
\`@next\` documentation even if there are no \`yield\` statements in the
|
|
174
|
+
function or none return values. May be desired to flag that a project is
|
|
175
|
+
aware of the expected yield return being \`undefined\`. Defaults to \`false\`.`,
|
|
150
176
|
type: 'boolean'
|
|
151
177
|
},
|
|
152
178
|
forceRequireYields: {
|
|
153
179
|
default: false,
|
|
180
|
+
description: `Set to \`true\` to always insist on
|
|
181
|
+
\`@yields\` documentation for generators even if there are only
|
|
182
|
+
expressionless \`yield\` statements in the function. May be desired to flag
|
|
183
|
+
that a project is aware of an \`undefined\`/\`void\` yield. Defaults to
|
|
184
|
+
\`false\`.`,
|
|
154
185
|
type: 'boolean'
|
|
155
186
|
},
|
|
156
187
|
next: {
|
|
157
188
|
default: false,
|
|
189
|
+
description: `If \`true\`, this option will insist that any use of a \`yield\` return
|
|
190
|
+
value (e.g., \`const rv = yield;\` or \`const rv = yield value;\`) has a
|
|
191
|
+
(non-standard) \`@next\` tag (in addition to any \`@yields\` tag) so as to be
|
|
192
|
+
able to document the type expected to be supplied into the iterator
|
|
193
|
+
(the \`Generator\` iterator that is returned by the call to the generator
|
|
194
|
+
function) to the iterator (e.g., \`it.next(value)\`). The tag will not be
|
|
195
|
+
expected if the generator function body merely has plain \`yield;\` or
|
|
196
|
+
\`yield value;\` statements without returning the values. Defaults to
|
|
197
|
+
\`false\`.`,
|
|
158
198
|
type: 'boolean'
|
|
159
199
|
},
|
|
160
200
|
nextWithGeneratorTag: {
|
|
161
201
|
default: false,
|
|
202
|
+
description: `If a \`@generator\` tag is present on a block, require
|
|
203
|
+
(non-standard ) \`@next\` (see \`next\` option). This will require using \`void\`
|
|
204
|
+
or \`undefined\` in cases where generators do not use the \`next()\`-supplied
|
|
205
|
+
incoming \`yield\`-returned value. Defaults to \`false\`. See \`contexts\` to
|
|
206
|
+
\`any\` if you want to catch \`@generator\` with \`@callback\` or such not
|
|
207
|
+
attached to a function.`,
|
|
162
208
|
type: 'boolean'
|
|
163
209
|
},
|
|
164
210
|
withGeneratorTag: {
|
|
165
211
|
default: true,
|
|
212
|
+
description: `If a \`@generator\` tag is present on a block, require
|
|
213
|
+
\`@yields\`/\`@yield\`. Defaults to \`true\`. See \`contexts\` to \`any\` if you want
|
|
214
|
+
to catch \`@generator\` with \`@callback\` or such not attached to a function.`,
|
|
166
215
|
type: 'boolean'
|
|
167
216
|
}
|
|
168
217
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireYields.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","checkTagName","report","tagName","preferredTagName","getPreferredTagName","tags","getTags","length","tag","missingTag","_default","exports","iterateJsdoc","context","forceRequireNext","forceRequireYields","next","nextWithGeneratorTag","withGeneratorTag","options","iteratingFunction","isIteratingFunction","preferredYieldTagName","missingYieldTag","shouldReportYields","hasTag","isGenerator","hasYieldValue","preferredNextTagName","missingNextTag","shouldReportNext","hasYieldReturnValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","exemptedBy","module"],"sources":["../../src/rules/requireYields.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a yield value, in case the documentation is inherited\n * or the method has a constructor or abstract tag.\n *\n * In either of these cases the yield value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a yield value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a yield value\n // so we can bail out here, too.\n 'class',\n 'constructor',\n\n // Yield (and any `next`) type is specified accompanying the targeted\n // @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @param {string} tagName\n * @returns {[preferredTagName?: string, missingTag?: boolean]}\n */\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n }\n\n // In case the code yields something, we expect a yields value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingTag = typeof tag === 'undefined' || tag === null;\n\n return [\n preferredTagName, missingTag,\n ];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n utils,\n}) => {\n const {\n forceRequireNext = false,\n forceRequireYields = false,\n next = false,\n nextWithGeneratorTag = false,\n withGeneratorTag = true,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @yield comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n preferredYieldTagName,\n missingYieldTag,\n ] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (!missingYieldTag) {\n return false;\n }\n\n if (\n withGeneratorTag && utils.hasTag('generator') ||\n forceRequireYields && iteratingFunction && utils.isGenerator()\n ) {\n return true;\n }\n\n return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();\n };\n\n if (shouldReportYields()) {\n report(`Missing JSDoc @${preferredYieldTagName} declaration.`);\n }\n }\n\n if (next || nextWithGeneratorTag || forceRequireNext) {\n const [\n preferredNextTagName,\n missingNextTag,\n ] = checkTagName(\n utils, report, 'next',\n );\n if (!preferredNextTagName) {\n return;\n }\n\n const shouldReportNext = () => {\n if (!missingNextTag) {\n return false;\n }\n\n if (\n nextWithGeneratorTag && utils.hasTag('generator')) {\n return true;\n }\n\n if (\n !next && !forceRequireNext ||\n !iteratingFunction ||\n !utils.isGenerator()\n ) {\n return false;\n }\n\n return forceRequireNext || utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`Missing JSDoc @${preferredNextTagName} declaration.`);\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires yields are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireNext: {\n default: false,\n type: 'boolean',\n },\n forceRequireYields: {\n default: false,\n type: 'boolean',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n nextWithGeneratorTag: {\n default: false,\n type: 'boolean',\n },\n withGeneratorTag: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;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,OAAO,GAAIC,KAAK,IAAK;EACzB,OAAOA,KAAK,CAACC,OAAO,CAAC;EACnB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa;EAEb;EACA;EACA,MAAM;EAEN;EACA,WAAW,CACZ,CAAC,IACAD,KAAK,CAACE,SAAS,CAAC,CAAC;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAGA,CAACH,KAAK,EAAEI,MAAM,EAAEC,OAAO,KAAK;EAC/C,MAAMC,gBAAgB,GAAG,qBAAuBN,KAAK,CAACO,mBAAmB,CAAC;IACxEF;EACF,CAAC,CAAE;EACH,IAAI,C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cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEL,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVK,OAAO,EAAE;kBACPD,IAAI,EAAE;gBACR,CAAC;gBACD9B,OAAO,EAAE;kBACP8B,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDE,UAAU,EAAE;UACVJ,KAAK,EAAE;YACLE,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD7B,gBAAgB,EAAE;UAChBnB,OAAO,EAAE,KAAK;UACdgD,IAAI,EAAE;QACR,CAAC;QACD5B,kBAAkB,EAAE;UAClBpB,OAAO,EAAE,KAAK;UACdgD,IAAI,EAAE;QACR,CAAC;QACD3B,IAAI,EAAE;UACJrB,OAAO,EAAE,KAAK;UACdgD,IAAI,EAAE;QACR,CAAC;QACD1B,oBAAoB,EAAE;UACpBtB,OAAO,EAAE,KAAK;UACdgD,IAAI,EAAE;QACR,CAAC;QACDzB,gBAAgB,EAAE;UAChBvB,OAAO,EAAE,IAAI;UACbgD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAG,MAAA,CAAAnC,OAAA,GAAAA,OAAA,CAAAhB,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireYields.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","checkTagName","report","tagName","preferredTagName","getPreferredTagName","tags","getTags","length","tag","missingTag","_default","exports","iterateJsdoc","context","forceRequireNext","forceRequireYields","next","nextWithGeneratorTag","withGeneratorTag","options","iteratingFunction","isIteratingFunction","preferredYieldTagName","missingYieldTag","shouldReportYields","hasTag","isGenerator","hasYieldValue","preferredNextTagName","missingNextTag","shouldReportNext","hasYieldReturnValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","exemptedBy","module"],"sources":["../../src/rules/requireYields.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a yield value, in case the documentation is inherited\n * or the method has a constructor or abstract tag.\n *\n * In either of these cases the yield value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a yield value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a yield value\n // so we can bail out here, too.\n 'class',\n 'constructor',\n\n // Yield (and any `next`) type is specified accompanying the targeted\n // @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @param {string} tagName\n * @returns {[preferredTagName?: string, missingTag?: boolean]}\n */\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n }\n\n // In case the code yields something, we expect a yields value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingTag = typeof tag === 'undefined' || tag === null;\n\n return [\n preferredTagName, missingTag,\n ];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n utils,\n}) => {\n const {\n forceRequireNext = false,\n forceRequireYields = false,\n next = false,\n nextWithGeneratorTag = false,\n withGeneratorTag = true,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @yield comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n preferredYieldTagName,\n missingYieldTag,\n ] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (!missingYieldTag) {\n return false;\n }\n\n if (\n withGeneratorTag && utils.hasTag('generator') ||\n forceRequireYields && iteratingFunction && utils.isGenerator()\n ) {\n return true;\n }\n\n return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();\n };\n\n if (shouldReportYields()) {\n report(`Missing JSDoc @${preferredYieldTagName} declaration.`);\n }\n }\n\n if (next || nextWithGeneratorTag || forceRequireNext) {\n const [\n preferredNextTagName,\n missingNextTag,\n ] = checkTagName(\n utils, report, 'next',\n );\n if (!preferredNextTagName) {\n return;\n }\n\n const shouldReportNext = () => {\n if (!missingNextTag) {\n return false;\n }\n\n if (\n nextWithGeneratorTag && utils.hasTag('generator')) {\n return true;\n }\n\n if (\n !next && !forceRequireNext ||\n !iteratingFunction ||\n !utils.isGenerator()\n ) {\n return false;\n }\n\n return forceRequireNext || utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`Missing JSDoc @${preferredNextTagName} declaration.`);\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires yields are documented with `@yields` tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n 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 \\`forceRequireYields\\` option is set or if the\n\\`withGeneratorTag\\` option is set with a present \\`@generator\\` tag\n(since we are not checking against the actual \\`yield\\` 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 },\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 \\`@yields\\`. 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 forceRequireNext: {\n default: false,\n description: `Set to \\`true\\` to always insist on\n\\`@next\\` documentation even if there are no \\`yield\\` statements in the\nfunction or none return values. May be desired to flag that a project is\naware of the expected yield return being \\`undefined\\`. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n forceRequireYields: {\n default: false,\n description: `Set to \\`true\\` to always insist on\n\\`@yields\\` documentation for generators even if there are only\nexpressionless \\`yield\\` statements in the function. May be desired to flag\nthat a project is aware of an \\`undefined\\`/\\`void\\` yield. Defaults to\n\\`false\\`.`,\n type: 'boolean',\n },\n next: {\n default: false,\n description: `If \\`true\\`, this option will insist that any use of a \\`yield\\` return\nvalue (e.g., \\`const rv = yield;\\` or \\`const rv = yield value;\\`) has a\n(non-standard) \\`@next\\` tag (in addition to any \\`@yields\\` tag) so as to be\nable to document the type expected to be supplied into the iterator\n(the \\`Generator\\` iterator that is returned by the call to the generator\nfunction) to the iterator (e.g., \\`it.next(value)\\`). The tag will not be\nexpected if the generator function body merely has plain \\`yield;\\` or\n\\`yield value;\\` statements without returning the values. Defaults to\n\\`false\\`.`,\n type: 'boolean',\n },\n nextWithGeneratorTag: {\n default: false,\n description: `If a \\`@generator\\` tag is present on a block, require\n(non-standard ) \\`@next\\` (see \\`next\\` option). This will require using \\`void\\`\nor \\`undefined\\` in cases where generators do not use the \\`next()\\`-supplied\nincoming \\`yield\\`-returned value. Defaults to \\`false\\`. See \\`contexts\\` to\n\\`any\\` if you want to catch \\`@generator\\` with \\`@callback\\` or such not\nattached to a function.`,\n type: 'boolean',\n },\n withGeneratorTag: {\n default: true,\n description: `If a \\`@generator\\` tag is present on a block, require\n\\`@yields\\`/\\`@yield\\`. Defaults to \\`true\\`. See \\`contexts\\` to \\`any\\` if you want\nto catch \\`@generator\\` with \\`@callback\\` or such not attached to a function.`,\n type: 'boolean',\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,OAAO,GAAIC,KAAK,IAAK;EACzB,OAAOA,KAAK,CAACC,OAAO,CAAC;EACnB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa;EAEb;EACA;EACA,MAAM;EAEN;EACA,WAAW,CACZ,CAAC,IACAD,KAAK,CAACE,SAAS,CAAC,CAAC;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAGA,CAACH,KAAK,EAAEI,MAAM,EAAEC,OAAO,KAAK;EAC/C,MAAMC,gBAAgB,GAAG,qBAAuBN,KAAK,CAACO,mBAAmB,CAAC;IACxEF;EACF,CAAC,CAAE;EACH,IAAI,CAACC,gBAAgB,EAAE;IACrB,OAAO,EAAE;EACX;EAEA,MAAME,IAAI,GAAGR,KAAK,CAACS,OAAO,CAACH,gBAAgB,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L;cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEL,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVK,OAAO,EAAE;kBACPD,IAAI,EAAE;gBACR,CAAC;gBACD9B,OAAO,EAAE;kBACP8B,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDE,UAAU,EAAE;UACVV,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXM,KAAK,EAAE;YACLE,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD7B,gBAAgB,EAAE;UAChBnB,OAAO,EAAE,KAAK;UACdwC,WAAW,EAAE;AACzB;AACA;AACA,+EAA+E;UACnEQ,IAAI,EAAE;QACR,CAAC;QACD5B,kBAAkB,EAAE;UAClBpB,OAAO,EAAE,KAAK;UACdwC,WAAW,EAAE;AACzB;AACA;AACA;AACA,WAAW;UACCQ,IAAI,EAAE;QACR,CAAC;QACD3B,IAAI,EAAE;UACJrB,OAAO,EAAE,KAAK;UACdwC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;UACCQ,IAAI,EAAE;QACR,CAAC;QACD1B,oBAAoB,EAAE;UACpBtB,OAAO,EAAE,KAAK;UACdwC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,wBAAwB;UACZQ,IAAI,EAAE;QACR,CAAC;QACDzB,gBAAgB,EAAE;UAChBvB,OAAO,EAAE,IAAI;UACbwC,WAAW,EAAE;AACzB;AACA,+EAA+E;UACnEQ,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAG,MAAA,CAAAnC,OAAA,GAAAA,OAAA,CAAAhB,OAAA","ignoreList":[]}
|
|
@@ -112,7 +112,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
112
112
|
}, {
|
|
113
113
|
meta: {
|
|
114
114
|
docs: {
|
|
115
|
-
description: '
|
|
115
|
+
description: 'Ensures that if a `@yields` is present that a `yield` (or `yield` with a value) is present in the function body (or that if a `@next` is present that there is a yield with a return value present).',
|
|
116
116
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields-check.md#repos-sticky-header'
|
|
117
117
|
},
|
|
118
118
|
schema: [{
|
|
@@ -120,9 +120,22 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
120
120
|
properties: {
|
|
121
121
|
checkGeneratorsOnly: {
|
|
122
122
|
default: false,
|
|
123
|
+
description: `Avoids checking the function body and merely insists
|
|
124
|
+
that all generators have \`@yields\`. This can be an optimization with the
|
|
125
|
+
ESLint \`require-yield\` rule, as that rule already ensures a \`yield\` is
|
|
126
|
+
present in generators, albeit assuming the generator is not empty).
|
|
127
|
+
Defaults to \`false\`.`,
|
|
123
128
|
type: 'boolean'
|
|
124
129
|
},
|
|
125
130
|
contexts: {
|
|
131
|
+
description: `Set this to an array of strings representing the AST context
|
|
132
|
+
(or objects with optional \`context\` and \`comment\` properties) where you wish
|
|
133
|
+
the rule to be applied.
|
|
134
|
+
|
|
135
|
+
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
136
|
+
|
|
137
|
+
Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
|
|
138
|
+
\`FunctionExpression\`).`,
|
|
126
139
|
items: {
|
|
127
140
|
anyOf: [{
|
|
128
141
|
type: 'string'
|
|
@@ -141,14 +154,19 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
141
154
|
},
|
|
142
155
|
type: 'array'
|
|
143
156
|
},
|
|
144
|
-
exemptedBy: {
|
|
145
|
-
items: {
|
|
146
|
-
type: 'string'
|
|
147
|
-
},
|
|
148
|
-
type: 'array'
|
|
149
|
-
},
|
|
150
157
|
next: {
|
|
151
158
|
default: false,
|
|
159
|
+
description: `If \`true\`, this option will insist that any use of a (non-standard)
|
|
160
|
+
\`@next\` tag (in addition to any \`@yields\` tag) will be matched by a \`yield\`
|
|
161
|
+
which uses a return value in the body of the generator (e.g.,
|
|
162
|
+
\`const rv = yield;\` or \`const rv = yield value;\`). This (non-standard)
|
|
163
|
+
tag is intended to be used to indicate a type and/or description of
|
|
164
|
+
the value expected to be supplied by the user when supplied to the iterator
|
|
165
|
+
by its \`next\` method, as with \`it.next(value)\` (with the iterator being
|
|
166
|
+
the \`Generator\` iterator that is returned by the call to the generator
|
|
167
|
+
function). This option will report an error if the generator function body
|
|
168
|
+
merely has plain \`yield;\` or \`yield value;\` statements without returning
|
|
169
|
+
the values. Defaults to \`false\`.`,
|
|
152
170
|
type: 'boolean'
|
|
153
171
|
}
|
|
154
172
|
},
|