Skip to content

Commit 6baad05

Browse files
committed
fix(text-escaping): always allow content in example tags; fixes #1360
1 parent 9edf4b1 commit 6baad05

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.README/rules/text-escaping.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Markdown and you therefore do not wish for it to be accidentally interpreted
1010
as such by the likes of Visual Studio Code or if you wish to view it escaped
1111
within it or your documentation.
1212

13+
`@example` tag content will not be checked.
14+
1315
## Fixer
1416

1517
(TODO)

docs/rules/text-escaping.md

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Markdown and you therefore do not wish for it to be accidentally interpreted
1919
as such by the likes of Visual Studio Code or if you wish to view it escaped
2020
within it or your documentation.
2121

22+
`@example` tag content will not be checked.
23+
2224
<a name="user-content-text-escaping-fixer"></a>
2325
<a name="text-escaping-fixer"></a>
2426
## Fixer
@@ -175,5 +177,21 @@ The following patterns are not considered problems:
175177
* to escape
176178
*/
177179
// "jsdoc/text-escaping": ["error"|"warn", {"escapeHTML":true}]
180+
181+
/**
182+
* @example
183+
* ```
184+
* Some things to escape: <a> and &gt; and &#xabc; and `test`
185+
* ```
186+
*/
187+
// "jsdoc/text-escaping": ["error"|"warn", {"escapeHTML":true}]
188+
189+
/**
190+
* @example
191+
* ```
192+
* Some things to escape: <a> and &gt; and &#xabc; and `test`
193+
* ```
194+
*/
195+
// "jsdoc/text-escaping": ["error"|"warn", {"escapeMarkdown":true}]
178196
````
179197

src/rules/textEscaping.js

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export default iterateJsdoc(({
7373
}
7474

7575
for (const tag of jsdoc.tags) {
76+
if (tag.tag === 'example') {
77+
continue;
78+
}
7679
if (/** @type {string[]} */ (
7780
utils.getTagDescription(tag, true)
7881
).some((desc) => {
@@ -100,6 +103,9 @@ export default iterateJsdoc(({
100103
}
101104

102105
for (const tag of jsdoc.tags) {
106+
if (tag.tag === 'example') {
107+
continue;
108+
}
103109
if (/** @type {string[]} */ (
104110
utils.getTagDescription(tag, true)
105111
).some((desc) => {

test/rules/assertions/textEscaping.js

+30
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,35 @@ export default /** @type {import('../index.js').TestCases} */ ({
316316
},
317317
],
318318
},
319+
{
320+
code: `
321+
/**
322+
* @example
323+
* \`\`\`
324+
* Some things to escape: <a> and &gt; and &#xabc; and \`test\`
325+
* \`\`\`
326+
*/
327+
`,
328+
options: [
329+
{
330+
escapeHTML: true,
331+
},
332+
]
333+
},
334+
{
335+
code: `
336+
/**
337+
* @example
338+
* \`\`\`
339+
* Some things to escape: <a> and &gt; and &#xabc; and \`test\`
340+
* \`\`\`
341+
*/
342+
`,
343+
options: [
344+
{
345+
escapeMarkdown: true,
346+
},
347+
]
348+
},
319349
],
320350
});

0 commit comments

Comments
 (0)