Skip to content

Commit c896471

Browse files
address the comments
1 parent df4381c commit c896471

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tools/spectral/ipa/__tests__/IPA126TagNamesShouldUseTitleCase.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ testRule('xgen-IPA-126-tag-names-should-use-title-case', [
134134
{ name: '-Test Tag' },
135135
{ name: 'Test Tag-' },
136136
{ name: 'Test Tag -Name' },
137+
{ name: 'the Test Tag' },
137138
],
138139
},
139140
errors: [
@@ -173,6 +174,12 @@ testRule('xgen-IPA-126-tag-names-should-use-title-case', [
173174
path: ['tags', '7'],
174175
severity: DiagnosticSeverity.Warning,
175176
},
177+
{
178+
code: 'xgen-IPA-126-tag-names-should-use-title-case',
179+
message: 'Tag name should use Title Case, found: "the Test Tag".',
180+
path: ['tags', '8'],
181+
severity: DiagnosticSeverity.Warning,
182+
},
176183
],
177184
},
178185
]);

tools/spectral/ipa/rulesets/functions/IPA126TagNamesShouldUseTitleCase.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,22 @@ export default (input, { ignoreList, grammaticalWords }, { path }) => {
2626

2727
function isTitleCase(str, ignoreList, grammaticalWords) {
2828
// Split by spaces to check each word/word-group
29+
// First character should be uppercase, rest lowercase, all alphabetical
2930
const words = str.split(' ');
3031

31-
return words.every((wordGroup) => {
32+
return words.every((wordGroup, index) => {
3233
// For hyphenated words, check each part
3334
if (wordGroup.includes('-')) {
3435
const hyphenatedParts = wordGroup.split('-');
3536
return hyphenatedParts.every((part) => {
3637
if (ignoreList.includes(part)) return true;
37-
if (grammaticalWords.includes(part)) return true;
38-
// First character should be uppercase, rest lowercase, all alphabetical
3938
return /^[A-Z][a-z]*$/.test(part);
4039
});
4140
}
4241

4342
// For regular words
4443
if (ignoreList.includes(wordGroup)) return true;
45-
if (grammaticalWords.includes(wordGroup)) return true;
44+
if (index !== 0 && grammaticalWords.includes(wordGroup)) return true;
4645
return /^[A-Z][a-z]*$/.test(wordGroup);
4746
});
4847
}

0 commit comments

Comments
 (0)