Skip to content

Commit c1514d6

Browse files
committed
chore: Use set for allowed changeset types
1 parent 3d4ffab commit c1514d6

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

build-packages/check-pr/validators.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { getInput, setFailed, info } from '@actions/core';
55
import { messageTypes } from '../changeset-types.js';
66

77
const validCommitTypes = ['feat', 'fix', 'chore'];
8+
const allAllowedChangeTypes = new Set(
9+
messageTypes.flatMap(({ name, alternatives }) => [name, ...alternatives])
10+
);
811

912
// Expected format: preamble(topic)!: Title text
1013
export async function validateTitle(title: string | undefined): Promise<void> {
@@ -116,10 +119,6 @@ export function validateChangesets(
116119
fileContents: string[]
117120
): void {
118121
const allowedBumps = getAllowedBumps(commitType, isBreaking);
119-
const allAllowedTypes = messageTypes.flatMap(({ name, alternatives }) => [
120-
name,
121-
...alternatives
122-
]);
123122

124123
if (!hasMatchingChangeset(allowedBumps, fileContents)) {
125124
return setFailed(
@@ -139,7 +138,7 @@ export function validateChangesets(
139138
}
140139

141140
const allChangeTypesMatch = changeTypes.every(type =>
142-
allAllowedTypes.includes(type.toLowerCase())
141+
allAllowedChangeTypes.has(type.toLowerCase())
143142
);
144143

145144
if (!allChangeTypesMatch) {

0 commit comments

Comments
 (0)