{"version":3,"sources":["../../src/rules/requireThrows.js"],"names":["canSkip","utils","hasATag","avoidDocs","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","hasThrowValue","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","context","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAIC,KAAD,IAAW;AACzB,SAAOA,KAAK,CAACC,OAAN,CAAc,CACnB;AACA;AACA;AACA;AACA;AACA,YANmB,EAOnB,SAPmB,EASnB;AACA,QAVmB,CAAd,KAYLD,KAAK,CAACE,SAAN,EAZF;AAaD,CAdD;;eAgBe,2BAAa,CAAC;AAC3BC,EAAAA,MAD2B;AAE3BH,EAAAA;AAF2B,CAAD,KAGtB;AACJ;AACA;AACA,MAAID,OAAO,CAACC,KAAD,CAAX,EAAoB;AAClB;AACD;;AAED,QAAMI,OAAO,GAAGJ,KAAK,CAACK,mBAAN,CAA0B;AAACD,IAAAA,OAAO,EAAE;AAAV,GAA1B,CAAhB;;AACA,MAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,QAAME,IAAI,GAAGN,KAAK,CAACO,OAAN,CAAcH,OAAd,CAAb;AACA,QAAMI,iBAAiB,GAAGR,KAAK,CAACS,mBAAN,EAA1B,CAbI,CAeJ;;AACA,QAAM,CAACC,GAAD,IAAQJ,IAAd;AACA,QAAMK,gBAAgB,GAAG,OAAOD,GAAP,KAAe,WAAf,IAA8BA,GAAG,KAAK,IAA/D;;AAEA,QAAME,YAAY,GAAG,MAAM;AACzB,QAAI,CAACD,gBAAL,EAAuB;AACrB,aAAO,KAAP;AACD;;AAED,WAAOH,iBAAiB,IAAIR,KAAK,CAACa,aAAN,EAA5B;AACD,GAND;;AAQA,MAAID,YAAY,EAAhB,EAAoB;AAClBT,IAAAA,MAAM,CAAE,kBAAiBC,OAAQ,eAA3B,CAAN;AACD;AACF,CAjCc,EAiCZ;AACDU,EAAAA,eAAe,EAAE,IADhB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,GAAG,EAAE;AADD,KADF;AAIJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVC,QAAAA,QAAQ,EAAE;AACRC,UAAAA,KAAK,EAAE;AACLC,YAAAA,KAAK,EAAE,CACL;AACEC,cAAAA,IAAI,EAAE;AADR,aADK,EAIL;AACEL,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVK,gBAAAA,OAAO,EAAE;AACPD,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIVE,gBAAAA,OAAO,EAAE;AACPF,kBAAAA,IAAI,EAAE;AADC;AAJC,eAFd;AAUEA,cAAAA,IAAI,EAAE;AAVR,aAJK;AADF,WADC;AAoBRA,UAAAA,IAAI,EAAE;AApBE,SADA;AAuBVG,QAAAA,UAAU,EAAE;AACVL,UAAAA,KAAK,EAAE;AACLE,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI;AAvBF,OAFd;AAgCEA,MAAAA,IAAI,EAAE;AAhCR,KADM,CAJJ;AAwCJA,IAAAA,IAAI,EAAE;AAxCF;AAFL,CAjCY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\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 *\n * @param {*} utils\n * a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean}\n * true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not 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 = utils.getPreferredTagName({tagName: 'throws'});\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 [tag] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\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 url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns',\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"],"file":"requireThrows.js"}