eslint-plugin-jsdoc 50.6.4 → 50.6.6

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.
@@ -30,9 +30,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
30
30
  return tag === tagName;
31
31
  }) || settings.mode === 'closure' && emptyIfClosure.has(tagName) || settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);
32
32
  });
33
- for (const tag of emptyTags) {
33
+ for (const [key, tag] of emptyTags.entries()) {
34
34
  const content = tag.name || tag.description || tag.type;
35
- if (content.trim()) {
35
+ if (content.trim() && (
36
+ // Allow for JSDoc-block final asterisks
37
+ key !== emptyTags.length - 1 || !/^\s*\*+$/u.test(content))) {
36
38
  const fix = () => {
37
39
  // By time of call in fixer, `tag` will have `line` added
38
40
  utils.setTag(
@@ -1 +1 @@
1
- {"version":3,"file":"emptyTags.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","defaultEmptyTags","Set","emptyIfNotClosure","emptyIfClosure","_default","exports","iterateJsdoc","settings","jsdoc","utils","emptyTags","filterTags","tag","tagName","has","hasOptionTag","tags","some","mode","content","name","description","type","trim","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 'ignore', 'inner', 'instance', 'override', 'readonly',\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 'inheritDoc',\n\n // jsdoc doesn't use but allow for TypeScript\n 'internal',\n 'overload',\n]);\n\nconst emptyIfNotClosure = new Set([\n 'package', 'private', 'protected', 'public', 'static',\n\n // Closure doesn't allow with this casing\n 'inheritdoc',\n]);\n\nconst emptyIfClosure = new Set([\n 'interface',\n]);\n\nexport default iterateJsdoc(({\n settings,\n jsdoc,\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 tag of emptyTags) {\n const content = tag.name || tag.description || tag.type;\n if (content.trim()) {\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: 'Expects specific tags to be empty of any 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 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,EAC7D,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;AAErD;AACA;AACA,YAAY;AAEZ;AACA,UAAU,EACV,UAAU,CACX,CAAC;AAEF,MAAMC,iBAAiB,GAAG,IAAID,GAAG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ACF,CAAC,EAAE;EACDG,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJV,WAAW,EAAE,mDAAmD;MAChEW,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVpB,IAAI,EAAE;UACJqB,KAAK,EAAE;YACLf,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAgB,MAAA,CAAAjC,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","settings","jsdoc","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 'ignore', 'inner', 'instance', 'override', 'readonly',\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 'inheritDoc',\n\n // jsdoc doesn't use but allow for TypeScript\n 'internal',\n 'overload',\n]);\n\nconst emptyIfNotClosure = new Set([\n 'package', 'private', 'protected', 'public', 'static',\n\n // Closure doesn't allow with this casing\n 'inheritdoc',\n]);\n\nconst emptyIfClosure = new Set([\n 'interface',\n]);\n\nexport default iterateJsdoc(({\n settings,\n jsdoc,\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 [key, tag] 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*\\*+$/u).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: 'Expects specific tags to be empty of any 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 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,EAC7D,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;AAErD;AACA;AACA,YAAY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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,mDAAmD;MAChEa,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,IAAI,EAAE;UACJyB,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":[]}
@@ -73,6 +73,9 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
73
73
  return;
74
74
  }
75
75
  for (const tag of jsdoc.tags) {
76
+ if (tag.tag === 'example') {
77
+ continue;
78
+ }
76
79
  if ( /** @type {string[]} */utils.getTagDescription(tag, true).some(desc => {
77
80
  return htmlRegex.test(desc);
78
81
  })) {
@@ -94,6 +97,9 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
94
97
  return;
95
98
  }
96
99
  for (const tag of jsdoc.tags) {
100
+ if (tag.tag === 'example') {
101
+ continue;
102
+ }
97
103
  if ( /** @type {string[]} */utils.getTagDescription(tag, true).some(desc => {
98
104
  return markdownRegex.test(desc);
99
105
  })) {
@@ -1 +1 @@
1
- {"version":3,"file":"textEscaping.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","htmlRegex","markdownRegex","htmlReplacer","desc","replaceAll","RegExp","_","markdownReplacer","backticks","encapsed","bookend","repeat","length","_default","exports","iterateJsdoc","context","jsdoc","utils","escapeHTML","escapeMarkdown","options","report","loc","end","column","line","start","message","descriptions","getDescription","some","test","setDescriptionLines","reportJSDoc","tag","tags","getTagDescription","setTagDescription","source","number","iterateAllJsdocs","meta","docs","description","url","fixable","schema","additionalProperties","properties","type","module"],"sources":["../../src/rules/textEscaping.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n// We could disallow raw gt, quot, and apos, but allow for parity; but we do\n// not allow hex or decimal character references\nconst htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\\S)/u;\nconst markdownRegex = /(?<!\\\\)(`+)([^`]+)\\1(?!`)/u;\n\n/**\n * @param {string} desc\n * @returns {string}\n */\nconst htmlReplacer = (desc) => {\n return desc.replaceAll(new RegExp(htmlRegex, 'gu'), (_) => {\n if (_ === '<') {\n return '&lt;';\n }\n\n return '&amp;';\n });\n};\n\n/**\n * @param {string} desc\n * @returns {string}\n */\nconst markdownReplacer = (desc) => {\n return desc.replaceAll(new RegExp(markdownRegex, 'gu'), (_, backticks, encapsed) => {\n const bookend = '`'.repeat(backticks.length);\n return `\\\\${bookend}${encapsed}${bookend}`;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n escapeHTML,\n escapeMarkdown,\n } = context.options[0] || {};\n\n if (!escapeHTML && !escapeMarkdown) {\n context.report({\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'You must include either `escapeHTML` or `escapeMarkdown`',\n });\n return;\n }\n\n const {\n descriptions,\n } = utils.getDescription();\n\n if (escapeHTML) {\n if (descriptions.some((desc) => {\n return htmlRegex.test(desc);\n })) {\n const line = utils.setDescriptionLines(htmlRegex, htmlReplacer);\n utils.reportJSDoc('You have unescaped HTML characters < or &', {\n line,\n }, () => {}, true);\n return;\n }\n\n for (const tag of jsdoc.tags) {\n if (/** @type {string[]} */ (\n utils.getTagDescription(tag, true)\n ).some((desc) => {\n return htmlRegex.test(desc);\n })) {\n const line = utils.setTagDescription(tag, htmlRegex, htmlReplacer) +\n tag.source[0].number;\n utils.reportJSDoc('You have unescaped HTML characters < or & in a tag', {\n line,\n }, () => {}, true);\n }\n }\n\n return;\n }\n\n if (descriptions.some((desc) => {\n return markdownRegex.test(desc);\n })) {\n const line = utils.setDescriptionLines(markdownRegex, markdownReplacer);\n utils.reportJSDoc('You have unescaped Markdown backtick sequences', {\n line,\n }, () => {}, true);\n return;\n }\n\n for (const tag of jsdoc.tags) {\n if (/** @type {string[]} */ (\n utils.getTagDescription(tag, true)\n ).some((desc) => {\n return markdownRegex.test(desc);\n })) {\n const line = utils.setTagDescription(\n tag, markdownRegex, markdownReplacer,\n ) + tag.source[0].number;\n utils.reportJSDoc(\n 'You have unescaped Markdown backtick sequences in a tag',\n {\n line,\n },\n () => {},\n true,\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Auto-escape certain characters that are input within block and tag descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/text-escaping.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n // Option properties here (or remove the object)\n escapeHTML: {\n type: 'boolean',\n },\n escapeMarkdown: {\n type: 'boolean',\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;AACA;AACA,MAAMG,SAAS,GAAG,0CAA0C;AAC5D,MAAMC,aAAa,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G,IAAIlB,KAAK,CAACmB,IAAI,EAAE;IAC5B,KAAI,uBACFlB,KAAK,CAACmB,iBAAiB,CAACF,GAAG,EAAE,IAAI,CAAC,CAClCJ,IAAI,CAAE5B,IAAI,IAAK;MACf,OAAOF,aAAa,CAAC+B,IAAI,CAAC7B,IAAI,CAAC;IACjC,CAAC,CAAC,EAAE;MACF,MAAMuB,IAAI,GAAGR,KAAK,CAACoB,iBAAiB,CAClCH,GAAG,EAAElC,aAAa,EAAEM,gBACtB,CAAC,GAAG4B,GAAG,CAACI,MAAM,CAAC,CAAC,CAAC,CAACC,MAAM;MACxBtB,KAAK,CAACgB,WAAW,CACf,yDAAyD,EACzD;QACER;MACF,CAAC,EACD,MAAM,CAAC,CAAC,EACR,IACF,CAAC;IACH;EACF;AACF,CAAC,EAAE;EACDe,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kFAAkF;MAC/FC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV;QACA9B,UAAU,EAAE;UACV+B,IAAI,EAAE;QACR,CAAC;QACD9B,cAAc,EAAE;UACd8B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAf,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"textEscaping.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","htmlRegex","markdownRegex","htmlReplacer","desc","replaceAll","RegExp","_","markdownReplacer","backticks","encapsed","bookend","repeat","length","_default","exports","iterateJsdoc","context","jsdoc","utils","escapeHTML","escapeMarkdown","options","report","loc","end","column","line","start","message","descriptions","getDescription","some","test","setDescriptionLines","reportJSDoc","tag","tags","getTagDescription","setTagDescription","source","number","iterateAllJsdocs","meta","docs","description","url","fixable","schema","additionalProperties","properties","type","module"],"sources":["../../src/rules/textEscaping.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n// We could disallow raw gt, quot, and apos, but allow for parity; but we do\n// not allow hex or decimal character references\nconst htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\\S)/u;\nconst markdownRegex = /(?<!\\\\)(`+)([^`]+)\\1(?!`)/u;\n\n/**\n * @param {string} desc\n * @returns {string}\n */\nconst htmlReplacer = (desc) => {\n return desc.replaceAll(new RegExp(htmlRegex, 'gu'), (_) => {\n if (_ === '<') {\n return '&lt;';\n }\n\n return '&amp;';\n });\n};\n\n/**\n * @param {string} desc\n * @returns {string}\n */\nconst markdownReplacer = (desc) => {\n return desc.replaceAll(new RegExp(markdownRegex, 'gu'), (_, backticks, encapsed) => {\n const bookend = '`'.repeat(backticks.length);\n return `\\\\${bookend}${encapsed}${bookend}`;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n escapeHTML,\n escapeMarkdown,\n } = context.options[0] || {};\n\n if (!escapeHTML && !escapeMarkdown) {\n context.report({\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'You must include either `escapeHTML` or `escapeMarkdown`',\n });\n return;\n }\n\n const {\n descriptions,\n } = utils.getDescription();\n\n if (escapeHTML) {\n if (descriptions.some((desc) => {\n return htmlRegex.test(desc);\n })) {\n const line = utils.setDescriptionLines(htmlRegex, htmlReplacer);\n utils.reportJSDoc('You have unescaped HTML characters < or &', {\n line,\n }, () => {}, true);\n return;\n }\n\n for (const tag of jsdoc.tags) {\n if (tag.tag === 'example') {\n continue;\n }\n if (/** @type {string[]} */ (\n utils.getTagDescription(tag, true)\n ).some((desc) => {\n return htmlRegex.test(desc);\n })) {\n const line = utils.setTagDescription(tag, htmlRegex, htmlReplacer) +\n tag.source[0].number;\n utils.reportJSDoc('You have unescaped HTML characters < or & in a tag', {\n line,\n }, () => {}, true);\n }\n }\n\n return;\n }\n\n if (descriptions.some((desc) => {\n return markdownRegex.test(desc);\n })) {\n const line = utils.setDescriptionLines(markdownRegex, markdownReplacer);\n utils.reportJSDoc('You have unescaped Markdown backtick sequences', {\n line,\n }, () => {}, true);\n return;\n }\n\n for (const tag of jsdoc.tags) {\n if (tag.tag === 'example') {\n continue;\n }\n if (/** @type {string[]} */ (\n utils.getTagDescription(tag, true)\n ).some((desc) => {\n return markdownRegex.test(desc);\n })) {\n const line = utils.setTagDescription(\n tag, markdownRegex, markdownReplacer,\n ) + tag.source[0].number;\n utils.reportJSDoc(\n 'You have unescaped Markdown backtick sequences in a tag',\n {\n line,\n },\n () => {},\n true,\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Auto-escape certain characters that are input within block and tag descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/text-escaping.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n // Option properties here (or remove the object)\n escapeHTML: {\n type: 'boolean',\n },\n escapeMarkdown: {\n type: 'boolean',\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;AACA;AACA,MAAMG,SAAS,GAAG,0CAA0C;AAC5D,MAAMC,aAAa,GAAG,4BAA4B;;AAElD;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,IAAI,IAAK;EAC7B,OAAOA,IAAI,CAACC,UAAU,CAAC,IAAIC,MAAM,CAACL,SAAS,EAAE,IAAI,CAAC,EAAGM,CAAC,IAAK;IACzD,IAAIA,CAAC,K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CAACF,GAAG,EAAE,IAAI,CAAC,CAClCJ,IAAI,CAAE5B,IAAI,IAAK;MACf,OAAOF,aAAa,CAAC+B,IAAI,CAAC7B,IAAI,CAAC;IACjC,CAAC,CAAC,EAAE;MACF,MAAMuB,IAAI,GAAGR,KAAK,CAACoB,iBAAiB,CAClCH,GAAG,EAAElC,aAAa,EAAEM,gBACtB,CAAC,GAAG4B,GAAG,CAACI,MAAM,CAAC,CAAC,CAAC,CAACC,MAAM;MACxBtB,KAAK,CAACgB,WAAW,CACf,yDAAyD,EACzD;QACER;MACF,CAAC,EACD,MAAM,CAAC,CAAC,EACR,IACF,CAAC;IACH;EACF;AACF,CAAC,EAAE;EACDe,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kFAAkF;MAC/FC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV;QACA9B,UAAU,EAAE;UACV+B,IAAI,EAAE;QACR,CAAC;QACD9B,cAAc,EAAE;UACd8B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAf,OAAA","ignoreList":[]}
package/package.json CHANGED
@@ -161,5 +161,5 @@
161
161
  "test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
162
162
  "test-index": "npm run test-no-cov -- test/rules/index.js"
163
163
  },
164
- "version": "50.6.4"
164
+ "version": "50.6.6"
165
165
  }
@@ -42,9 +42,12 @@ export default iterateJsdoc(({
42
42
  settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);
43
43
  });
44
44
 
45
- for (const tag of emptyTags) {
45
+ for (const [key, tag] of emptyTags.entries()) {
46
46
  const content = tag.name || tag.description || tag.type;
47
- if (content.trim()) {
47
+ if (content.trim() && (
48
+ // Allow for JSDoc-block final asterisks
49
+ key !== emptyTags.length - 1 || !(/^\s*\*+$/u).test(content)
50
+ )) {
48
51
  const fix = () => {
49
52
  // By time of call in fixer, `tag` will have `line` added
50
53
  utils.setTag(
@@ -73,6 +73,9 @@ export default iterateJsdoc(({
73
73
  }
74
74
 
75
75
  for (const tag of jsdoc.tags) {
76
+ if (tag.tag === 'example') {
77
+ continue;
78
+ }
76
79
  if (/** @type {string[]} */ (
77
80
  utils.getTagDescription(tag, true)
78
81
  ).some((desc) => {
@@ -100,6 +103,9 @@ export default iterateJsdoc(({
100
103
  }
101
104
 
102
105
  for (const tag of jsdoc.tags) {
106
+ if (tag.tag === 'example') {
107
+ continue;
108
+ }
103
109
  if (/** @type {string[]} */ (
104
110
  utils.getTagDescription(tag, true)
105
111
  ).some((desc) => {