Skip to content

Commit cf8c901

Browse files
committed
Add valid ignore-tags to parsed annotation comments
1 parent 6ce5c15 commit cf8c901

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

packages/annotation-comments/src/core/parse.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export function parseAnnotationComments(options: ParseAnnotationCommentsOptions)
4848
} else if (ignoreRange > 0) {
4949
tagsIgnoredUntilLineIndex = tag.range.end.line + ignoreRange
5050
}
51-
return
51+
// We still want to add this valid ignore-tags comment to the result array
52+
// to allow it to be removed by `cleanCode()` later, so we don't return here
5253
}
5354

5455
// If we arrive here, add the tag and comment to the list of annotation comments

packages/annotation-comments/test/parse.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,12 @@ countdown(5)
248248
`// [!after] This should be parsed again`,
249249
]
250250
const comments = getComments(lines.join('\n'))
251-
expect(comments).toHaveLength(2)
252251
expect(comments).toMatchObject([
253252
{
254253
tag: { name: 'before', targetSearchQuery: undefined },
255254
contents: [`This is before any ignores`],
256255
},
257-
// TODO: Expect the ignore-tags annotation comment to be present as well
256+
{ tag: { name: 'ignore-tags' } },
258257
{
259258
tag: { name: 'after', targetSearchQuery: undefined },
260259
contents: [`This should be parsed again`],
@@ -271,13 +270,12 @@ countdown(5)
271270
`// [!after] This should be parsed again`,
272271
]
273272
const comments = getComments(lines.join('\n'))
274-
expect(comments).toHaveLength(2)
275273
expect(comments).toMatchObject([
276274
{
277275
tag: { name: 'before', targetSearchQuery: undefined },
278276
contents: [`This is before any ignores`],
279277
},
280-
// TODO: Expect the ignore-tags annotation comment to be present as well
278+
{ tag: { name: 'ignore-tags' } },
281279
{
282280
tag: { name: 'after', targetSearchQuery: undefined },
283281
contents: [`This should be parsed again`],
@@ -293,13 +291,12 @@ countdown(5)
293291
`// [!note] This should be parsed again`,
294292
]
295293
const comments = getComments(lines.join('\n'))
296-
expect(comments).toHaveLength(2)
297294
expect(comments).toMatchObject([
298295
{
299296
tag: { name: 'before', targetSearchQuery: undefined },
300297
contents: [`This is before any ignores`],
301298
},
302-
// TODO: Expect the ignore-tags annotation comment to be present as well
299+
{ tag: { name: 'ignore-tags' } },
303300
{
304301
tag: { name: 'note', targetSearchQuery: undefined },
305302
contents: [`This should be parsed again`],
@@ -318,13 +315,12 @@ countdown(5)
318315
`// [!note] This should be parsed again`,
319316
]
320317
const comments = getComments(lines.join('\n'))
321-
expect(comments).toHaveLength(3)
322318
expect(comments).toMatchObject([
323319
{
324320
tag: { name: 'before', targetSearchQuery: undefined },
325321
contents: [`This is before any ignores`],
326322
},
327-
// TODO: Expect the ignore-tags annotation comment to be present as well
323+
{ tag: { name: 'ignore-tags' } },
328324
{
329325
tag: { name: 'ins', targetSearchQuery: undefined },
330326
contents: [],
@@ -347,15 +343,14 @@ countdown(5)
347343
`testCode() // [!ins]`,
348344
]
349345
const comments = getComments(lines.join('\n'))
350-
expect(comments).toHaveLength(3)
351346
expect(comments).toMatchObject([
352347
{
353348
tag: { name: 'before', targetSearchQuery: undefined },
354349
contents: [`This is before any ignores`],
355350
commentRange: { start: { line: 0 }, end: { line: 5 } },
356351
annotationRange: { start: { line: 1 }, end: { line: 1 } },
357352
},
358-
// TODO: Expect the ignore-tags annotation comment to be present as well
353+
{ tag: { name: 'ignore-tags' } },
359354
{
360355
tag: { name: 'note', targetSearchQuery: undefined },
361356
contents: [`This should be parsed again`],

0 commit comments

Comments
 (0)