{"version":3,"sources":["../../src/rules/requireYieldsCheck.js"],"names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","checkTagName","report","tagName","preferredTagName","getPreferredTagName","tags","getTags","length","context","next","checkGeneratorsOnly","options","preferredYieldTagName","yieldTag","shouldReportYields","isGenerator","hasDefinedTypeTag","hasYieldValue","preferredNextTagName","nextTag","shouldReportNext","hasYieldReturnValue","meta","docs","description","url","schema","additionalProperties","properties","default","type","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,OAAO,GAAG,CAACC,KAAD,EAAQC,QAAR,KAAqB;AACnC,QAAMC,WAAW,GAAG,CAClB;AACA;AACA;AACA;AACA;AACA,YANkB,EAOlB,SAPkB,EASlB;AACA;AACA,SAXkB,EAYlB,aAZkB,EAclB;AACA,aAfkB,CAApB;;AAkBA,MAAID,QAAQ,CAACE,IAAT,KAAkB,SAAtB,EAAiC;AAC/B;AACAD,IAAAA,WAAW,CAACE,IAAZ,CAAiB,QAAjB;AACD;;AAED,SAAOJ,KAAK,CAACK,OAAN,CAAcH,WAAd,KACLF,KAAK,CAACM,aAAN,EADK,IAELN,KAAK,CAACO,WAAN,CAAkB,WAAlB,CAFK,IAGLN,QAAQ,CAACE,IAAT,KAAkB,SAAlB,IAA+BH,KAAK,CAACO,WAAN,CAAkB,QAAlB,CAHjC;AAID,CA5BD;;AA8BA,MAAMC,YAAY,GAAG,CAACR,KAAD,EAAQS,MAAR,EAAgBC,OAAhB,KAA4B;AAC/C,QAAMC,gBAAgB,GAAGX,KAAK,CAACY,mBAAN,CAA0B;AAACF,IAAAA;AAAD,GAA1B,CAAzB;;AACA,MAAI,CAACC,gBAAL,EAAuB;AACrB,WAAO,EAAP;AACD;;AAED,QAAME,IAAI,GAAGb,KAAK,CAACc,OAAN,CAAcH,gBAAd,CAAb;;AAEA,MAAIE,IAAI,CAACE,MAAL,KAAgB,CAApB,EAAuB;AACrB,WAAO,EAAP;AACD;;AA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;AAFF;AAjCI,OAFd;AAwCEA,MAAAA,IAAI,EAAE;AAxCR,KADM,CALJ;AAiDJA,IAAAA,IAAI,EAAE;AAjDF;AADL,CAnDY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a yield is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing yield.\n 'abstract',\n 'virtual',\n\n // Constructor functions do not have a yield value\n // so we can bail here, too.\n 'class',\n 'constructor',\n\n // This seems to imply a class as well\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\nconst checkTagName = (utils, report, tagName) => {\n const preferredTagName = utils.getPreferredTagName({tagName});\n if (!preferredTagName) {\n return [];\n }\n\n const tags = utils.getTags(preferredTagName);\n\n if (tags.length === 0) {\n return [];\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${preferredTagName} declaration.`);\n\n return [];\n }\n\n return [preferredTagName, tags[0]];\n};\n\nexport default iterateJsdoc(({\n context,\n report,\n settings,\n utils,\n}) => {\n if (canSkip(utils, settings)) {\n return;\n }\n\n const {\n next = false,\n checkGeneratorsOnly = false,\n } = context.options[0] || {};\n\n const [preferredYieldTagName, yieldTag] = checkTagName(\n utils, report, 'yields',\n );\n if (preferredYieldTagName) {\n const shouldReportYields = () => {\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(yieldTag) && !utils.hasYieldValue();\n };\n\n // In case a yield value is declared in JSDoc, we also expect one in the code.\n if (shouldReportYields()) {\n report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`);\n }\n }\n\n if (next) {\n const [preferredNextTagName, nextTag] = checkTagName(\n utils, report, 'next',\n );\n if (preferredNextTagName) {\n const shouldReportNext = () => {\n if (checkGeneratorsOnly && !utils.isGenerator()) {\n return true;\n }\n\n return utils.hasDefinedTypeTag(nextTag) && !utils.hasYieldReturnValue();\n };\n\n if (shouldReportNext()) {\n report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`);\n }\n }\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-yields-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkGeneratorsOnly: {\n default: false,\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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n next: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireYieldsCheck.js"}