{"version":3,"sources":["../../src/rules/requireDescription.js"],"names":["jsdoc","report","utils","context","avoidDocs","options","descriptionStyle","targetTagName","getPreferredTagName","skipReportingBlockedTag","tagName","isBlocked","blocked","checkDescription","description","exampleContent","_","compact","trim","split","length","functionExamples","filter","tags","tag","forEach","example","name","contextDefaults","meta","schema","additionalProperties","properties","contexts","items","type","enum","exemptedBy"],"mappings":";;;;;;;AAAA;;AACA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA,KAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,MAAID,KAAK,CAACE,SAAN,EAAJ,EAAuB;AACrB;AACD;;AAHG,eAIgCD,OAAO,CAACE,OAAR,CAAgB,CAAhB,KAAsB,EAJtD;AAAA,qCAIGC,gBAJH;AAAA,QAIGA,gBAJH,sCAIsB,MAJtB;;AAMJ,MAAIC,aAAa,GAAGL,KAAK,CAACM,mBAAN,CAA0B;AAC5C;AACA;AACA;AACA;AACAC,IAAAA,uBAAuB,EAAEH,gBAAgB,KAAK,KALF;AAM5CI,IAAAA,OAAO,EAAE;AANmC,GAA1B,CAApB;;AAQA,MAAI,CAACH,aAAL,EAAoB;AAClB;AACD;;AACD,QAAMI,SAAS,GAAG,OAAOJ,aAAP,KAAyB,QAAzB,IAAqCA,aAAa,CAACK,OAArE;;AACA,MAAID,SAAJ,EAAe;AACbJ,IAAAA,aAAa,GAAGA,aAAa,CAACG,OAA9B;AACD;;AAED,QAAMG,gBAAgB,GAAIC,WAAD,IAAiB;AACxC,UAAMC,cAAc,GAAGC,gBAAEC,OAAF,CAAUH,WAAW,CAACI,IAAZ,GAAmBC,KAAnB,CAAyB,IAAzB,CAAV,CAAvB;;AAEA,WAAOJ,cAAc,CAACK,MAAtB;AACD,GAJD;;AAMA,MAAId,gBAAgB,KAAK,KAAzB,EAAgC;AAC9B,QAAIO,gBAAgB,CAACb,KAAK,CAACc,WAAN,IAAqB,E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;AAJI;AAXF,OAFd;AAoBEA,MAAAA,IAAI,EAAE;AApBR,KADM,CADJ;AAyBJA,IAAAA,IAAI,EAAE;AAzBF;AAFL,CAlEY,C","sourcesContent":["import _ from 'lodash';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n}) => {\n if (utils.avoidDocs()) {\n return;\n }\n const {descriptionStyle = 'body'} = context.options[0] || {};\n\n let targetTagName = utils.getPreferredTagName({\n // We skip reporting except when `@description` is essential to the rule,\n // so user can block the tag and still meaningfully use this rule\n // even if the tag is present (and `check-tag-names` is the one to\n // normally report the fact that it is blocked but present)\n skipReportingBlockedTag: descriptionStyle !== 'tag',\n tagName: 'description',\n });\n if (!targetTagName) {\n return;\n }\n const isBlocked = typeof targetTagName === 'object' && targetTagName.blocked;\n if (isBlocked) {\n targetTagName = targetTagName.tagName;\n }\n\n const checkDescription = (description) => {\n const exampleContent = _.compact(description.trim().split('\\n'));\n\n return exampleContent.length;\n };\n\n if (descriptionStyle !== 'tag') {\n if (checkDescription(jsdoc.description || '')) {\n return;\n }\n\n if (descriptionStyle === 'body') {\n report('Missing JSDoc block description.');\n\n return;\n }\n }\n\n const functionExamples = isBlocked ?\n [] :\n _.filter(jsdoc.tags, {\n tag: targetTagName,\n });\n\n if (!functionExamples.length) {\n report(\n descriptionStyle === 'any' ?\n `Missing JSDoc block description or @${targetTagName} declaration.` :\n `Missing JSDoc @${targetTagName} declaration.`,\n );\n\n return;\n }\n\n functionExamples.forEach((example) => {\n if (!checkDescription(`${example.name} ${example.description}`)) {\n report(`Missing JSDoc @${targetTagName} description.`);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n descriptionStyle: {\n enum: ['body', 'tag', 'any'],\n type: 'string',\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":"requireDescription.js"}