{"version":3,"file":"no-separator-comment.mjs","names":[],"sources":["../../../src/rules/code-style/no-separator-comment.ts"],"sourcesContent":["import type {Rule} from 'eslint'\n\nconst rule: Rule.RuleModule = {\n  meta: {\n    type: 'layout',\n    docs: {\n      description: 'Remove comments containing repeated characters (===, ---, +++, ###, etc.) used as separators',\n      recommended: false\n    },\n    fixable: 'code',\n    messages: {\n      noSeparatorComment: 'Separator comments with repeated characters are not allowed and will be removed.'\n    },\n    schema: []\n  },\n  create(context) {\n    const {sourceCode} = context\n    const separatorPattern = /(.)\\1{2,}/ // Match 3+ consecutive identical characters (common separator patterns)\n\n    return {\n      Program() {\n        const comments = sourceCode.getAllComments()\n\n        for (const comment of comments) {\n          if (separatorPattern.test(comment.value)) {\n            context.report({\n              loc: comment.loc!,\n              messageId: 'noSeparatorComment',\n              fix(fixer) {\n                if (!comment.range || !comment.loc) return null\n\n                const startLine = comment.loc.start.line\n                const endLine = comment.loc.end.line\n                const lineStart = sourceCode.getIndexFromLoc({line: startLine, column: 0})\n                const lineEnd = sourceCode.lines[endLine - 1].length + sourceCode.getIndexFromLoc({line: endLine, column: 0})\n\n                const contentBefore = sourceCode.text.slice(lineStart, comment.range[0])\n                const contentAfter = sourceCode.text.slice(comment.range[1], lineEnd)\n\n                if (contentBefore.trim() !== '' && contentAfter.trim() === '') return fixer.remove(comment as any)\n\n                const isLastLine = endLine === sourceCode.lines.length\n                if (isLastLine) return fixer.removeRange([lineStart, lineEnd])\n\n                const nextLineStart = sourceCode.getIndexFromLoc({line: endLine + 1, column: 0})\n                return fixer.removeRange([lineStart, nextLineStart])\n              }\n            })\n          }\n        }\n      }\n    }\n  }\n}\n\nexport default rule\n"],"mappings":";AAEA,MAAM,OAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,SAAS;EACT,UAAU,EACR,oBAAoB,oFACrB;EACD,QAAQ,EAAE;EACX;CACD,OAAO,SAAS;EACd,MAAM,EAAC,eAAc;EACrB,MAAM,mBAAmB;AAEzB,SAAO,EACL,UAAU;GACR,MAAM,WAAW,WAAW,gBAAgB;AAE5C,QAAK,MAAM,WAAW,SACpB,KAAI,iBAAiB,KAAK,QAAQ,MAAM,CACtC,SAAQ,OAAO;IACb,KAAK,QAAQ;IACb,WAAW;IACX,IAAI,OAAO;AACT,SAAI,CAAC,QAAQ,SAAS,CAAC,QAAQ,IAAK,QAAO;KAE3C,MAAM,YAAY,QAAQ,IAAI,MAAM;KACpC,MAAM,UAAU,QAAQ,IAAI,IAAI;KAChC,MAAM,YAAY,WAAW,gBAAgB;MAAC,MAAM;MAAW,QAAQ;MAAE,CAAC;KAC1E,MAAM,UAAU,WAAW,MAAM,UAAU,GAAG,SAAS,WAAW,gBAAgB;MAAC,MAAM;MAAS,QAAQ;MAAE,CAAC;KAE7G,MAAM,gBAAgB,WAAW,KAAK,MAAM,WAAW,QAAQ,MAAM,GAAG;KACxE,MAAM,eAAe,WAAW,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ;AAErE,SAAI,cAAc,MAAM,KAAK,MAAM,aAAa,MAAM,KAAK,GAAI,QAAO,MAAM,OAAO,QAAe;AAGlG,SADmB,YAAY,WAAW,MAAM,OAChC,QAAO,MAAM,YAAY,CAAC,WAAW,QAAQ,CAAC;KAE9D,MAAM,gBAAgB,WAAW,gBAAgB;MAAC,MAAM,UAAU;MAAG,QAAQ;MAAE,CAAC;AAChF,YAAO,MAAM,YAAY,CAAC,WAAW,cAAc,CAAC;;IAEvD,CAAC;KAIT;;CAEJ"}