Skip to content

Commit bd87d7e

Browse files
authored
Fix list capitalization rule to skip site-policy directory (#56129)
1 parent d2c803e commit bd87d7e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/content-linter/lib/linting-rules/list-first-word-capitalization.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export const listFirstWordCapitalization = {
55
description: 'First word of list item should be capitalized',
66
tags: ['ul', 'ol'],
77
function: (params, onError) => {
8+
// Skip site-policy directory as these are legal documents with specific formatting requirements
9+
if (params.name && params.name.includes('content/site-policy/')) return
10+
811
// We're going to look for a sequence of 3 tokens. If the markdown
912
// is a really small string, it might not even have that many tokens
1013
// in it. Can bail early.

src/content-linter/tests/unit/list-first-word-captitalization.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,25 @@ describe(listFirstWordCapitalization.names.join(' - '), () => {
7676
const errors = result.markdown
7777
expect(errors.length).toBe(0)
7878
})
79+
80+
test('skips site-policy directory files', async () => {
81+
const markdown = [
82+
'- list item should normally be flagged',
83+
'- another uncapitalized item',
84+
'- a. this is alphabetic numbering',
85+
'- b. this is also alphabetic numbering',
86+
].join('\n')
87+
88+
// Test normal behavior (should flag errors)
89+
const normalResult = await runRule(listFirstWordCapitalization, { strings: { markdown } })
90+
expect(normalResult.markdown.length).toBeGreaterThan(0)
91+
92+
// Test site-policy exclusion (should skip all errors)
93+
const sitePolicyResult = await runRule(listFirstWordCapitalization, {
94+
strings: {
95+
'content/site-policy/some-policy.md': markdown,
96+
},
97+
})
98+
expect(sitePolicyResult['content/site-policy/some-policy.md'].length).toBe(0)
99+
})
79100
})

0 commit comments

Comments
 (0)