github-pages-deploy-action/node_modules/eslint-plugin-jsdoc/dist/rules/matchDescription.js.map
2020-03-31 08:40:00 -04:00

1 line
7.0 KiB
Plaintext

{"version":3,"sources":["../../src/rules/matchDescription.js"],"names":["matchDescriptionDefault","stringOrDefault","value","userDefault","jsdoc","report","context","utils","options","validateDescription","description","tag","mainDescription","tagValue","tagName","tags","regex","RegExp","matchDescription","test","line","Object","keys","length","hasOptionTag","Boolean","forEachPreferredTag","matchingJsdocTag","targetTagName","name","trim","whitelistedTags","filterTags","getTagsByType","tagsWithNames","tagsWithoutNames","some","_","trimStart","contextDefaults","meta","schema","additionalProperties","properties","contexts","items","type","oneOf","format","patternProperties","enum"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA;AACA;AACA,MAAMA,uBAAuB,GAAG,6BAAhC;;AAEA,MAAMC,eAAe,GAAG,CAACC,KAAD,EAAQC,WAAR,KAAwB;AAC9C,SAAO,OAAOD,KAAP,KAAiB,QAAjB,GACLA,KADK,GAELC,WAAW,IAAIH,uBAFjB;AAGD,CAJD;;eAMe,2BAAa,CAAC;AAC3BI,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA,OAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAMC,OAAO,GAAGF,OAAO,CAACE,OAAR,CAAgB,CAAhB,KAAsB,EAAtC;;AAEA,QAAMC,mBAAmB,GAAG,CAACC,WAAD,EAAcC,GAAd,KAAsB;AAChD,QAAI,CAACA,GAAD,IAAQH,OAAO,CAACI,eAAR,KAA4B,KAAxC,EAA+C;AAC7C;AACD;;AAED,QAAIC,QAAQ,GAAGL,OAAO,CAACI,eAAvB;;AACA,QAAID,GAAJ,EAAS;AACP,YAAMG,OAAO,GAAGH,GAAG,CAACA,GAApB;AACAE,MAAAA,QAAQ,GAAGL,OAAO,CAACO,IAAR,CAAaD,OAAb,CAAX;AACD;;AAED,UAAME,KAAK,GAAG,IAAIC,MAAJ,CACZhB,eAAe,CAACY,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V;AAEEF,gBAAAA,IAAI,EAAE;AAFR,eADK,EAKL;AACEI,gBAAAA,IAAI,EAAE,CAAC,IAAD,CADR;AAEEJ,gBAAAA,IAAI,EAAE;AAFR,eALK;AADH;AADW,WADf;AAeJA,UAAAA,IAAI,EAAE;AAfF;AAtBI,OAFd;AA0CEA,MAAAA,IAAI,EAAE;AA1CR,KADM,CADJ;AA+CJA,IAAAA,IAAI,EAAE;AA/CF;AAFL,CAnEY,C","sourcesContent":["import _ from 'lodash';\nimport iterateJsdoc from '../iterateJsdoc';\n\n// If supporting Node >= 10, we could loosen the default to this for the\n// initial letter: \\\\p{Upper}\nconst matchDescriptionDefault = '^[A-Z`\\\\d_][\\\\s\\\\S]*[.?!`]$';\n\nconst stringOrDefault = (value, userDefault) => {\n return typeof value === 'string' ?\n value :\n userDefault || matchDescriptionDefault;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n utils,\n}) => {\n const options = context.options[0] || {};\n\n const validateDescription = (description, tag) => {\n if (!tag && options.mainDescription === false) {\n return;\n }\n\n let tagValue = options.mainDescription;\n if (tag) {\n const tagName = tag.tag;\n tagValue = options.tags[tagName];\n }\n\n const regex = new RegExp(\n stringOrDefault(tagValue, options.matchDescription),\n 'u',\n );\n\n if (!regex.test(description)) {\n report('JSDoc description does not satisfy the regex pattern.', null, tag || {\n // Add one as description would typically be into block\n line: jsdoc.line + 1,\n });\n }\n };\n\n if (jsdoc.description) {\n validateDescription(jsdoc.description);\n }\n\n if (!options.tags || !Object.keys(options.tags).length) {\n return;\n }\n\n const hasOptionTag = (tagName) => {\n return Boolean(options.tags[tagName]);\n };\n\n utils.forEachPreferredTag('description', (matchingJsdocTag, targetTagName) => {\n const description = (matchingJsdocTag.name + ' ' + matchingJsdocTag.description).trim();\n if (hasOptionTag(targetTagName)) {\n validateDescription(description, matchingJsdocTag);\n }\n }, true);\n\n const whitelistedTags = utils.filterTags(({tag: tagName}) => {\n return hasOptionTag(tagName);\n });\n const {tagsWithNames, tagsWithoutNames} = utils.getTagsByType(whitelistedTags);\n\n tagsWithNames.some((tag) => {\n const description = _.trimStart(tag.description, '- ');\n\n return validateDescription(description, tag);\n });\n\n tagsWithoutNames.some((tag) => {\n const description = (tag.name + ' ' + tag.description).trim();\n\n return validateDescription(description, tag);\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 mainDescription: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n ],\n },\n matchDescription: {\n format: 'regex',\n type: 'string',\n },\n tags: {\n patternProperties: {\n '.*': {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [true],\n type: 'boolean',\n },\n ],\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchDescription.js"}