Skip to content

Commit

Permalink
fix(config): warn not error if extending group presets (#9836)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed May 4, 2021
1 parent 63ca348 commit e0fa64d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
16 changes: 16 additions & 0 deletions lib/config/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,21 @@ describe(getName(), () => {
expect(errors).toHaveLength(1);
expect(errors).toMatchSnapshot();
});
it('warns on nested group packageRules', async () => {
const config = {
packageRules: [
{
automerge: true,
extends: ['group:fortawesome'],
},
],
};
const { warnings, errors } = await configValidation.validateConfig(
config,
true
);
expect(errors).toHaveLength(0);
expect(warnings).toHaveLength(1);
});
});
});
19 changes: 15 additions & 4 deletions lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { configRegexPredicate, isConfigRegex, regEx } from '../util/regex';
import * as template from '../util/template';
import { hasValidSchedule, hasValidTimezone } from '../workers/branch/schedule';
import { getOptions } from './definitions';
import { migrateConfig } from './migration';
import { resolveConfigPresets } from './presets';
import type {
RenovateConfig,
Expand Down Expand Up @@ -255,6 +256,12 @@ export async function validateConfig(
const tzRe = /^:timezone\((.+)\)$/;
for (const subval of val) {
if (is.string(subval)) {
if (subval.startsWith('group:')) {
warnings.push({
topic: 'Configuration Warning',
message: `${currentPath}: you should not extend "group:" presets`,
});
}
if (tzRe.test(subval)) {
const [, timezone] = tzRe.exec(subval);
const [validTimezone, errorMessage] = hasValidTimezone(
Expand Down Expand Up @@ -297,10 +304,14 @@ export async function validateConfig(
if (key === 'packageRules') {
for (const [subIndex, packageRule] of val.entries()) {
if (is.object(packageRule)) {
const resolvedRule = await resolveConfigPresets(
packageRule as RenovateConfig,
config
);
const resolvedRule = migrateConfig({
packageRules: [
await resolveConfigPresets(
packageRule as RenovateConfig,
config
),
],
}).migratedConfig.packageRules[0];
errors.push(
...managerValidator.check({ resolvedRule, currentPath })
);
Expand Down

0 comments on commit e0fa64d

Please sign in to comment.