mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix: raise config errors for package rules missing selectors
This commit is contained in:
parent
1c96ba54b4
commit
906c6273c7
3 changed files with 11 additions and 17 deletions
|
@ -141,12 +141,12 @@ async function validateConfig(config) {
|
|||
}
|
||||
}
|
||||
if (!hasSelector) {
|
||||
const message =
|
||||
'Each packageRule must contain at least one of ' +
|
||||
JSON.stringify(selectors);
|
||||
const message = `Each packageRule must contain at least one selector (${selectors.join(
|
||||
', '
|
||||
)}). If you wish for configuration to apply to all packages, it is not necessary to place it inside a packageRule at all.`;
|
||||
logger.info({ packageRule }, `packageRule warning`);
|
||||
warnings.push({
|
||||
depName: 'Configuration Warning',
|
||||
errors.push({
|
||||
depName: 'Configuration Error',
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`config/validation validateConfig(config) errors for all types 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"depName": "Configuration Warning",
|
||||
"message": "Each packageRule must contain at least one of [\\"packageNames\\",\\"packagePatterns\\",\\"excludePackageNames\\",\\"excludePackagePatterns\\"]",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`config/validation validateConfig(config) errors for all types 2`] = `
|
||||
Array [
|
||||
Object {
|
||||
"depName": "Configuration Error",
|
||||
|
@ -47,6 +38,10 @@ Array [
|
|||
"depName": "Configuration Error",
|
||||
"message": "Invalid configuration option: \`foo\`",
|
||||
},
|
||||
Object {
|
||||
"depName": "Configuration Error",
|
||||
"message": "Each packageRule must contain at least one selector (packageNames, packagePatterns, excludePackageNames, excludePackagePatterns). If you wish for configuration to apply to all packages, it is not necessary to place it inside a packageRule at all.",
|
||||
},
|
||||
Object {
|
||||
"depName": "Configuration Error",
|
||||
"message": "packageRules must contain JSON objects",
|
||||
|
|
|
@ -43,10 +43,9 @@ describe('config/validation', () => {
|
|||
const { warnings, errors } = await configValidation.validateConfig(
|
||||
config
|
||||
);
|
||||
expect(warnings).toMatchSnapshot();
|
||||
expect(warnings).toHaveLength(1);
|
||||
expect(warnings).toHaveLength(0);
|
||||
expect(errors).toMatchSnapshot();
|
||||
expect(errors).toHaveLength(10);
|
||||
expect(errors).toHaveLength(11);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue