{"version":3,"file":"requireDescription.cjs","names":["iterateJsdoc"],"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  context,\n  jsdoc,\n  report,\n  utils,\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 (and potentially other contexts) 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            description: `A value indicating whether \\`constructor\\`s should be\nchecked. Defaults to \\`true\\`.`,\n            type: 'boolean',\n          },\n          checkGetters: {\n            default: true,\n            description: `A value indicating whether getters should be checked.\nDefaults to \\`true\\`.`,\n            type: 'boolean',\n          },\n          checkSetters: {\n            default: true,\n            description: `A value indicating whether setters should be checked.\nDefaults to \\`true\\`.`,\n            type: 'boolean',\n          },\n          contexts: {\n            description: `Set to an array of strings representing the AST context\nwhere you wish the rule to be applied (e.g., \\`ClassDeclaration\\` for ES6\nclasses).\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`,\n\\`FunctionDeclaration\\`, \\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\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            description: `Whether to accept implicit descriptions (\\`\"body\"\\`) or\n\\`@description\\` tags (\\`\"tag\"\\`) as satisfying the rule. Set to \\`\"any\"\\` to\naccept either style. Defaults to \\`\"body\"\\`.`,\n            enum: [\n              'body', 'tag', 'any',\n            ],\n            type: 'string',\n          },\n          exemptedBy: {\n            description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@description\\`. Defaults to an\narray with \\`inheritdoc\\`. If you set this array, it will overwrite the\ndefault, so be sure to add back \\`inheritdoc\\` if you wish its presence\nto cause exemption of the rule.`,\n            items: {\n              type: 'string',\n            },\n            type: 'array',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'suggestion',\n  },\n});\n"],"mappings":";;;;;;AAAA;AAA8C;AAE9C;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAI,WAAW,IAAK;EACxC,OAAO,WAAW,CACf,IAAI,CAAC,CAAC,CACN,KAAK,CAAC,IAAI,CAAC,CACX,MAAM,CAAC,OAAO,CAAC,CACf,MAAM;AACX,CAAC;AAAC,iCAEa,IAAAA,qBAAY,EAAC,CAAC;EAC3B,OAAO;EACP,KAAK;EACL,MAAM;EACN;AACF,CAAC,KAAK;EACJ,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;EAEA,MAAM;IACJ,gBAAgB,GAAG;EACrB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,IAAI,aAAa,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAC5C;IACA;IACA;IACA;IACA,uBAAuB,EAAE,gBAAgB,KAAK,KAAK;IACnD,OAAO,EAAE;EACX,CAAC,CAAC;EACF,IAAI,CAAC,aAAa,EAAE;IAClB;EACF;EAEA,MAAM,SAAS,GAAG,OAAO,aAAa,KAAK,QAAQ,IAAI,SAAS,IAAI,aAAa,IAAI,aAAa,CAAC,OAAO;EAC1G,IAAI,SAAS,EAAE;IACb,aAAa,GAAG,gDACd,aAAa,CACb,OAAO;E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