eslint-plugin-jsdoc 60.4.1 → 60.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/iterateJsdoc.d.ts +5 -0
  3. package/dist/cjs/jsdocUtils.d.ts +19 -2
  4. package/dist/cjs/rules/escapeInlineTags.d.ts +2 -0
  5. package/dist/generateDocs.cjs +5 -6
  6. package/dist/generateDocs.cjs.map +1 -1
  7. package/dist/index-cjs.cjs +14 -1
  8. package/dist/index-cjs.cjs.map +1 -1
  9. package/dist/index-esm.cjs +0 -2
  10. package/dist/index-esm.cjs.map +1 -1
  11. package/dist/index.cjs +14 -3
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/iterateJsdoc.cjs +12 -0
  14. package/dist/iterateJsdoc.cjs.map +1 -1
  15. package/dist/iterateJsdoc.d.ts +5 -0
  16. package/dist/jsdocUtils.cjs +21 -17
  17. package/dist/jsdocUtils.cjs.map +1 -1
  18. package/dist/jsdocUtils.d.ts +19 -2
  19. package/dist/rules/checkLineAlignment.cjs +1 -2
  20. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  21. package/dist/rules/checkTagNames.cjs +16 -0
  22. package/dist/rules/checkTagNames.cjs.map +1 -1
  23. package/dist/rules/convertToJsdocComments.cjs +2 -4
  24. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  25. package/dist/rules/emptyTags.cjs +1 -2
  26. package/dist/rules/emptyTags.cjs.map +1 -1
  27. package/dist/rules/escapeInlineTags.cjs +149 -0
  28. package/dist/rules/escapeInlineTags.cjs.map +1 -0
  29. package/dist/rules/escapeInlineTags.d.ts +3 -0
  30. package/dist/rules/informativeDocs.cjs +3 -6
  31. package/dist/rules/informativeDocs.cjs.map +1 -1
  32. package/dist/rules/linesBeforeBlock.cjs +4 -8
  33. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  34. package/dist/rules/matchDescription.cjs +2 -4
  35. package/dist/rules/matchDescription.cjs.map +1 -1
  36. package/dist/rules/matchName.cjs +1 -2
  37. package/dist/rules/matchName.cjs.map +1 -1
  38. package/dist/rules/multilineBlocks.cjs +3 -6
  39. package/dist/rules/multilineBlocks.cjs.map +1 -1
  40. package/dist/rules/noBadBlocks.cjs +1 -2
  41. package/dist/rules/noBadBlocks.cjs.map +1 -1
  42. package/dist/rules/noTypes.cjs +1 -2
  43. package/dist/rules/noTypes.cjs.map +1 -1
  44. package/dist/rules/noUndefinedTypes.cjs +1 -1
  45. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  46. package/dist/rules/requireAsteriskPrefix.cjs +1 -2
  47. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  48. package/dist/rules/requireDescriptionCompleteSentence.cjs +1 -2
  49. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  50. package/dist/rules/requireFileOverview.cjs +1 -3
  51. package/dist/rules/requireFileOverview.cjs.map +1 -1
  52. package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -2
  53. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  54. package/dist/rules/requireJsdoc.cjs +3 -6
  55. package/dist/rules/requireJsdoc.cjs.map +1 -1
  56. package/dist/rules/requireParam.cjs +6 -12
  57. package/dist/rules/requireParam.cjs.map +1 -1
  58. package/dist/rules/requireParamName.cjs +1 -2
  59. package/dist/rules/requireParamName.cjs.map +1 -1
  60. package/dist/rules/requireReturns.cjs +1 -2
  61. package/dist/rules/requireReturns.cjs.map +1 -1
  62. package/dist/rules/requireTemplate.cjs +1 -2
  63. package/dist/rules/requireTemplate.cjs.map +1 -1
  64. package/dist/rules/sortTags.cjs +1 -2
  65. package/dist/rules/sortTags.cjs.map +1 -1
  66. package/dist/rules.d.ts +34 -37
  67. package/package.json +11 -11
  68. package/src/index-cjs.js +16 -0
  69. package/src/index-esm.js +0 -2
  70. package/src/index.js +16 -2
  71. package/src/iterateJsdoc.js +13 -0
  72. package/src/jsdocUtils.js +22 -17
  73. package/src/rules/checkLineAlignment.js +1 -2
  74. package/src/rules/checkTagNames.js +19 -0
  75. package/src/rules/convertToJsdocComments.js +2 -4
  76. package/src/rules/emptyTags.js +1 -2
  77. package/src/rules/escapeInlineTags.js +189 -0
  78. package/src/rules/informativeDocs.js +3 -6
  79. package/src/rules/linesBeforeBlock.js +4 -8
  80. package/src/rules/matchDescription.js +2 -4
  81. package/src/rules/matchName.js +1 -2
  82. package/src/rules/multilineBlocks.js +3 -6
  83. package/src/rules/noBadBlocks.js +1 -2
  84. package/src/rules/noTypes.js +1 -2
  85. package/src/rules/noUndefinedTypes.js +7 -1
  86. package/src/rules/requireAsteriskPrefix.js +1 -2
  87. package/src/rules/requireDescriptionCompleteSentence.js +1 -2
  88. package/src/rules/requireFileOverview.js +1 -3
  89. package/src/rules/requireHyphenBeforeParamDescription.js +1 -2
  90. package/src/rules/requireJsdoc.js +3 -6
  91. package/src/rules/requireParam.js +6 -12
  92. package/src/rules/requireParamName.js +1 -2
  93. package/src/rules/requireReturns.js +1 -2
  94. package/src/rules/requireTemplate.js +1 -2
  95. package/src/rules/sortTags.js +1 -2
  96. package/src/rules.d.ts +34 -37
@@ -1 +1 @@
1
- {"version":3,"file":"checkLineAlignment.cjs","names":["_alignTransform","_interopRequireDefault","require","_iterateJsdoc","_commentParser","e","__esModule","default","flow","commentFlow","transforms","checkNotAlignedPerTag","utils","tag","customSpacings","spacerProps","contentProps","mightHaveNamepath","tagMightHaveNamepath","tokens","source","followedBySpace","idx","callbck","nextIndex","slice","some","spacerProp","innerIdx","contentProp","spacePropVal","ret","postHyphenSpacing","postHyphen","exactHyphenSpacing","RegExp","hasNoHyphen","test","description","hasExactHyphenSpacing","ok","contentPropVal","spacerPropVal","spacing","length","fix","entries","padStart","hasSpace","contentPrp","hyphenSpacing","replace","setTag","reportJSDoc","checkAlignment","disableWrapIndent","indent","jsdoc","jsdocNode","preserveMainDescriptionPostDelimiter","report","tags","wrapIndent","transform","alignTransform","transformedJsdoc","comment","value","formatted","stringify","trimStart","fixer","replaceText","_default","exports","iterateJsdoc","context","applicableTags","options","includes","foundTags","getPresentTags","type","name","postDelimiter","line","number","charAt","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperties","properties","postName","postTag","postType","items","module"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import alignTransform from '../alignTransform.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\nimport {\n transforms,\n} from 'comment-parser';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\n/**\n * @typedef {{\n * postDelimiter: import('../iterateJsdoc.js').Integer,\n * postHyphen: import('../iterateJsdoc.js').Integer,\n * postName: import('../iterateJsdoc.js').Integer,\n * postTag: import('../iterateJsdoc.js').Integer,\n * postType: import('../iterateJsdoc.js').Integer,\n * }} CustomSpacings\n */\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {CustomSpacings} customSpacings\n */\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n\n /**\n * @typedef {\"tag\"|\"type\"|\"name\"|\"description\"} ContentProp\n */\n\n /** @type {(\"postDelimiter\"|\"postTag\"|\"postType\"|\"postName\")[]} */\n let spacerProps;\n /** @type {ContentProp[]} */\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n /**\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck]\n */\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const exactHyphenSpacing = new RegExp(`^\\\\s*-\\\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\\\s)`, 'v');\n const hasNoHyphen = !(/^\\s*-(?!$)(?=\\s)/v).test(tokens.description);\n const hasExactHyphenSpacing = exactHyphenSpacing.test(\n tokens.description,\n );\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n }) && (hasNoHyphen || hasExactHyphenSpacing);\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n if (!hasExactHyphenSpacing) {\n const hyphenSpacing = /^\\s*-\\s+/v;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\n/**\n * @param {object} cfg\n * @param {CustomSpacings} cfg.customSpacings\n * @param {string} cfg.indent\n * @param {import('comment-parser').Block} cfg.jsdoc\n * @param {import('eslint').Rule.Node & {\n * range: [number, number]\n * }} cfg.jsdocNode\n * @param {boolean} cfg.preserveMainDescriptionPostDelimiter\n * @param {import('../iterateJsdoc.js').Report} cfg.report\n * @param {string[]} cfg.tags\n * @param {import('../iterateJsdoc.js').Utils} cfg.utils\n * @param {string} cfg.wrapIndent\n * @param {boolean} cfg.disableWrapIndent\n * @returns {void}\n */\nconst checkAlignment = ({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n wrapIndent,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n disableWrapIndent,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n wrapIndent,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' +\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */ (jsdocNode).value + '*/';\n\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n jsdocNode,\n report,\n utils,\n}) => {\n const {\n customSpacings,\n disableWrapIndent = false,\n preserveMainDescriptionPostDelimiter,\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template',\n ],\n wrapIndent = '',\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!(\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */\n (jsdocNode).value.includes('\\n')\n )) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n wrapIndent,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n if (context.options[0] !== 'any') {\n for (const tag of foundTags) {\n checkNotAlignedPerTag(\n utils,\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */\n (tag),\n customSpacings,\n );\n }\n }\n\n for (const tag of foundTags) {\n if (tag.source.length > 1) {\n let idx = 0;\n for (const {\n tokens,\n // Avoid the tag line\n } of tag.source.slice(1)) {\n idx++;\n\n if (\n !tokens.description ||\n // Avoid first lines after multiline type\n tokens.type ||\n tokens.name\n ) {\n continue;\n }\n\n // Don't include a single separating space/tab\n if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {\n utils.reportJSDoc('Expected wrap indent', {\n line: tag.source[0].number + idx,\n }, () => {\n tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;\n });\n return;\n }\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header',\n },\n fixable: 'whitespace',\n schema: [\n {\n description: `If the string value is\n\\`\"always\"\\` then a problem is raised when the lines are not aligned.\nIf it is \\`\"never\"\\` then a problem should be raised when there is more than\none space between each line's parts. If it is \\`\"any\"\\`, no alignment is made.\nDefaults to \\`\"never\"\\`.\n\nNote that in addition to alignment, the \"never\" and \"always\" options will both\nensure that at least one space is present after the asterisk delimiter.`,\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n description: `An object with any of the following spacing keys set to an integer.\nIf a spacing is not defined, it defaults to one.\n`,\n properties: {\n postDelimiter: {\n description: 'Affects spacing after the asterisk (e.g., `* @param`)',\n type: 'integer',\n },\n postHyphen: {\n description: 'Affects spacing after any hyphens in the description (e.g., `* @param {someType} name - A description`)',\n type: 'integer',\n },\n postName: {\n description: 'Affects spacing after the name (e.g., `* @param {someType} name `)',\n type: 'integer',\n },\n postTag: {\n description: 'Affects spacing after the tag (e.g., `* @param `)',\n type: 'integer',\n },\n postType: {\n description: 'Affects spacing after the type (e.g., `* @param {someType} `)',\n type: 'integer',\n },\n },\n type: 'object',\n },\n disableWrapIndent: {\n description: 'Disables `wrapIndent`; existing wrap indentation is preserved without changes.',\n type: 'boolean',\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n description: `A boolean to determine whether to preserve the post-delimiter spacing of the\nmain description. If \\`false\\` or unset, will be set to a single space.`,\n type: 'boolean',\n },\n tags: {\n description: `Use this to change the tags which are sought for alignment changes. Defaults to an array of\n\\`['param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template']\\`.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n wrapIndent: {\n description: `The indent that will be applied for tag text after the first line.\nDefault to the empty string (no indent).`,\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEwB,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB,MAAM;EACJG,IAAI,EAAEC;AACR,CAAC,GAAGC,yBAAU;;AAEd;AACA;AAC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AAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAmB,MAAA,CAAA3B,OAAA,GAAAA,OAAA,CAAAnE,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"checkLineAlignment.cjs","names":["_alignTransform","_interopRequireDefault","require","_iterateJsdoc","_commentParser","e","__esModule","default","flow","commentFlow","transforms","checkNotAlignedPerTag","utils","tag","customSpacings","spacerProps","contentProps","mightHaveNamepath","tagMightHaveNamepath","tokens","source","followedBySpace","idx","callbck","nextIndex","slice","some","spacerProp","innerIdx","contentProp","spacePropVal","ret","postHyphenSpacing","postHyphen","exactHyphenSpacing","RegExp","hasNoHyphen","test","description","hasExactHyphenSpacing","ok","contentPropVal","spacerPropVal","spacing","length","fix","entries","padStart","hasSpace","contentPrp","hyphenSpacing","replace","setTag","reportJSDoc","checkAlignment","disableWrapIndent","indent","jsdoc","jsdocNode","preserveMainDescriptionPostDelimiter","report","tags","wrapIndent","transform","alignTransform","transformedJsdoc","comment","value","formatted","stringify","trimStart","fixer","replaceText","_default","exports","iterateJsdoc","context","applicableTags","options","includes","foundTags","getPresentTags","type","name","postDelimiter","line","number","charAt","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperties","properties","postName","postTag","postType","items","module"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import alignTransform from '../alignTransform.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\nimport {\n transforms,\n} from 'comment-parser';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\n/**\n * @typedef {{\n * postDelimiter: import('../iterateJsdoc.js').Integer,\n * postHyphen: import('../iterateJsdoc.js').Integer,\n * postName: import('../iterateJsdoc.js').Integer,\n * postTag: import('../iterateJsdoc.js').Integer,\n * postType: import('../iterateJsdoc.js').Integer,\n * }} CustomSpacings\n */\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {CustomSpacings} customSpacings\n */\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n\n /**\n * @typedef {\"tag\"|\"type\"|\"name\"|\"description\"} ContentProp\n */\n\n /** @type {(\"postDelimiter\"|\"postTag\"|\"postType\"|\"postName\")[]} */\n let spacerProps;\n /** @type {ContentProp[]} */\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n /**\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck]\n */\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const exactHyphenSpacing = new RegExp(`^\\\\s*-\\\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\\\s)`, 'v');\n const hasNoHyphen = !(/^\\s*-(?!$)(?=\\s)/v).test(tokens.description);\n const hasExactHyphenSpacing = exactHyphenSpacing.test(\n tokens.description,\n );\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n }) && (hasNoHyphen || hasExactHyphenSpacing);\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n if (!hasExactHyphenSpacing) {\n const hyphenSpacing = /^\\s*-\\s+/v;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\n/**\n * @param {object} cfg\n * @param {CustomSpacings} cfg.customSpacings\n * @param {string} cfg.indent\n * @param {import('comment-parser').Block} cfg.jsdoc\n * @param {import('eslint').Rule.Node & {\n * range: [number, number]\n * }} cfg.jsdocNode\n * @param {boolean} cfg.preserveMainDescriptionPostDelimiter\n * @param {import('../iterateJsdoc.js').Report} cfg.report\n * @param {string[]} cfg.tags\n * @param {import('../iterateJsdoc.js').Utils} cfg.utils\n * @param {string} cfg.wrapIndent\n * @param {boolean} cfg.disableWrapIndent\n * @returns {void}\n */\nconst checkAlignment = ({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n wrapIndent,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n disableWrapIndent,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n wrapIndent,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' +\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */ (jsdocNode).value + '*/';\n\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n jsdocNode,\n report,\n utils,\n}) => {\n const {\n customSpacings,\n disableWrapIndent = false,\n preserveMainDescriptionPostDelimiter,\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template',\n ],\n wrapIndent = '',\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!(\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */\n (jsdocNode).value.includes('\\n')\n )) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n wrapIndent,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n if (context.options[0] !== 'any') {\n for (const tag of foundTags) {\n checkNotAlignedPerTag(\n utils,\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */\n (tag),\n customSpacings,\n );\n }\n }\n\n for (const tag of foundTags) {\n if (tag.source.length > 1) {\n let idx = 0;\n for (const {\n tokens,\n // Avoid the tag line\n } of tag.source.slice(1)) {\n idx++;\n\n if (\n !tokens.description ||\n // Avoid first lines after multiline type\n tokens.type ||\n tokens.name\n ) {\n continue;\n }\n\n // Don't include a single separating space/tab\n if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {\n utils.reportJSDoc('Expected wrap indent', {\n line: tag.source[0].number + idx,\n }, () => {\n tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;\n });\n return;\n }\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header',\n },\n fixable: 'whitespace',\n schema: [\n {\n description: `If the string value is\n\\`\"always\"\\` then a problem is raised when the lines are not aligned.\nIf it is \\`\"never\"\\` then a problem should be raised when there is more than\none space between each line's parts. If it is \\`\"any\"\\`, no alignment is made.\nDefaults to \\`\"never\"\\`.\n\nNote that in addition to alignment, the \"never\" and \"always\" options will both\nensure that at least one space is present after the asterisk delimiter.`,\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n description: `An object with any of the following spacing keys set to an integer.\nIf a spacing is not defined, it defaults to one.`,\n properties: {\n postDelimiter: {\n description: 'Affects spacing after the asterisk (e.g., `* @param`)',\n type: 'integer',\n },\n postHyphen: {\n description: 'Affects spacing after any hyphens in the description (e.g., `* @param {someType} name - A description`)',\n type: 'integer',\n },\n postName: {\n description: 'Affects spacing after the name (e.g., `* @param {someType} name `)',\n type: 'integer',\n },\n postTag: {\n description: 'Affects spacing after the tag (e.g., `* @param `)',\n type: 'integer',\n },\n postType: {\n description: 'Affects spacing after the type (e.g., `* @param {someType} `)',\n type: 'integer',\n },\n },\n type: 'object',\n },\n disableWrapIndent: {\n description: 'Disables `wrapIndent`; existing wrap indentation is preserved without changes.',\n type: 'boolean',\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n description: `A boolean to determine whether to preserve the post-delimiter spacing of the\nmain description. If \\`false\\` or unset, will be set to a single space.`,\n type: 'boolean',\n },\n tags: {\n description: `Use this to change the tags which are sought for alignment changes. Defaults to an array of\n\\`['param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template']\\`.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n wrapIndent: {\n description: `The indent that will be applied for tag text after the first line.\nDefault to the empty string (no indent).`,\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEwB,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB,MAAM;EACJG,IAAI,EAAEC;AACR,CAAC,GAAGC,yBAAU;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAGA,CAACC,KAAK,EAAEC,GAAG,EAAEC,cAAc,KAAK;EAC5D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAEE;AACF;AACA;;EAEE;EACA,IAAIC,WAAW;EACf;EACA,IAAIC,YAAY;EAChB,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,oBAAoB,CAACL,GAAG,CAACA,GAAG,CAAC;EAC7D,IAAII,iBAAiB,EAAE;IACrBF,WAAW,GAAG,CACZ,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CACnD;IACDC,YAAY,GAAG,CACb,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CACrC;EACH,CAAC,MAAM;IACLD,WAAW,GAAG,CACZ,eAAe,EAAE,SAAS,EAAE,UAAU,CACvC;IACDC,YAAY,GAAG,CACb,KAAK,EAAE,MAAM,EAAE,aA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C;YACDiB,QAAQ,EAAE;cACR7D,WAAW,EAAE,iEAAiE;cAC9E4C,IAAI,EAAE;YACR;UACF,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD3B,iBAAiB,EAAE;UACjBjB,WAAW,EAAE,gFAAgF;UAC7F4C,IAAI,EAAE;QACR,CAAC;QACDvB,oCAAoC,EAAE;UACpCpD,OAAO,EAAE,KAAK;UACd+B,WAAW,EAAE;AACzB,wEAAwE;UAC5D4C,IAAI,EAAE;QACR,CAAC;QACDrB,IAAI,EAAE;UACJvB,WAAW,EAAE;AACzB,uFAAuF;UAC3E8D,KAAK,EAAE;YACLlB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDpB,UAAU,EAAE;UACVxB,WAAW,EAAE;AACzB,yCAAyC;UAC7B4C,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAmB,MAAA,CAAA3B,OAAA,GAAAA,OAAA,CAAAnE,OAAA","ignoreList":[]}
@@ -27,12 +27,14 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
27
27
  * @type {{
28
28
  * definedTags: string[],
29
29
  * enableFixer: boolean,
30
+ * inlineTags: string[],
30
31
  * jsxTags: boolean,
31
32
  * typed: boolean
32
33
  }} */
33
34
  {
34
35
  definedTags = [],
35
36
  enableFixer = true,
37
+ inlineTags = ['link', 'linkcode', 'linkplain', 'tutorial'],
36
38
  jsxTags,
37
39
  typed
38
40
  } = context.options[0] || {};
@@ -178,6 +180,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
178
180
  report(`Invalid JSDoc tag name "${tagName}".`, null, jsdocTag);
179
181
  }
180
182
  }
183
+ for (const inlineTag of utils.getInlineTags()) {
184
+ if (!inlineTags.includes(inlineTag.tag)) {
185
+ report(`Invalid JSDoc inline tag name "${inlineTag.tag}"`, null, inlineTag);
186
+ }
187
+ }
181
188
  }, {
182
189
  iterateAllJsdocs: true,
183
190
  meta: {
@@ -207,6 +214,15 @@ The format is as follows:
207
214
  description: 'Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#typed).',
208
215
  type: 'boolean'
209
216
  },
217
+ inlineTags: {
218
+ description: `List of tags to allow inline.
219
+
220
+ Defaults to array of \`'link', 'linkcode', 'linkplain', 'tutorial'\``,
221
+ items: {
222
+ type: 'string'
223
+ },
224
+ type: 'array'
225
+ },
210
226
  jsxTags: {
211
227
  description: `If this is set to \`true\`, all of the following tags used to control JSX output are allowed:
212
228
 
@@ -1 +1 @@
1
- {"version":3,"file":"checkTagNames.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_escapeStringRegexp","e","__esModule","default","jsxTagNames","Set","typedTagsAlwaysUnnecessary","typedTagsNeedingName","typedTagsUnnecessaryOutsideDeclare","_default","exports","iterateJsdoc","context","jsdoc","jsdocNode","node","report","settings","sourceCode","utils","definedTags","enableFixer","jsxTags","typed","options","definedPreferredTags","structuredTags","tagNamePreference","definedStructuredTags","Object","keys","definedNonPreferredTags","length","values","map","preferredTag","undefined","reportSettings","replacement","filter","Boolean","isInAmbientContext","subNode","type","getFilename","endsWith","declare","parent","tagIsRedundantWhenTyped","jsdocTag","has","tag","includes","reportWithTagRemovalFixer","message","tagIndex","additionalTagChanges","reportJSDoc","description","trim","changeTag","postType","removeTag","removeEmptyBlock","checkTagForTypedValidity","postTag","name","tags","tagName","validTags","isValidTag","preferredTagName","getPreferredTagName","allowObjectReturn","defaultMessage","fixer","getText","replace","RegExp","escapeStringRegexp","replaceText","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/checkTagNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\n// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/\nconst jsxTagNames = new Set([\n 'jsx',\n 'jsxFrag',\n 'jsxImportSource',\n 'jsxRuntime',\n]);\n\nconst typedTagsAlwaysUnnecessary = new Set([\n 'augments',\n 'callback',\n 'class',\n 'enum',\n 'implements',\n 'private',\n 'property',\n 'protected',\n 'public',\n 'readonly',\n 'this',\n 'type',\n 'typedef',\n]);\n\nconst typedTagsNeedingName = new Set([\n 'template',\n]);\n\nconst typedTagsUnnecessaryOutsideDeclare = new Set([\n 'abstract',\n 'access',\n 'class',\n 'constant',\n 'constructs',\n 'default',\n 'enum',\n 'export',\n 'exports',\n 'function',\n 'global',\n 'inherits',\n 'instance',\n 'interface',\n 'member',\n 'memberof',\n 'memberOf',\n 'method',\n 'mixes',\n 'mixin',\n 'module',\n 'name',\n 'namespace',\n 'override',\n 'property',\n 'requires',\n 'static',\n 'this',\n]);\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const\n /**\n * @type {{\n * definedTags: string[],\n * enableFixer: boolean,\n * jsxTags: boolean,\n * typed: boolean\n }} */ {\n definedTags = [],\n enableFixer = true,\n jsxTags,\n typed,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTags = [];\n const {\n structuredTags,\n tagNamePreference,\n } = settings;\n const definedStructuredTags = Object.keys(structuredTags);\n const definedNonPreferredTags = Object.keys(tagNamePreference);\n if (definedNonPreferredTags.length) {\n definedPreferredTags = Object.values(tagNamePreference).map((preferredTag) => {\n if (typeof preferredTag === 'string') {\n // May become an empty string but will be filtered out below\n return preferredTag;\n }\n\n if (!preferredTag) {\n return undefined;\n }\n\n if (typeof preferredTag !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.',\n );\n }\n\n return preferredTag.replacement;\n })\n .filter(Boolean);\n }\n\n /**\n * @param {import('eslint').Rule.Node} subNode\n * @returns {boolean}\n */\n const isInAmbientContext = (subNode) => {\n return subNode.type === 'Program' ?\n context.getFilename().endsWith('.d.ts') :\n Boolean(\n /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */ (\n subNode\n ).declare,\n ) || isInAmbientContext(subNode.parent);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @returns {boolean}\n */\n const tagIsRedundantWhenTyped = (jsdocTag) => {\n if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) {\n return false;\n }\n\n if (jsdocTag.tag === 'default') {\n return false;\n }\n\n if (node === null) {\n return false;\n }\n\n if (context.getFilename().endsWith('.d.ts') && [\n null, 'Program', undefined,\n ].includes(node?.parent?.type)) {\n return false;\n }\n\n if (isInAmbientContext(/** @type {import('eslint').Rule.Node} */ (node))) {\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} message\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {Partial<import('comment-parser').Tokens>} [additionalTagChanges]\n * @returns {void}\n */\n const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => {\n utils.reportJSDoc(message, jsdocTag, enableFixer ? () => {\n if (jsdocTag.description.trim()) {\n utils.changeTag(jsdocTag, {\n postType: '',\n type: '',\n ...additionalTagChanges,\n });\n } else {\n utils.removeTag(tagIndex, {\n removeEmptyBlock: true,\n });\n }\n } : null, true);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @returns {boolean}\n */\n const checkTagForTypedValidity = (jsdocTag, tagIndex) => {\n if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n {\n postTag: '',\n tag: '',\n },\n );\n return true;\n }\n\n if (tagIsRedundantWhenTyped(jsdocTag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant outside of ambient (\\`declare\\`/\\`.d.ts\\`) contexts when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' without a name is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n return false;\n };\n\n for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) {\n const jsdocTag = jsdoc.tags[tagIndex];\n const tagName = jsdocTag.tag;\n if (jsxTags && jsxTagNames.has(tagName)) {\n continue;\n }\n\n if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) {\n continue;\n }\n\n const validTags = [\n ...definedTags,\n ...(/** @type {string[]} */ (definedPreferredTags)),\n ...definedNonPreferredTags,\n ...definedStructuredTags,\n ...typed ? typedTagsNeedingName : [],\n ];\n\n if (utils.isValidTag(tagName, validTags)) {\n let preferredTagName = utils.getPreferredTagName({\n allowObjectReturn: true,\n defaultMessage: `Blacklisted tag found (\\`@${tagName}\\`)`,\n tagName,\n });\n if (!preferredTagName) {\n continue;\n }\n\n let message;\n if (typeof preferredTagName === 'object') {\n ({\n message,\n replacement: preferredTagName,\n } = /** @type {{message: string; replacement?: string | undefined;}} */ (\n preferredTagName\n ));\n }\n\n if (!message) {\n message = `Invalid JSDoc tag (preference). Replace \"${tagName}\" JSDoc tag with \"${preferredTagName}\".`;\n }\n\n if (preferredTagName !== tagName) {\n report(message, (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).replace(\n new RegExp(`@${escapeStringRegexp(tagName)}\\\\b`, 'v'),\n `@${preferredTagName}`,\n );\n\n return fixer.replaceText(jsdocNode, replacement);\n }, jsdocTag);\n }\n } else {\n report(`Invalid JSDoc tag name \"${tagName}\".`, null, jsdocTag);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid block tag names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTags: {\n description: `Use an array of \\`definedTags\\` strings to configure additional, allowed tags.\nThe format is as follows:\n\n\\`\\`\\`json\n{\n \"definedTags\": [\"note\", \"record\"]\n}\n\\`\\`\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#typed).',\n type: 'boolean',\n },\n jsxTags: {\n description: `If this is set to \\`true\\`, all of the following tags used to control JSX output are allowed:\n\n\\`\\`\\`\njsx\njsxFrag\njsxImportSource\njsxRuntime\n\\`\\`\\`\n\nFor more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).`,\n type: 'boolean',\n },\n typed: {\n description: `If this is set to \\`true\\`, additionally checks for tag names that are redundant when using a type checker such as TypeScript.\n\nThese tags are always unnecessary when using TypeScript or similar:\n\n\\`\\`\\`\naugments\ncallback\nclass\nenum\nimplements\nprivate\nproperty\nprotected\npublic\nreadonly\nthis\ntype\ntypedef\n\\`\\`\\`\n\nThese tags are unnecessary except when inside a TypeScript \\`declare\\` context:\n\n\\`\\`\\`\nabstract\naccess\nclass\nconstant\nconstructs\ndefault\nenum\nexport\nexports\nfunction\nglobal\ninherits\ninstance\ninterface\nmember\nmemberof\nmemberOf\nmethod\nmixes\nmixin\nmodule\nname\nnamespace\noverride\nproperty\nrequires\nstatic\nthis\n\\`\\`\\``,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD;AACA,MAAMG,WAAW,GAAG,IAAIC,GAAG,CAAC,CAC1B,KAAK,EACL,SAAS,EACT,iBAAi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W,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKf,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA+C,MAAA,CAAAhF,OAAA,GAAAA,OAAA,CAAAP,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"checkTagNames.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_escapeStringRegexp","e","__esModule","default","jsxTagNames","Set","typedTagsAlwaysUnnecessary","typedTagsNeedingName","typedTagsUnnecessaryOutsideDeclare","_default","exports","iterateJsdoc","context","jsdoc","jsdocNode","node","report","settings","sourceCode","utils","definedTags","enableFixer","inlineTags","jsxTags","typed","options","definedPreferredTags","structuredTags","tagNamePreference","definedStructuredTags","Object","keys","definedNonPreferredTags","length","values","map","preferredTag","undefined","reportSettings","replacement","filter","Boolean","isInAmbientContext","subNode","type","getFilename","endsWith","declare","parent","tagIsRedundantWhenTyped","jsdocTag","has","tag","includes","reportWithTagRemovalFixer","message","tagIndex","additionalTagChanges","reportJSDoc","description","trim","changeTag","postType","removeTag","removeEmptyBlock","checkTagForTypedValidity","postTag","name","tags","tagName","validTags","isValidTag","preferredTagName","getPreferredTagName","allowObjectReturn","defaultMessage","fixer","getText","replace","RegExp","escapeStringRegexp","replaceText","inlineTag","getInlineTags","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/checkTagNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\n// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/\nconst jsxTagNames = new Set([\n 'jsx',\n 'jsxFrag',\n 'jsxImportSource',\n 'jsxRuntime',\n]);\n\nconst typedTagsAlwaysUnnecessary = new Set([\n 'augments',\n 'callback',\n 'class',\n 'enum',\n 'implements',\n 'private',\n 'property',\n 'protected',\n 'public',\n 'readonly',\n 'this',\n 'type',\n 'typedef',\n]);\n\nconst typedTagsNeedingName = new Set([\n 'template',\n]);\n\nconst typedTagsUnnecessaryOutsideDeclare = new Set([\n 'abstract',\n 'access',\n 'class',\n 'constant',\n 'constructs',\n 'default',\n 'enum',\n 'export',\n 'exports',\n 'function',\n 'global',\n 'inherits',\n 'instance',\n 'interface',\n 'member',\n 'memberof',\n 'memberOf',\n 'method',\n 'mixes',\n 'mixin',\n 'module',\n 'name',\n 'namespace',\n 'override',\n 'property',\n 'requires',\n 'static',\n 'this',\n]);\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const\n /**\n * @type {{\n * definedTags: string[],\n * enableFixer: boolean,\n * inlineTags: string[],\n * jsxTags: boolean,\n * typed: boolean\n }} */ {\n definedTags = [],\n enableFixer = true,\n inlineTags = [\n 'link', 'linkcode', 'linkplain', 'tutorial',\n ],\n jsxTags,\n typed,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTags = [];\n const {\n structuredTags,\n tagNamePreference,\n } = settings;\n const definedStructuredTags = Object.keys(structuredTags);\n const definedNonPreferredTags = Object.keys(tagNamePreference);\n if (definedNonPreferredTags.length) {\n definedPreferredTags = Object.values(tagNamePreference).map((preferredTag) => {\n if (typeof preferredTag === 'string') {\n // May become an empty string but will be filtered out below\n return preferredTag;\n }\n\n if (!preferredTag) {\n return undefined;\n }\n\n if (typeof preferredTag !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.',\n );\n }\n\n return preferredTag.replacement;\n })\n .filter(Boolean);\n }\n\n /**\n * @param {import('eslint').Rule.Node} subNode\n * @returns {boolean}\n */\n const isInAmbientContext = (subNode) => {\n return subNode.type === 'Program' ?\n context.getFilename().endsWith('.d.ts') :\n Boolean(\n /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */ (\n subNode\n ).declare,\n ) || isInAmbientContext(subNode.parent);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @returns {boolean}\n */\n const tagIsRedundantWhenTyped = (jsdocTag) => {\n if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) {\n return false;\n }\n\n if (jsdocTag.tag === 'default') {\n return false;\n }\n\n if (node === null) {\n return false;\n }\n\n if (context.getFilename().endsWith('.d.ts') && [\n null, 'Program', undefined,\n ].includes(node?.parent?.type)) {\n return false;\n }\n\n if (isInAmbientContext(/** @type {import('eslint').Rule.Node} */ (node))) {\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} message\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {Partial<import('comment-parser').Tokens>} [additionalTagChanges]\n * @returns {void}\n */\n const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => {\n utils.reportJSDoc(message, jsdocTag, enableFixer ? () => {\n if (jsdocTag.description.trim()) {\n utils.changeTag(jsdocTag, {\n postType: '',\n type: '',\n ...additionalTagChanges,\n });\n } else {\n utils.removeTag(tagIndex, {\n removeEmptyBlock: true,\n });\n }\n } : null, true);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @returns {boolean}\n */\n const checkTagForTypedValidity = (jsdocTag, tagIndex) => {\n if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n {\n postTag: '',\n tag: '',\n },\n );\n return true;\n }\n\n if (tagIsRedundantWhenTyped(jsdocTag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant outside of ambient (\\`declare\\`/\\`.d.ts\\`) contexts when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' without a name is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n return false;\n };\n\n for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) {\n const jsdocTag = jsdoc.tags[tagIndex];\n const tagName = jsdocTag.tag;\n if (jsxTags && jsxTagNames.has(tagName)) {\n continue;\n }\n\n if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) {\n continue;\n }\n\n const validTags = [\n ...definedTags,\n ...(/** @type {string[]} */ (definedPreferredTags)),\n ...definedNonPreferredTags,\n ...definedStructuredTags,\n ...typed ? typedTagsNeedingName : [],\n ];\n\n if (utils.isValidTag(tagName, validTags)) {\n let preferredTagName = utils.getPreferredTagName({\n allowObjectReturn: true,\n defaultMessage: `Blacklisted tag found (\\`@${tagName}\\`)`,\n tagName,\n });\n if (!preferredTagName) {\n continue;\n }\n\n let message;\n if (typeof preferredTagName === 'object') {\n ({\n message,\n replacement: preferredTagName,\n } = /** @type {{message: string; replacement?: string | undefined;}} */ (\n preferredTagName\n ));\n }\n\n if (!message) {\n message = `Invalid JSDoc tag (preference). Replace \"${tagName}\" JSDoc tag with \"${preferredTagName}\".`;\n }\n\n if (preferredTagName !== tagName) {\n report(message, (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).replace(\n new RegExp(`@${escapeStringRegexp(tagName)}\\\\b`, 'v'),\n `@${preferredTagName}`,\n );\n\n return fixer.replaceText(jsdocNode, replacement);\n }, jsdocTag);\n }\n } else {\n report(`Invalid JSDoc tag name \"${tagName}\".`, null, jsdocTag);\n }\n }\n\n for (const inlineTag of utils.getInlineTags()) {\n if (!inlineTags.includes(inlineTag.tag)) {\n report(`Invalid JSDoc inline tag name \"${inlineTag.tag}\"`, null, inlineTag);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid block tag names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTags: {\n description: `Use an array of \\`definedTags\\` strings to configure additional, allowed tags.\nThe format is as follows:\n\n\\`\\`\\`json\n{\n \"definedTags\": [\"note\", \"record\"]\n}\n\\`\\`\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#typed).',\n type: 'boolean',\n },\n inlineTags: {\n description: `List of tags to allow inline.\n\nDefaults to array of \\`'link', 'linkcode', 'linkplain', 'tutorial'\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n jsxTags: {\n description: `If this is set to \\`true\\`, all of the following tags used to control JSX output are allowed:\n\n\\`\\`\\`\njsx\njsxFrag\njsxImportSource\njsxRuntime\n\\`\\`\\`\n\nFor more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).`,\n type: 'boolean',\n },\n typed: {\n description: `If this is set to \\`true\\`, additionally checks for tag names that are redundant when using a type checker such as TypeScript.\n\nThese tags are always unnecessary when using TypeScript or similar:\n\n\\`\\`\\`\naugments\ncallback\nclass\nenum\nimplements\nprivate\nproperty\nprotected\npublic\nreadonly\nthis\ntype\ntypedef\n\\`\\`\\`\n\nThese tags are unnecessary except when inside a TypeScript \\`declare\\` context:\n\n\\`\\`\\`\nabstract\naccess\nclass\nconstant\nconstructs\ndefault\nenum\nexport\nexports\nfunction\nglobal\ninherits\ninstance\ninterface\nmember\nmemberof\nmemberOf\nmethod\nmixes\nmixin\nmodule\nname\nnamespace\noverride\nproperty\nrequires\nstatic\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pC,MAAM,CAAC,kCAAkCkE,SAAS,CAAC9B,GAAG,GAAG,EAAE,IAAI,EAAE8B,SAAS,CAAC;IAC7E;EACF;AACF,CAAC,EAAE;EACDE,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJ3B,WAAW,EAAE,kCAAkC;MAC/C4B,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVvE,WAAW,EAAE;UACXuC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKiC,KAAK,EAAE;YACLhD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,WAAW,EAAE;UACXsC,WAAW,EAAE,uGAAuG;UACpHf,IAAI,EAAE;QACR,CAAC;QACDtB,UAAU,EAAE;UACVqC,WAAW,EAAE;AACzB;AACA,qEAAqE;UACzDiC,KAAK,EAAE;YACLhD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrB,OAAO,EAAE;UACPoC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kHAAkH;UACtGf,IAAI,EAAE;QACR,CAAC;QACDpB,KAAK,EAAE;UACLmC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKf,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiD,MAAA,CAAAnF,OAAA,GAAAA,OAAA,CAAAP,OAAA","ignoreList":[]}
@@ -243,8 +243,7 @@ Supplying your own value overrides the defaults.`,
243
243
  Can either be strings or an object with a \`context\` string and an optional, default \`false\` \`inlineCommentBlock\` boolean.
244
244
 
245
245
  Defaults to \`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
246
- \`FunctionExpression\`, \`TSDeclareFunction\`.
247
- `,
246
+ \`FunctionExpression\`, \`TSDeclareFunction\`.`,
248
247
  items: {
249
248
  anyOf: [{
250
249
  type: 'string'
@@ -332,8 +331,7 @@ be converted to \`multi\` style JSDoc comments.)
332
331
  /** Some text */
333
332
  \`\`\`
334
333
 
335
- Defaults to \`multi\`.
336
- `,
334
+ Defaults to \`multi\`.`,
337
335
  enum: ['multi', 'single'],
338
336
  type: 'string'
339
337
  },
@@ -1 +1 @@
1
- {"version":3,"file":"convertToJsdocComments.cjs","names":["_iterateJsdoc","require","_jsdocUtils","_jsdoccomment","_default","exports","default","create","context","sourceCode","getSourceCode","settings","getSettings","allowedPrefixes","contexts","contextsAfter","contextsBeforeAndAfter","enableFixer","enforceJsdocLineStyle","lineOrBlockStyle","options","reportingNonJsdoc","report","messageId","comment","node","fixer","loc","end","column","line","start","fix","getFixer","addComment","ctxts","lines","minLines","maxLines","baseNode","getReducedASTNode","decorator","getDecorator","indent","getIndent","text","getText","inlineCommentBlock","find","contxt","ctxt","type","reportings","checkNonJsdoc","_info","_handler","getNonJsdocComment","some","prefix","value","trimStart","startsWith","commentToAdd","insertion","trim","trimEnd","repeat","replaceText","checkNonJsdocAfter","getFollowingComment","slice","remove","insertTextBefore","parent","getContextObject","enforcedContexts","meta","docs","description","url","fixable","messages","blockCommentsJsdocStyle","lineCommentsJsdocStyle","schema","additionalProperties","properties","items","anyOf","enum","module"],"sources":["../../src/rules/convertToJsdocComments.js"],"sourcesContent":["import {\n getSettings,\n} from '../iterateJsdoc.js';\nimport {\n enforcedContexts,\n getContextObject,\n getIndent,\n} from '../jsdocUtils.js';\nimport {\n getDecorator,\n getFollowingComment,\n getNonJsdocComment,\n getReducedASTNode,\n} from '@es-joy/jsdoccomment';\n\n/** @type {import('eslint').Rule.RuleModule} */\nexport default {\n create (context) {\n /**\n * @typedef {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} Token\n */\n\n /**\n * @callback AddComment\n * @param {boolean|undefined} inlineCommentBlock\n * @param {Token} comment\n * @param {string} indent\n * @param {number} lines\n * @param {import('eslint').Rule.RuleFixer} fixer\n */\n\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n sourceCode = context.getSourceCode(),\n } = context;\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n allowedPrefixes = [\n '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',\n ],\n contexts = settings.contexts || [],\n contextsAfter = /** @type {string[]} */ ([]),\n contextsBeforeAndAfter = [\n 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',\n ],\n enableFixer = true,\n enforceJsdocLineStyle = 'multi',\n lineOrBlockStyle = 'both',\n } = context.options[0] ?? {};\n\n let reportingNonJsdoc = false;\n\n /**\n * @param {string} messageId\n * @param {import('estree').Comment|Token} comment\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').Rule.ReportFixer} fixer\n */\n const report = (messageId, comment, node, fixer) => {\n const loc = {\n end: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n start: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n };\n\n context.report({\n fix: enableFixer ? fixer : null,\n loc,\n messageId,\n node,\n });\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const getFixer = (node, comment, addComment, ctxts) => {\n return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n // Default to one line break if the `minLines`/`maxLines` settings allow\n const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;\n let baseNode =\n /**\n * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}\n */ (\n getReducedASTNode(node, sourceCode)\n );\n\n const decorator = getDecorator(\n /** @type {import('eslint').Rule.Node} */\n (baseNode),\n );\n if (decorator) {\n baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (\n decorator\n );\n }\n\n const indent = getIndent({\n text: sourceCode.getText(\n /** @type {import('eslint').Rule.Node} */ (baseNode),\n /** @type {import('eslint').AST.SourceLocation} */\n (\n /** @type {import('eslint').Rule.Node} */ (baseNode).loc\n ).start.column,\n ),\n });\n\n const {\n inlineCommentBlock,\n } =\n /**\n * @type {{\n * context: string,\n * inlineCommentBlock: boolean,\n * minLineCount: import('../iterateJsdoc.js').Integer\n * }[]}\n */ (ctxts).find((contxt) => {\n if (typeof contxt === 'string') {\n return false;\n }\n\n const {\n context: ctxt,\n } = contxt;\n return ctxt === node.type;\n }) || {};\n\n return addComment(inlineCommentBlock, comment, indent, lines, fixer);\n };\n };\n\n /**\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {import('eslint').Rule.Node} node\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const reportings = (comment, node, addComment, ctxts) => {\n const fixer = getFixer(node, comment, addComment, ctxts);\n\n if (comment.type === 'Block') {\n if (lineOrBlockStyle === 'line') {\n return;\n }\n\n report('blockCommentsJsdocStyle', comment, node, fixer);\n return;\n }\n\n if (comment.type === 'Line') {\n if (lineOrBlockStyle === 'block') {\n return;\n }\n\n report('lineCommentsJsdocStyle', comment, node, fixer);\n }\n };\n\n /**\n * @type {import('../iterateJsdoc.js').CheckJsdoc}\n */\n const checkNonJsdoc = (_info, _handler, node) => {\n const comment = getNonJsdocComment(sourceCode, node, settings);\n\n if (\n !comment ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n reportingNonJsdoc = true;\n\n /** @type {AddComment} */\n // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}`;\n\n return fixer.replaceText(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n insertion,\n );\n };\n\n reportings(comment, node, addComment, contexts);\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const checkNonJsdocAfter = (node, ctxts) => {\n const comment = getFollowingComment(sourceCode, node);\n\n if (\n !comment ||\n comment.value.startsWith('*') ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n /** @type {AddComment} */\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}${lines ? `\\n${indent.slice(1)}` : ' '}`;\n\n return [\n fixer.remove(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n ), fixer.insertTextBefore(\n node.type === 'VariableDeclarator' ? node.parent : node,\n insertion,\n ),\n ];\n };\n\n reportings(comment, node, addComment, ctxts);\n };\n\n // Todo: add contexts to check after (and handle if want both before and after)\n return {\n ...getContextObject(\n enforcedContexts(context, true, settings),\n checkNonJsdoc,\n ),\n ...getContextObject(\n contextsAfter,\n (_info, _handler, node) => {\n checkNonJsdocAfter(node, contextsAfter);\n },\n ),\n ...getContextObject(\n contextsBeforeAndAfter,\n (_info, _handler, node) => {\n checkNonJsdoc({}, null, node);\n if (!reportingNonJsdoc) {\n checkNonJsdocAfter(node, contextsBeforeAndAfter);\n }\n },\n ),\n };\n },\n meta: {\n docs: {\n description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',\n },\n\n fixable: 'code',\n\n messages: {\n blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',\n lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedPrefixes: {\n description: `An array of prefixes to allow at the beginning of a comment.\n\nDefaults to \\`['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-']\\`.\n\nSupplying your own value overrides the defaults.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n contexts: {\n description: `The contexts array which will be checked for preceding content.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to \\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`, \\`TSDeclareFunction\\`.\n`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsAfter: {\n description: `The contexts array which will be checked for content on the same line after.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to an empty array.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsBeforeAndAfter: {\n description: `The contexts array which will be checked for content before and on the same\nline after.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to \\`VariableDeclarator\\`, \\`TSPropertySignature\\`, \\`PropertyDefinition\\`.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable fixing.',\n type: 'boolean',\n },\n enforceJsdocLineStyle: {\n description: `What policy to enforce on the conversion of non-JSDoc comments without\nline breaks. (Non-JSDoc (mulitline) comments with line breaks will always\nbe converted to \\`multi\\` style JSDoc comments.)\n\n- \\`multi\\` - Convert to multi-line style\n\\`\\`\\`js\n/**\n * Some text\n */\n\\`\\`\\`\n- \\`single\\` - Convert to single-line style\n\\`\\`\\`js\n/** Some text */\n\\`\\`\\`\n\nDefaults to \\`multi\\`.\n`,\n enum: [\n 'multi', 'single',\n ],\n type: 'string',\n },\n lineOrBlockStyle: {\n description: `What style of comments to which to apply JSDoc conversion.\n\n- \\`block\\` - Applies to block-style comments (\\`/* ... */\\`)\n- \\`line\\` - Applies to line-style comments (\\`// ...\\`)\n- \\`both\\` - Applies to both block and line-style comments\n\nDefaults to \\`both\\`.`,\n enum: [\n 'block', 'line', 'both',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n};\n"],"mappings":";;;;;;AAAA,I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oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV9E,OAAO,EAAE;kBACP2C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDlC,WAAW,EAAE;UACX6D,WAAW,EAAE,mCAAmC;UAChD3B,IAAI,EAAE;QACR,CAAC;QACDjC,qBAAqB,EAAE;UACrB4D,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACWW,IAAI,EAAE,CACJ,OAAO,EAAE,QAAQ,CAClB;UACDtC,IAAI,EAAE;QACR,CAAC;QACDhC,gBAAgB,EAAE;UAChB2D,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,sBAAsB;UACVW,IAAI,EAAE,CACJ,OAAO,EAAE,MAAM,EAAE,MAAM,CACxB;UACDtC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC;AAAAuC,MAAA,CAAArF,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"convertToJsdocComments.cjs","names":["_iterateJsdoc","require","_jsdocUtils","_jsdoccomment","_default","exports","default","create","context","sourceCode","getSourceCode","settings","getSettings","allowedPrefixes","contexts","contextsAfter","contextsBeforeAndAfter","enableFixer","enforceJsdocLineStyle","lineOrBlockStyle","options","reportingNonJsdoc","report","messageId","comment","node","fixer","loc","end","column","line","start","fix","getFixer","addComment","ctxts","lines","minLines","maxLines","baseNode","getReducedASTNode","decorator","getDecorator","indent","getIndent","text","getText","inlineCommentBlock","find","contxt","ctxt","type","reportings","checkNonJsdoc","_info","_handler","getNonJsdocComment","some","prefix","value","trimStart","startsWith","commentToAdd","insertion","trim","trimEnd","repeat","replaceText","checkNonJsdocAfter","getFollowingComment","slice","remove","insertTextBefore","parent","getContextObject","enforcedContexts","meta","docs","description","url","fixable","messages","blockCommentsJsdocStyle","lineCommentsJsdocStyle","schema","additionalProperties","properties","items","anyOf","enum","module"],"sources":["../../src/rules/convertToJsdocComments.js"],"sourcesContent":["import {\n getSettings,\n} from '../iterateJsdoc.js';\nimport {\n enforcedContexts,\n getContextObject,\n getIndent,\n} from '../jsdocUtils.js';\nimport {\n getDecorator,\n getFollowingComment,\n getNonJsdocComment,\n getReducedASTNode,\n} from '@es-joy/jsdoccomment';\n\n/** @type {import('eslint').Rule.RuleModule} */\nexport default {\n create (context) {\n /**\n * @typedef {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} Token\n */\n\n /**\n * @callback AddComment\n * @param {boolean|undefined} inlineCommentBlock\n * @param {Token} comment\n * @param {string} indent\n * @param {number} lines\n * @param {import('eslint').Rule.RuleFixer} fixer\n */\n\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n sourceCode = context.getSourceCode(),\n } = context;\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n allowedPrefixes = [\n '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',\n ],\n contexts = settings.contexts || [],\n contextsAfter = /** @type {string[]} */ ([]),\n contextsBeforeAndAfter = [\n 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',\n ],\n enableFixer = true,\n enforceJsdocLineStyle = 'multi',\n lineOrBlockStyle = 'both',\n } = context.options[0] ?? {};\n\n let reportingNonJsdoc = false;\n\n /**\n * @param {string} messageId\n * @param {import('estree').Comment|Token} comment\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').Rule.ReportFixer} fixer\n */\n const report = (messageId, comment, node, fixer) => {\n const loc = {\n end: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n start: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n };\n\n context.report({\n fix: enableFixer ? fixer : null,\n loc,\n messageId,\n node,\n });\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const getFixer = (node, comment, addComment, ctxts) => {\n return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n // Default to one line break if the `minLines`/`maxLines` settings allow\n const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;\n let baseNode =\n /**\n * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}\n */ (\n getReducedASTNode(node, sourceCode)\n );\n\n const decorator = getDecorator(\n /** @type {import('eslint').Rule.Node} */\n (baseNode),\n );\n if (decorator) {\n baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (\n decorator\n );\n }\n\n const indent = getIndent({\n text: sourceCode.getText(\n /** @type {import('eslint').Rule.Node} */ (baseNode),\n /** @type {import('eslint').AST.SourceLocation} */\n (\n /** @type {import('eslint').Rule.Node} */ (baseNode).loc\n ).start.column,\n ),\n });\n\n const {\n inlineCommentBlock,\n } =\n /**\n * @type {{\n * context: string,\n * inlineCommentBlock: boolean,\n * minLineCount: import('../iterateJsdoc.js').Integer\n * }[]}\n */ (ctxts).find((contxt) => {\n if (typeof contxt === 'string') {\n return false;\n }\n\n const {\n context: ctxt,\n } = contxt;\n return ctxt === node.type;\n }) || {};\n\n return addComment(inlineCommentBlock, comment, indent, lines, fixer);\n };\n };\n\n /**\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {import('eslint').Rule.Node} node\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const reportings = (comment, node, addComment, ctxts) => {\n const fixer = getFixer(node, comment, addComment, ctxts);\n\n if (comment.type === 'Block') {\n if (lineOrBlockStyle === 'line') {\n return;\n }\n\n report('blockCommentsJsdocStyle', comment, node, fixer);\n return;\n }\n\n if (comment.type === 'Line') {\n if (lineOrBlockStyle === 'block') {\n return;\n }\n\n report('lineCommentsJsdocStyle', comment, node, fixer);\n }\n };\n\n /**\n * @type {import('../iterateJsdoc.js').CheckJsdoc}\n */\n const checkNonJsdoc = (_info, _handler, node) => {\n const comment = getNonJsdocComment(sourceCode, node, settings);\n\n if (\n !comment ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n reportingNonJsdoc = true;\n\n /** @type {AddComment} */\n // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}`;\n\n return fixer.replaceText(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n insertion,\n );\n };\n\n reportings(comment, node, addComment, contexts);\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const checkNonJsdocAfter = (node, ctxts) => {\n const comment = getFollowingComment(sourceCode, node);\n\n if (\n !comment ||\n comment.value.startsWith('*') ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n /** @type {AddComment} */\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}${lines ? `\\n${indent.slice(1)}` : ' '}`;\n\n return [\n fixer.remove(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n ), fixer.insertTextBefore(\n node.type === 'VariableDeclarator' ? node.parent : node,\n insertion,\n ),\n ];\n };\n\n reportings(comment, node, addComment, ctxts);\n };\n\n // Todo: add contexts to check after (and handle if want both before and after)\n return {\n ...getContextObject(\n enforcedContexts(context, true, settings),\n checkNonJsdoc,\n ),\n ...getContextObject(\n contextsAfter,\n (_info, _handler, node) => {\n checkNonJsdocAfter(node, contextsAfter);\n },\n ),\n ...getContextObject(\n contextsBeforeAndAfter,\n (_info, _handler, node) => {\n checkNonJsdoc({}, null, node);\n if (!reportingNonJsdoc) {\n checkNonJsdocAfter(node, contextsBeforeAndAfter);\n }\n },\n ),\n };\n },\n meta: {\n docs: {\n description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',\n },\n\n fixable: 'code',\n\n messages: {\n blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',\n lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedPrefixes: {\n description: `An array of prefixes to allow at the beginning of a comment.\n\nDefaults to \\`['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-']\\`.\n\nSupplying your own value overrides the defaults.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n contexts: {\n description: `The contexts array which will be checked for preceding content.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to \\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`, \\`TSDeclareFunction\\`.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsAfter: {\n description: `The contexts array which will be checked for content on the same line after.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to an empty array.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsBeforeAndAfter: {\n description: `The contexts array which will be checked for content before and on the same\nline after.\n\nCan either be strings or an object with a \\`context\\` string and an optional, default \\`false\\` \\`inlineCommentBlock\\` boolean.\n\nDefaults to \\`VariableDeclarator\\`, \\`TSPropertySignature\\`, \\`PropertyDefinition\\`.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable fixing.',\n type: 'boolean',\n },\n enforceJsdocLineStyle: {\n description: `What policy to enforce on the conversion of non-JSDoc comments without\nline breaks. (Non-JSDoc (mulitline) comments with line breaks will always\nbe converted to \\`multi\\` style JSDoc comments.)\n\n- \\`multi\\` - Convert to multi-line style\n\\`\\`\\`js\n/**\n * Some text\n */\n\\`\\`\\`\n- \\`single\\` - Convert to single-line style\n\\`\\`\\`js\n/** Some text */\n\\`\\`\\`\n\nDefaults to \\`multi\\`.`,\n enum: [\n 'multi', 'single',\n ],\n type: 'string',\n },\n lineOrBlockStyle: {\n description: `What style of comments to which to apply JSDoc conversion.\n\n- \\`block\\` - Applies to block-style comments (\\`/* ... */\\`)\n- \\`line\\` - Applies to line-style comments (\\`// ...\\`)\n- \\`both\\` - Applies to both block and line-style comments\n\nDefaults to \\`both\\`.`,\n enum: [\n 'block', 'line', 'both',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAF,OAAA;AAOA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe;EACbC,MAAMA,CAAEC,OAAO,EAAE;IACf;AACJ;AACA;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IAEI;IACA,MAAM;MACJC,UAAU,GAAGD,OAAO,CAACE,aAAa,CAAC;IACrC,CAAC,GAAGF,OAAO;IACX,MAAMG,QAAQ,GAAG,IAAAC,yBAAW,EAACJ,OAAO,CAAC;IACrC,IAAI,CAACG,QAAQ,EAAE;MACb,OAAO,CAAC,CAAC;IACX;IAEA,MAAM;MACJE,eAAe,GAAG,CAChB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CACzD;MACDC,QAAQ,GAAGH,QAAQ,CAACG,QAAQ,IAAI,EAAE;MAClCC,aAAa,IAAG,uBAAyB,EAAE,CAAC;MAC5CC,sBAAsB,GAAG,CACvB,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,CAClE;MACDC,WAAW,GAAG,IAAI;MAClBC,qBAAqB,GAAG,OAAO;MAC/BC,gBAAgB,GAAG;IACrB,CAAC,GAAGX,OAAO,CAACY,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAIC,iBAAiB,GAAG,KAAK;;IAE7B;AACJ;AACA;AACA;AACA;AACA;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kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDnC,sBAAsB,EAAE;UACtB8D,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,qFAAqF;UACzES,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACErC,IAAI,EAAE;YACR,CAAC,EACD;cACEkC,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV9E,OAAO,EAAE;kBACP2C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDlC,WAAW,EAAE;UACX6D,WAAW,EAAE,mCAAmC;UAChD3B,IAAI,EAAE;QACR,CAAC;QACDjC,qBAAqB,EAAE;UACrB4D,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;UACXW,IAAI,EAAE,CACJ,OAAO,EAAE,QAAQ,CAClB;UACDtC,IAAI,EAAE;QACR,CAAC;QACDhC,gBAAgB,EAAE;UAChB2D,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,sBAAsB;UACVW,IAAI,EAAE,CACJ,OAAO,EAAE,MAAM,EAAE,MAAM,CACxB;UACDtC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC;AAAAuC,MAAA,CAAArF,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
@@ -69,8 +69,7 @@ add them within this option.
69
69
  {
70
70
  'jsdoc/empty-tags': ['error', {tags: ['event']}]
71
71
  }
72
- \`\`\`
73
- `,
72
+ \`\`\``,
74
73
  items: {
75
74
  type: 'string'
76
75
  },
@@ -1 +1 @@
1
- {"version":3,"file":"emptyTags.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","defaultEmptyTags","Set","emptyIfNotClosure","emptyIfClosure","_default","exports","iterateJsdoc","jsdoc","settings","utils","emptyTags","filterTags","tag","tagName","has","hasOptionTag","tags","some","mode","key","entries","content","name","description","type","trim","length","test","fix","setTag","reportJSDoc","checkInternal","checkPrivate","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/emptyTags.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nconst defaultEmptyTags = new Set([\n 'abstract', 'async', 'generator', 'global', 'hideconstructor',\n\n // jsdoc doesn't use this form in its docs, but allow for compatibility with\n // TypeScript which allows and Closure which requires\n 'ignore',\n\n // jsdoc doesn't use but allow for TypeScript\n 'inheritDoc', 'inner', 'instance',\n 'internal',\n\n 'overload',\n\n 'override',\n 'readonly',\n]);\n\nconst emptyIfNotClosure = new Set([\n // Closure doesn't allow with this casing\n 'inheritdoc', 'package', 'private', 'protected', 'public',\n\n 'static',\n]);\n\nconst emptyIfClosure = new Set([\n 'interface',\n]);\n\nexport default iterateJsdoc(({\n jsdoc,\n settings,\n utils,\n}) => {\n const emptyTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return defaultEmptyTags.has(tagName) ||\n utils.hasOptionTag(tagName) && jsdoc.tags.some(({\n tag,\n }) => {\n return tag === tagName;\n }) ||\n settings.mode === 'closure' && emptyIfClosure.has(tagName) ||\n settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);\n });\n\n for (const [\n key,\n tag,\n ] of emptyTags.entries()) {\n const content = tag.name || tag.description || tag.type;\n if (content.trim() && (\n // Allow for JSDoc-block final asterisks\n key !== emptyTags.length - 1 || !(/^\\s*\\*+$/v).test(content)\n )) {\n const fix = () => {\n // By time of call in fixer, `tag` will have `line` added\n utils.setTag(\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */ (tag),\n );\n };\n\n utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true);\n }\n }\n}, {\n checkInternal: true,\n checkPrivate: true,\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks tags that are expected to be empty (e.g., `@abstract` or `@async`), reporting if they have content',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `If you want additional tags to be checked for their descriptions, you may\nadd them within this option.\n\n\\`\\`\\`js\n{\n 'jsdoc/empty-tags': ['error', {tags: ['event']}]\n}\n\\`\\`\\`\n`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\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,MAAMG,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAC/B,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB;AAE7D;AACA;AACA,QAAQ;AAER;AACA,YAAY,EAAE,OAAO,EAAE,UAAU,EACjC,UAAU,EAEV,UAAU,EAEV,UAAU,EACV,UAAU,CACX,CAAC;AAEF,MAAMC,iBAAiB,GAAG,IAAID,GAAG,CAAC;AAChC;AACA,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAEzD,QAAQ,CACT,CAAC;AAEF,MAAME,cAAc,GAAG,IAAIF,GAAG,CAAC,CAC7B,WAAW,CACZ,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEY,IAAAO,qBAAY,EAAC,CAAC;EAC3BC,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EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJZ,WAAW,EAAE,2GAA2G;MACxHa,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,IAAI,EAAE;UACJO,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACWkB,KAAK,EAAE;YACLjB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAkB,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"emptyTags.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","defaultEmptyTags","Set","emptyIfNotClosure","emptyIfClosure","_default","exports","iterateJsdoc","jsdoc","settings","utils","emptyTags","filterTags","tag","tagName","has","hasOptionTag","tags","some","mode","key","entries","content","name","description","type","trim","length","test","fix","setTag","reportJSDoc","checkInternal","checkPrivate","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/emptyTags.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nconst defaultEmptyTags = new Set([\n 'abstract', 'async', 'generator', 'global', 'hideconstructor',\n\n // jsdoc doesn't use this form in its docs, but allow for compatibility with\n // TypeScript which allows and Closure which requires\n 'ignore',\n\n // jsdoc doesn't use but allow for TypeScript\n 'inheritDoc', 'inner', 'instance',\n 'internal',\n\n 'overload',\n\n 'override',\n 'readonly',\n]);\n\nconst emptyIfNotClosure = new Set([\n // Closure doesn't allow with this casing\n 'inheritdoc', 'package', 'private', 'protected', 'public',\n\n 'static',\n]);\n\nconst emptyIfClosure = new Set([\n 'interface',\n]);\n\nexport default iterateJsdoc(({\n jsdoc,\n settings,\n utils,\n}) => {\n const emptyTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return defaultEmptyTags.has(tagName) ||\n utils.hasOptionTag(tagName) && jsdoc.tags.some(({\n tag,\n }) => {\n return tag === tagName;\n }) ||\n settings.mode === 'closure' && emptyIfClosure.has(tagName) ||\n settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);\n });\n\n for (const [\n key,\n tag,\n ] of emptyTags.entries()) {\n const content = tag.name || tag.description || tag.type;\n if (content.trim() && (\n // Allow for JSDoc-block final asterisks\n key !== emptyTags.length - 1 || !(/^\\s*\\*+$/v).test(content)\n )) {\n const fix = () => {\n // By time of call in fixer, `tag` will have `line` added\n utils.setTag(\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */ (tag),\n );\n };\n\n utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true);\n }\n }\n}, {\n checkInternal: true,\n checkPrivate: true,\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks tags that are expected to be empty (e.g., `@abstract` or `@async`), reporting if they have content',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `If you want additional tags to be checked for their descriptions, you may\nadd them within this option.\n\n\\`\\`\\`js\n{\n 'jsdoc/empty-tags': ['error', {tags: ['event']}]\n}\n\\`\\`\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\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,MAAMG,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAC/B,UAAU,E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AAC;IAChB;IACAN,GAAG,KAAKT,SAAS,CAACgB,MAAM,GAAG,CAAC,IAAI,CAAE,WAAW,CAAEC,IAAI,CAACN,OAAO,CAAC,CAC7D,EAAE;MACD,MAAMO,GAAG,GAAGA,CAAA,KAAM;QAChB;QACAnB,KAAK,CAACoB,MAAM;QACV;AACV;AACA;AACA;AACA;QAAejB,GACP,CAAC;MACH,CAAC;MAEDH,KAAK,CAACqB,WAAW,CAAC,IAAIlB,GAAG,CAACA,GAAG,mBAAmB,EAAEA,GAAG,EAAEgB,GAAG,EAAE,IAAI,CAAC;IACnE;EACF;AACF,CAAC,EAAE;EACDG,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJZ,WAAW,EAAE,2GAA2G;MACxHa,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,IAAI,EAAE;UACJO,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKkB,KAAK,EAAE;YACLjB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAkB,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = (0, _iterateJsdoc.default)(({
10
+ context,
11
+ jsdoc,
12
+ settings,
13
+ utils
14
+ }) => {
15
+ const {
16
+ mode
17
+ } = settings;
18
+ if (mode !== 'typescript') {
19
+ return;
20
+ }
21
+ const {
22
+ allowedInlineTags = [],
23
+ enableFixer = false,
24
+ fixType = 'backslash'
25
+ } = context.options[0] || {};
26
+ const {
27
+ description
28
+ } = utils.getDescription();
29
+
30
+ /** @type {string[]} */
31
+ const tagNames = [];
32
+
33
+ /** @type {number[]} */
34
+ const indexes = [];
35
+ const unescapedInlineTagRegex = /(?:^|\s)@(\w+)/gv;
36
+ for (const [idx, descLine] of (description.startsWith('\n') ? description.slice(1) : description).split('\n').entries()) {
37
+ descLine.replaceAll(unescapedInlineTagRegex, (_, tagName) => {
38
+ if (allowedInlineTags.includes(tagName)) {
39
+ return _;
40
+ }
41
+ tagNames.push(tagName);
42
+ indexes.push(idx);
43
+ return _;
44
+ });
45
+ }
46
+ for (const [idx, tagName] of tagNames.entries()) {
47
+ utils.reportJSDoc(`Unexpected inline JSDoc tag. Did you mean to use {@${tagName}}, \\@${tagName}, or \`@${tagName}\`?`, {
48
+ line: indexes[idx] + 1
49
+ }, enableFixer ? () => {
50
+ utils.setBlockDescription((info, seedTokens, descLines) => {
51
+ return descLines.map(desc => {
52
+ const newDesc = desc.replaceAll(new RegExp(`(^|\\s)@${
53
+ // No need to escape, as contains only safe characters
54
+ tagName}`, 'gv'), fixType === 'backticks' ? '$1`@' + tagName + '`' : '$1\\@' + tagName);
55
+ return {
56
+ number: 0,
57
+ source: '',
58
+ tokens: seedTokens({
59
+ ...info,
60
+ description: newDesc,
61
+ postDelimiter: newDesc.trim() ? ' ' : ''
62
+ })
63
+ };
64
+ });
65
+ });
66
+ } : null);
67
+ }
68
+
69
+ /**
70
+ * @param {string} tagName
71
+ * @returns {[
72
+ * RegExp,
73
+ * (description: string) => string
74
+ * ]}
75
+ */
76
+ const escapeInlineTags = tagName => {
77
+ const regex = new RegExp(`(^|\\s)@${
78
+ // No need to escape, as contains only safe characters
79
+ tagName}`, 'gv');
80
+ return [regex,
81
+ /**
82
+ * @param {string} desc
83
+ */
84
+ desc => {
85
+ return desc.replaceAll(regex, fixType === 'backticks' ? '$1`@' + tagName + '`' : '$1\\@' + tagName);
86
+ }];
87
+ };
88
+ for (const tag of jsdoc.tags) {
89
+ if (tag.tag === 'example') {
90
+ continue;
91
+ }
92
+
93
+ /** @type {string} */
94
+ let tagName = '';
95
+ while (/** @type {string[]} */utils.getTagDescription(tag, true)
96
+ // eslint-disable-next-line no-loop-func -- Safe
97
+ .some(desc => {
98
+ tagName = unescapedInlineTagRegex.exec(desc)?.[1] ?? '';
99
+ if (allowedInlineTags.includes(tagName)) {
100
+ return false;
101
+ }
102
+ return tagName;
103
+ })) {
104
+ const line = utils.setTagDescription(tag, ...escapeInlineTags(tagName)) + tag.source[0].number;
105
+ utils.reportJSDoc(`Unexpected inline JSDoc tag. Did you mean to use {@${tagName}}, \\@${tagName}, or \`@${tagName}\`?`, {
106
+ line
107
+ }, enableFixer ? () => {} : null, true);
108
+ }
109
+ }
110
+ }, {
111
+ iterateAllJsdocs: true,
112
+ meta: {
113
+ docs: {
114
+ description: 'Reports use of JSDoc tags in non-tag positions (in the default "typescript" mode).',
115
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/escape-inline-tags.md#repos-sticky-header'
116
+ },
117
+ fixable: 'code',
118
+ schema: [{
119
+ additionalProperties: false,
120
+ properties: {
121
+ allowedInlineTags: {
122
+ description: 'A listing of tags you wish to allow unescaped. Defaults to an empty array.',
123
+ items: {
124
+ type: 'string'
125
+ },
126
+ type: 'array'
127
+ },
128
+ enableFixer: {
129
+ description: 'Whether to enable the fixer. Defaults to `false`.',
130
+ type: 'boolean'
131
+ },
132
+ fixType: {
133
+ description: `How to escape the inline tag.
134
+
135
+ May be "backticks" to enclose tags in backticks (treating as code segments), or
136
+ "backslash" to escape tags with a backslash, i.e., \`\\@\`
137
+
138
+ Defaults to "backslash".`,
139
+ enum: ['backticks', 'backslash'],
140
+ type: 'string'
141
+ }
142
+ },
143
+ type: 'object'
144
+ }],
145
+ type: 'suggestion'
146
+ }
147
+ });
148
+ module.exports = exports.default;
149
+ //# sourceMappingURL=escapeInlineTags.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escapeInlineTags.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdoc","settings","utils","mode","allowedInlineTags","enableFixer","fixType","options","description","getDescription","tagNames","indexes","unescapedInlineTagRegex","idx","descLine","startsWith","slice","split","entries","replaceAll","_","tagName","includes","push","reportJSDoc","line","setBlockDescription","info","seedTokens","descLines","map","desc","newDesc","RegExp","number","source","tokens","postDelimiter","trim","escapeInlineTags","regex","tag","tags","getTagDescription","some","exec","setTagDescription","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type","enum","module"],"sources":["../../src/rules/escapeInlineTags.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n settings,\n utils,\n}) => {\n const {\n mode,\n } = settings;\n\n if (mode !== 'typescript') {\n return;\n }\n\n const {\n allowedInlineTags = [],\n enableFixer = false,\n fixType = 'backslash',\n } = context.options[0] || {};\n\n const {\n description,\n } = utils.getDescription();\n\n /** @type {string[]} */\n const tagNames = [];\n\n /** @type {number[]} */\n const indexes = [];\n\n const unescapedInlineTagRegex = /(?:^|\\s)@(\\w+)/gv;\n for (const [\n idx,\n descLine,\n ] of (\n description.startsWith('\\n') ? description.slice(1) : description\n ).split('\\n').entries()\n ) {\n descLine.replaceAll(unescapedInlineTagRegex, (_, tagName) => {\n if (allowedInlineTags.includes(tagName)) {\n return _;\n }\n\n tagNames.push(tagName);\n indexes.push(idx);\n\n return _;\n });\n }\n\n for (const [\n idx,\n tagName,\n ] of tagNames.entries()) {\n utils.reportJSDoc(\n `Unexpected inline JSDoc tag. Did you mean to use {@${tagName}}, \\\\@${tagName}, or \\`@${tagName}\\`?`,\n {\n line: indexes[idx] + 1,\n },\n enableFixer ?\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return descLines.map((desc) => {\n const newDesc = desc.replaceAll(\n new RegExp(`(^|\\\\s)@${\n // No need to escape, as contains only safe characters\n tagName\n }`, 'gv'),\n fixType === 'backticks' ? '$1`@' + tagName + '`' : '$1\\\\@' + tagName,\n );\n\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: newDesc,\n postDelimiter: newDesc.trim() ? ' ' : '',\n }),\n };\n });\n });\n } :\n null,\n );\n }\n\n /**\n * @param {string} tagName\n * @returns {[\n * RegExp,\n * (description: string) => string\n * ]}\n */\n const escapeInlineTags = (tagName) => {\n const regex = new RegExp(`(^|\\\\s)@${\n // No need to escape, as contains only safe characters\n tagName\n }`, 'gv');\n\n return [\n regex,\n /**\n * @param {string} desc\n */\n (desc) => {\n return desc.replaceAll(\n regex,\n fixType === 'backticks' ? '$1`@' + tagName + '`' : '$1\\\\@' + tagName,\n );\n },\n ];\n };\n\n for (const tag of jsdoc.tags) {\n if (tag.tag === 'example') {\n continue;\n }\n\n /** @type {string} */\n let tagName = '';\n while (/** @type {string[]} */ (\n utils.getTagDescription(tag, true)\n // eslint-disable-next-line no-loop-func -- Safe\n ).some((desc) => {\n tagName = unescapedInlineTagRegex.exec(desc)?.[1] ?? '';\n if (allowedInlineTags.includes(tagName)) {\n return false;\n }\n\n return tagName;\n })) {\n const line = utils.setTagDescription(tag, ...escapeInlineTags(tagName)) +\n tag.source[0].number;\n utils.reportJSDoc(\n `Unexpected inline JSDoc tag. Did you mean to use {@${tagName}}, \\\\@${tagName}, or \\`@${tagName}\\`?`,\n {\n line,\n },\n enableFixer ? () => {} : null,\n true,\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports use of JSDoc tags in non-tag positions (in the default \"typescript\" mode).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/escape-inline-tags.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedInlineTags: {\n description: 'A listing of tags you wish to allow unescaped. Defaults to an empty array.',\n items: {\n type: 'string',\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Whether to enable the fixer. Defaults to `false`.',\n type: 'boolean',\n },\n fixType: {\n description: `How to escape the inline tag.\n\nMay be \"backticks\" to enclose tags in backticks (treating as code segments), or\n\"backslash\" to escape tags with a backslash, i.e., \\`\\\\@\\`\n\nDefaults to \"backslash\".`,\n enum: [\n 'backticks',\n 'backslash',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\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;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC;EACF,CAAC,GAAGF,QAAQ;EAEZ,IAAIE,IAAI,KAAK,YAAY,EAAE;IACzB;EACF;EAEA,MAAM;IACJC,iBAAiB,GAAG,EAAE;IACtBC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG;EACZ,CAAC,GAAGP,OAAO,CAACQ,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC;EACF,CAAC,GAAGN,KAAK,CAACO,cAAc,CAAC,CAAC;;EAE1B;EACA,MAAMC,QAAQ,GAAG,EAAE;;EAEnB;EACA,MAAMC,OAAO,GAAG,EAAE;EAElB,MAAMC,uBAAuB,GAAG,kBAAkB;EAClD,KAAK,MAAM,CACTC,GAAG,EACHC,QAAQ,CACT,IAAI,CACDN,WAAW,CAACO,UAAU,CAAC,I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ACDpB,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,EAC7B,IACF,CAAC;IACH;EACF;AACF,CAAC,EAAE;EACD0C,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJzC,WAAW,EAAE,oFAAoF;MACjG0C,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVlD,iBAAiB,EAAE;UACjBI,WAAW,EAAE,4EAA4E;UACzF+C,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDnD,WAAW,EAAE;UACXG,WAAW,EAAE,mDAAmD;UAChEgD,IAAI,EAAE;QACR,CAAC;QACDlD,OAAO,EAAE;UACPE,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,yBAAyB;UACbiD,IAAI,EAAE,CACJ,WAAW,EACX,WAAW,CACZ;UACDD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAE,MAAA,CAAA7D,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
3
+ //# sourceMappingURL=escapeInlineTags.d.ts.map