1 |
- {"version":3,"sources":["../../src/rules/requireDescription.js"],"names":["jsdoc","report","utils","context","avoidDocs","descriptionStyle","options","targetTagName","getPreferredTagName","skipReportingBlockedTag","tagName","isBlocked","blocked","checkDescription","description","exampleContent","_","compact","trim","split","length","getDescription","descTags","getPresentTags","tag","functionExamples","filter","tags","forEach","example","name","getTagDescription","contextDefaults","meta","docs","url","schema","additionalProperties","properties","checkConstructors","default","type","checkGetters","checkSetters","contexts","items","anyOf","comment","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;;AACD,QAAM;AAACC,IAAAA,gBAAgB,GAAG;AAApB,MAA8BF,OAAO,CAACG,OAAR,CAAgB,CAAhB,KAAsB,EAA1D;AAEA,MAAIC,aAAa,GAAGL,KAAK,CAACM,mBAAN,CAA0B;AAC5C;AACA;AACA;AACA;AACAC,IAAAA,uBAAuB,EAAEJ,gBAAgB,KAAK,KALF;AAM5CK,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,MAAIf,gBAAgB,KAAK,KAAzB,EAAgC;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,EAAE;AAzDF;AAFL,CAzEY,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 const {description} = utils.getDescription();\n if (checkDescription(description || '')) {\n return;\n }\n\n if (descriptionStyle === 'body') {\n const descTags = utils.getPresentTags(['desc', 'description']);\n if (descTags.length) {\n const [{tag: tagName}] = descTags;\n report(`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`);\n } else {\n report('Missing JSDoc block description.');\n }\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} ${utils.getTagDescription(example)}`)) {\n report(`Missing JSDoc @${targetTagName} description.`, null, example);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that all functions have a description.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: true,\n type: 'boolean',\n },\n checkGetters: {\n default: true,\n type: 'boolean',\n },\n checkSetters: {\n default: true,\n type: 'boolean',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\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"}
|