Skip to content

Commit 582b3b8

Browse files
authored
fix(ci): validate tag names to be lowercase
1 parent 1c0ff94 commit 582b3b8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/workflowFunctions/validateTags.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum ConflictType {
1515
NoWhiteSpace,
1616
NameNotInKeywords,
1717
Status404Link,
18+
NameLowercase
1819
}
1920

2021
type Conflict = {
@@ -121,6 +122,15 @@ export async function validateTags(
121122
});
122123
}
123124

125+
if (key !== key.toLowerCase()) {
126+
conflicts.push({
127+
firstName: key,
128+
secondName: '',
129+
conflictKeyWords: [],
130+
type: ConflictType.NameLowercase,
131+
})
132+
}
133+
124134
if (tag.keywords.some((keyword) => !keyword.replaceAll(/\s+/g, '').length)) {
125135
conflicts.push({
126136
firstName: key,
@@ -182,6 +192,7 @@ export async function validateTags(
182192
noWhiteSpaceConflicts,
183193
status404LinkConflicts,
184194
nameNotInKeywordsConflicts,
195+
nameLowercaseConflicts,
185196
} = conflicts.reduce(
186197
(a, conflict) => {
187198
switch (conflict.type) {
@@ -202,6 +213,8 @@ export async function validateTags(
202213
break;
203214
case ConflictType.Status404Link:
204215
a.status404LinkConflicts.push(conflict);
216+
case ConflictType.NameLowercase:
217+
a.nameLowercaseConflicts.push(conflict);
205218
}
206219

207220
return a;
@@ -213,6 +226,7 @@ export async function validateTags(
213226
emptyBodyConflicts: [] as Conflict[],
214227
noWhiteSpaceConflicts: [] as Conflict[],
215228
status404LinkConflicts: [] as Conflict[],
229+
nameLowercaseConflicts: [] as Conflict[],
216230
},
217231
);
218232

@@ -246,6 +260,14 @@ export async function validateTags(
246260
);
247261
}
248262

263+
if (nameLowercaseConflicts.length) {
264+
parts.push(
265+
`Tag validation error: Tag name has to be lowercase:\n${nameLowercaseConflicts
266+
.map((conflict, index) => kleur.red(`${index}. [${conflict.firstName}]`))
267+
.join('\n')}`,
268+
)
269+
}
270+
249271
if (emptyKeywordConflicts.length) {
250272
parts.push(
251273
`Tag validation error: Tag keywords cannot be empty:\n${emptyKeywordConflicts

0 commit comments

Comments
 (0)