Files
renovate/lib/config/validation-helpers/match-base-branches.ts
Jamie Tanna 1d6af9f207 refactor(config): use constants for config validation topics (#45333)
When reporting config validation issues, we generally use the same
constants for our validation errors/warnings.

Instead of having these strings duplicated everywhere, we can refactor
these into constants, making it clearer when reading the code.

We can retain a "soft" union for cases where we use a dynamically
generated topic, which we won't know ahead of time.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
2026-08-18 12:18:29 +00:00

26 lines
795 B
TypeScript

import { isNonEmptyArray } from '@sindresorhus/is';
import type { ValidationMessage } from '../types.ts';
import { type CheckBaseBranchesArgs, ConfigValidationTopic } from './types.ts';
/**
* Only if type condition or context condition violated then errors array will be mutated to store metadata
*/
export function check({
resolvedRule,
currentPath,
baseBranchPatterns,
}: CheckBaseBranchesArgs): ValidationMessage[] {
const warnings: ValidationMessage[] = [];
if (
Array.isArray(resolvedRule.matchBaseBranches) &&
!isNonEmptyArray(baseBranchPatterns)
) {
warnings.push({
topic: ConfigValidationTopic.Error,
message: `${currentPath}: You must configure baseBranchPatterns in order to use them inside matchBaseBranches.`,
});
}
return warnings;
}