{"version":3,"file":"noBadBlocks.cjs","names":["iterateJsdoc","commentParser"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n  parse as commentParser,\n} from 'comment-parser';\n\n// Neither a single nor 3+ asterisks are valid JSDoc per\n//  https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/v;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/v;\n\nexport default iterateJsdoc(({\n  allComments,\n  context,\n  makeReport,\n  sourceCode,\n}) => {\n  const [\n    {\n      ignore = [\n        'ts-check',\n        'ts-expect-error',\n        'ts-ignore',\n        'ts-nocheck',\n      ],\n      preventAllMultiAsteriskBlocks = false,\n    } = {},\n  ] = context.options;\n\n  let extraAsterisks = false;\n  const nonJsdocNodes = /** @type {import('estree').Node[]} */ (\n    allComments\n  ).filter((comment) => {\n    const commentText = sourceCode.getText(comment);\n\n    const initialText = commentText.replace(commentRegexp, '').trimStart();\n    if ([\n      'eslint',\n    ].some((directive) => {\n      return initialText.startsWith(directive);\n    })) {\n      return false;\n    }\n\n    let sliceIndex = 2;\n    if (!commentRegexp.test(commentText)) {\n      const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n      if (!multiline) {\n        return false;\n      }\n\n      sliceIndex = multiline.length;\n      extraAsterisks = true;\n      if (preventAllMultiAsteriskBlocks) {\n        return true;\n      }\n    }\n\n    const tags = (commentParser(\n      `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n    )[0] || {}).tags ?? [];\n\n    return tags.length && !tags.some(({\n      tag,\n    }) => {\n      return ignore.includes(tag);\n    });\n  });\n\n  if (!nonJsdocNodes.length) {\n    return;\n  }\n\n  for (const node of nonJsdocNodes) {\n    const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (\n      makeReport\n    )(context, node);\n\n    // eslint-disable-next-line no-loop-func\n    const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n      const text = sourceCode.getText(node);\n\n      return fixer.replaceText(\n        node,\n        extraAsterisks ?\n          text.replace(extraAsteriskCommentRegexp, '/**') :\n          text.replace('/*', '/**'),\n      );\n    };\n\n    report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n  }\n}, {\n  checkFile: true,\n  meta: {\n    docs: {\n      description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a JSDoc block.',\n      url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',\n    },\n    fixable: 'code',\n    schema: [\n      {\n        additionalProperties: false,\n        properties: {\n          ignore: {\n            description: `An array of directives that will not be reported if present at the beginning of\na multi-comment block and at-sign \\`/* @\\`.\n\nDefaults to \\`['ts-check', 'ts-expect-error', 'ts-ignore', 'ts-nocheck']\\`\n(some directives [used by TypeScript](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html#ts-check)).`,\n            items: {\n              type: 'string',\n            },\n            type: 'array',\n          },\n          preventAllMultiAsteriskBlocks: {\n            description: `A boolean (defaulting to \\`false\\`) which if \\`true\\` will prevent all\nJSDoc-like blocks with more than two initial asterisks even those without\napparent tag content.`,\n            type: 'boolean',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'layout',\n  },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEwB;AAExB;AACA;AACA,MAAM,aAAa,GAAG,cAAc;AACpC,MAAM,0BAA0B,GAAG,YAAY;AAAC,iCAEjC,IAAAA,qBAAY,EAAC,CAAC;EAC3B,WAAW;EACX,OAAO;EACP,UAAU;EACV;AACF,CAAC,KAAK;EACJ,MAAM,CACJ;IACE,MAAM,GAAG,CACP,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,CACb;IACD,6BAA6B,GAAG;EAClC,CAAC,GAAG,CAAC,CAAC,CACP,GAAG,OAAO,CAAC,OAAO;EAEnB,IAAI,cAAc,GAAG,KAAK;EAC1B,MAAM,aAAa,GAAG,sCACpB,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