{"version":3,"file":"requireExample.cjs","names":["iterateJsdoc"],"sources":["../../src/rules/requireExample.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n  context,\n  jsdoc,\n  report,\n  utils,\n}) => {\n  if (utils.avoidDocs()) {\n    return;\n  }\n\n  const {\n    enableFixer = true,\n    exemptNoArguments = false,\n  } = context.options[0] || {};\n\n  const targetTagName = 'example';\n\n  const functionExamples = jsdoc.tags.filter(({\n    tag,\n  }) => {\n    return tag === targetTagName;\n  });\n\n  if (!functionExamples.length) {\n    if (exemptNoArguments && utils.isIteratingFunctionOrVariable() &&\n      !utils.hasParams()\n    ) {\n      return;\n    }\n\n    utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => {\n      if (enableFixer) {\n        utils.addTag(targetTagName);\n      }\n    });\n\n    return;\n  }\n\n  for (const example of functionExamples) {\n    const exampleContent = `${example.name} ${utils.getTagDescription(example)}`\n      .trim()\n      .split('\\n')\n      .filter(Boolean);\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 (and potentially other contexts) have examples.',\n      url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-example.md#repos-sticky-header',\n    },\n    fixable: 'code',\n    schema: [\n      {\n        additionalProperties: false,\n        properties: {\n          checkConstructors: {\n            default: true,\n            description: `A value indicating whether \\`constructor\\`s should be checked.\nDefaults to \\`true\\`.`,\n            type: 'boolean',\n          },\n          checkGetters: {\n            default: false,\n            description: 'A value indicating whether getters should be checked. Defaults to `false`.',\n            type: 'boolean',\n          },\n          checkSetters: {\n            default: false,\n            description: 'A value indicating whether setters should be checked. Defaults to `false`.',\n            type: 'boolean',\n          },\n          contexts: {\n            description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n(e.g., \\`ClassDeclaration\\` for ES6 classes).\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want the rule to apply to any\nJSDoc block throughout your files.\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          enableFixer: {\n            default: true,\n            description: `A boolean on whether to enable the fixer (which adds an empty \\`@example\\` block).\nDefaults to \\`true\\`.`,\n            type: 'boolean',\n          },\n          exemptedBy: {\n            description: `Array of tags (e.g., \\`['type']\\`) whose presence on the document\nblock avoids the need for an \\`@example\\`. Defaults to an array with\n\\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n            items: {\n              type: 'string',\n            },\n            type: 'array',\n          },\n          exemptNoArguments: {\n            default: false,\n            description: `Boolean to indicate that no-argument functions should not be reported for\nmissing \\`@example\\` declarations.`,\n            type: 'boolean',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'suggestion',\n  },\n});\n"],"mappings":";;;;;;AAAA;AAA8C;AAAA,iCAE/B,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,WAAW,GAAG,IAAI;IAClB,iBAAiB,GAAG;EACtB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM,a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