|
1 |
- {"version":3,"sources":["../../src/rules/noBadBlocks.js"],"names":["commentRegexp","extraAsteriskCommentRegexp","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","multiline","exec","length","tags","slice","some","tag","includes","forEach","node","report","fix","fixer","text","replaceText","replace","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type"],"mappings":";;;;;;;AAAA;;AAGA;;;;AAEA;AACA;AACA,MAAMA,aAAa,GAAG,cAAtB;AACA,MAAMC,0BAA0B,GAAG,YAAnC;;eAEe,2BAAa,CAAC;AAC3BC,EAAAA,OAD2B;AAE3BC,EAAAA,UAF2B;AAG3BC,EAAAA,WAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAM,CACJ;AACEC,IAAAA,MAAM,GAAG,CACP,UADO,EAEP,iBAFO,EAGP,WAHO,EAIP,YAJO,CADX;AAOEC,IAAAA,6BAA6B,GAAG;AAPlC,MAQI,EATA,IAUFL,OAAO,CAACM,OAVZ;AAYA,MAAIC,cAAc,GAAG,KAArB;AACA,QAAMC,aAAa,GAAGN,WAAW,CAACO,MAAZ,CAAoBC,OAAD,IAAa;AACpD,UAAMC,WAAW,GAAGV,UAAU,CAACW,OAAX,CAAmBF,OAAnB,CAApB;AACA,QAAIG,UAAU,GAAG,CAAjB;;AACA,QAAI,CAACf,aAAa,CAACgB,IAAd,CAAmBH,WAAnB,CAAL,EAAsC;AAAA;;AACpC,YAAMI,SAAS,4BAAGhB,0BAA0B,CAACiB,IAA3B,CAAgCL,WAAhC,CAAH,0DAAG,sBAA+C,CAA/C,CAAlB;;AACA,UAAI,CAACI,SAAL,EAAgB;AACd,eAAO,KAAP;AACD;;AACDF,MAAAA,UAAU,GAAGE,SAAS,CAACE,MAAvB;AACAV,MAAAA,cAAc,GAAG,IAAjB;;AACA,UAAIF,6BAAJ,EAAmC;AACjC,eAAO,IAAP;AACD;AAC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AAA,UAAU,EAAE;AACVnC,QAAAA,MAAM,EAAE;AACNoC,UAAAA,KAAK,EAAE;AACLC,YAAAA,IAAI,EAAE;AADD,WADD;AAINA,UAAAA,IAAI,EAAE;AAJA,SADE;AAOVpC,QAAAA,6BAA6B,EAAE;AAC7BoC,UAAAA,IAAI,EAAE;AADuB;AAPrB,OAFd;AAaEA,MAAAA,IAAI,EAAE;AAbR,KADM,CANJ;AAuBJA,IAAAA,IAAI,EAAE;AAvBF;AAFL,CA9DY,C","sourcesContent":["import {\n parse as commentParser,\n} from 'comment-parser';\nimport iterateJsdoc from '../iterateJsdoc';\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 = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n context,\n sourceCode,\n allComments,\n makeReport,\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 = allComments.filter((comment) => {\n const commentText = sourceCode.getText(comment);\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\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 );\n\n return tags.length && !tags.some(({tag}) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n nonJsdocNodes.forEach((node) => {\n const report = makeReport(context, node);\n\n const fix = (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 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#eslint-plugin-jsdoc-rules-no-bad-blocks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"file":"noBadBlocks.js"}
|