|
1 |
- {"version":3,"sources":["../../src/rules/requireExample.js"],"names":["context","jsdoc","report","utils","avoidDocs","exemptNoArguments","options","targetTagName","functionExamples","_","filter","tags","tag","length","isIteratingFunction","hasParams","reportJSDoc","addTag","forEach","example","exampleContent","compact","name","getTagDescription","trim","split","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","checkConstructors","default","type","checkGetters","checkSetters","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;AACA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,MAAIA,KAAK,CAACC,SAAN,EAAJ,EAAuB;AACrB;AACD;;AAED,QAAM;AACJC,IAAAA,iBAAiB,GAAG;AADhB,MAEFL,OAAO,CAACM,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;AAIA,QAAMC,aAAa,GAAG,SAAtB;;AAEA,QAAMC,gBAAgB,GAAGC,gBAAEC,MAAF,CAAST,KAAK,CAACU,IAAf,EAAqB;AAC5CC,IAAAA,GAAG,EAAEL;AADuC,GAArB,CAAzB;;AAIA,MAAI,CAACC,gBAAgB,CAACK,MAAtB,EAA8B;AAC5B,QAAIR,iBAAiB,IAAIF,KAAK,CAACW,mBAAN,EAArB,IACF,CAACX,KAAK,CAACY,SAAN,EADH,EAEE;AACA;AACD;;AAEDZ,IAAAA,KAAK,CAACa,WAAN,CAAmB,kBAAiBT,aAAc,eAAlD,EAAkE,IAAlE,EAAwE,MAAM;AAC5EJ,MAAAA,KAAK,CAACc,MAAN,CAAaV,aAAb;AACD,KAFD;AAIA;AACD;;AAEDC,EAAAA,gBAAgB,CAACU,OAAjB,CAA0BC,OAAD,IAAa;AACpC,UAAMC,cAAc,GAAGX,gBAAEY,OAAF,CAAW,GAAEF,OAAO,CAACG,IAAK,IAAGnB,KAAK,CAACoB,iBAAN,CAAwBJ,OAAxB,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,EAAE;AACVH,UAAAA,KAAK,EAAE;AACLJ,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI,SAnCF;AAyCVhC,QAAAA,iBAAiB,EAAE;AACjB+B,UAAAA,OAAO,EAAE,KADQ;AAEjBC,UAAAA,IAAI,EAAE;AAFW;AAzCT,OAFd;AAgDEA,MAAAA,IAAI,EAAE;AAhDR,KADM,CANJ;AA0DJA,IAAAA,IAAI,EAAE;AA1DF;AAFL,CAzCY,C","sourcesContent":["import _ from 'lodash';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n report,\n utils,\n}) => {\n if (utils.avoidDocs()) {\n return;\n }\n\n const {\n exemptNoArguments = false,\n } = context.options[0] || {};\n\n const targetTagName = 'example';\n\n const functionExamples = _.filter(jsdoc.tags, {\n tag: targetTagName,\n });\n\n if (!functionExamples.length) {\n if (exemptNoArguments && utils.isIteratingFunction() &&\n !utils.hasParams()\n ) {\n return;\n }\n\n utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => {\n utils.addTag(targetTagName);\n });\n\n return;\n }\n\n functionExamples.forEach((example) => {\n const exampleContent = _.compact(`${example.name} ${utils.getTagDescription(example)}`.trim().split('\\n'));\n\n if (!exampleContent.length) {\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 examples.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-example',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: true,\n type: 'boolean',\n },\n checkGetters: {\n default: false,\n type: 'boolean',\n },\n checkSetters: {\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 exemptNoArguments: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireExample.js"}
|