forked from public/fvtt-cthulhu-eternal
1 line
7.6 KiB
Plaintext
1 line
7.6 KiB
Plaintext
|
{"version":3,"file":"requireDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","checkDescription","description","trim","split","filter","Boolean","length","_default","exports","iterateJsdoc","jsdoc","report","utils","context","avoidDocs","descriptionStyle","options","targetTagName","getPreferredTagName","skipReportingBlockedTag","tagName","isBlocked","blocked","getDescription","descTags","getPresentTags","tag","functionExamples","tags","example","name","getTagDescription","contextDefaults","meta","docs","url","schema","additionalProperties","properties","checkConstructors","type","checkGetters","checkSetters","contexts","items","anyOf","comment","enum","exemptedBy","module"],"sources":["../../src/rules/requireDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} description\n * @returns {import('../iterateJsdoc.js').Integer}\n */\nconst checkDescription = (description) => {\n return description\n .trim()\n .split('\\n')\n .filter(Boolean)\n .length;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n}) => {\n if (utils.avoidDocs()) {\n return;\n }\n\n const {\n descriptionStyle = 'body',\n } = 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\n const isBlocked = typeof targetTagName === 'object' && 'blocked' in targetTagName && targetTagName.blocked;\n if (isBlocked) {\n targetTagName = /** @type {{blocked: true; tagName: string;}} */ (\n targetTagName\n ).tagName;\n }\n\n if (descriptionStyle !== 'tag') {\n const {\n description,\n } = utils.getDescription();\n if (checkDescription(description || '')) {\n return;\n }\n\n if (descriptionStyle === 'body') {\n const descTags = utils.getPresentTags([\n 'desc', 'description',\n ]);\n if (descTags.length) {\n const [\n {\n tag: tagName,\n },\n ] = 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 jsdoc.tags.filter(({\n tag,\n }) => {\n return 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 for (const example of functionExamples) {\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/blob/main/docs/rules/require-description.md#repos-sticky-header',\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: 'stri
|