mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 17:51:49 +00:00
1d6af9f207
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>
26 lines
795 B
TypeScript
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;
|
|
}
|