{"version":3,"file":"checkIndentation.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","maskExcludedContent","str","excludeTags","regContent","RegExp","join","replace","_match","margin","code","repeat","match","length","maskCodeBlocks","replaceAll","getLineNumber","lines","lineIndex","precedingText","slice","lineBreaks","_default","exports","iterateJsdoc","context","jsdocNode","report","sourceCode","options","allowIndentedSections","textWithoutCodeBlocks","getText","text","split","hasSeenContent","currentSectionIndent","line","entries","indentMatch","afterIndent","indentAmount","test","trim","reg","lastIndex","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","type","items","pattern","module"],"sources":["../../src/rules/checkIndentation.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} str\n * @param {string[]} excludeTags\n * @returns {string}\n */\nconst maskExcludedContent = (str, excludeTags) => {\n  const regContent = new RegExp(`([ \\\\t]+\\\\*)[ \\\\t]@(?:${excludeTags.join('|')})(?=[ \\\\n])([\\\\w\\\\|\\\\W]*?\\\\n)(?=[ \\\\t]*\\\\*(?:[ \\\\t]*@\\\\w+\\\\s|\\\\/))`, 'gv');\n\n  return str.replace(regContent, (_match, margin, code) => {\n    return (margin + '\\n').repeat(code.match(/\\n/gv).length);\n  });\n};\n\n/**\n * @param {string} str\n * @returns {string}\n */\nconst maskCodeBlocks = (str) => {\n  const regContent = /([ \\t]+\\*)[ \\t]```[^\\n]*?([\\w\\|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*(?:```|@\\w+\\s)|\\/))/gv;\n\n  return str.replaceAll(regContent, (_match, margin, code) => {\n    return (margin + '\\n').repeat(code.match(/\\n/gv).length);\n  });\n};\n\n/**\n * @param {string[]} lines\n * @param {number} lineIndex\n * @returns {number}\n */\nconst getLineNumber = (lines, lineIndex) => {\n  const precedingText = lines.slice(0, lineIndex).join('\\n');\n  const lineBreaks = precedingText.match(/\\n/gv) || [];\n  return lineBreaks.length + 1;\n};\n\nexport default iterateJsdoc(({\n  context,\n  jsdocNode,\n  report,\n  sourceCode,\n}) => {\n  const options = context.options[0] || {};\n  const /** @type {{excludeTags: string[], allowIndentedSections: boolean}} */ {\n    allowIndentedSections = false,\n    excludeTags = [\n      'example',\n    ],\n  } = options;\n\n  const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));\n  const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;\n\n  if (allowIndentedSections) {\n    // When allowIndentedSections is enabled, only check for indentation on tag lines\n    // and the very first line of the main description\n    const lines = text.split('\\n');\n    let hasSeenContent = false;\n    let currentSectionIndent = null;\n\n    for (const [\n      lineIndex,\n      line,\n    ] of lines.entries()) {\n      // Check for indentation (two or more spaces after *)\n      const indentMatch = line.match(/^(?:\\/?\\**|[\\t ]*)\\*([\\t ]{2,})/v);\n\n      if (indentMatch) {\n        // Check what comes after the indentation\n        const afterIndent = line.slice(indentMatch[0].length);\n        const indentAmount = indentMatch[1].length;\n\n        // If this is a tag line with indentation, always report\n        if (/^@\\w+/v.test(afterIndent)) {\n          report('There must be no indentation.', null, {\n            line: getLineNumber(lines, lineIndex),\n          });\n          return;\n        }\n\n        // If we haven't seen any content yet (main description first line) and there's content, report\n        if (!hasSeenContent && afterIndent.trim().length > 0) {\n          report('There must be no indentation.', null, {\n            line: getLineNumber(lines, lineIndex),\n          });\n          return;\n        }\n\n        // For continuation lines, check consistency\n        if (hasSeenContent && afterIndent.trim().length > 0) {\n          if (currentSectionIndent === null) {\n            // First indented line in this section, set the indent level\n            currentSectionIndent = indentAmount;\n          } else if (indentAmount < currentSectionIndent) {\n            // Indentation is less than the established level (inconsistent)\n            report('There must be no indentation.', null, {\n              line: getLineNumber(lines, lineIndex),\n            });\n            return;\n          }\n        }\n      } else if (/^\\s*\\*\\s+\\S/v.test(line)) {\n        // No indentation on this line, reset section indent tracking\n        // (unless it's just whitespace or a closing comment)\n        currentSectionIndent = null;\n      }\n\n      // Track if we've seen any content (non-whitespace after the *)\n      if (/^\\s*\\*\\s+\\S/v.test(line)) {\n        hasSeenContent = true;\n      }\n\n      // Reset section indent when we encounter a tag\n      if (/@\\w+/v.test(line)) {\n        currentSectionIndent = null;\n      }\n    }\n  } else {\n    const reg = /^(?:\\/?\\**|[ \\t]*)\\*[ \\t]{2}/gmv;\n    if (reg.test(text)) {\n      const lineBreaks = text.slice(0, reg.lastIndex).match(/\\n/gv) || [];\n      report('There must be no indentation.', null, {\n        line: lineBreaks.length,\n      });\n    }\n  }\n}, {\n  iterateAllJsdocs: true,\n  meta: {\n    docs: {\n      description: 'Reports invalid padding inside JSDoc blocks.',\n      url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#repos-sticky-header',\n    },\n    schema: [\n      {\n        additionalProperties: false,\n        properties: {\n          allowIndentedSections: {\n            description: 'Allows indentation of nested sections on subsequent lines (like bullet lists)',\n            type: 'boolean',\n          },\n          excludeTags: {\n            description: `Array of tags (e.g., \\`['example', 'description']\\`) whose content will be\n\"hidden\" from the \\`check-indentation\\` rule. Defaults to \\`['example']\\`.\n\nBy default, the whole JSDoc block will be checked for invalid padding.\nThat would include \\`@example\\` blocks too, which can get in the way\nof adding full, readable examples of code without ending up with multiple\nlinting issues.\n\nWhen disabled (by passing \\`excludeTags: []\\` option), the following code *will*\nreport a padding issue:\n\n\\`\\`\\`js\n/**\n * @example\n * anArray.filter((a) => {\n *   return a.b;\n * });\n */\n\\`\\`\\``,\n            items: {\n              pattern: '^\\\\S+$',\n              type: 'string',\n            },\n            type: 'array',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'layout',\n  },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA,MAAMG,mBAAmB,GAAGA,C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