Skip to content
Snippets Groups Projects
Commit 906c6273 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: raise config errors for package rules missing selectors

parent 1c96ba54
No related branches found
Tags 11.42.2
No related merge requests found
...@@ -141,12 +141,12 @@ async function validateConfig(config) { ...@@ -141,12 +141,12 @@ async function validateConfig(config) {
} }
} }
if (!hasSelector) { if (!hasSelector) {
const message = const message = `Each packageRule must contain at least one selector (${selectors.join(
'Each packageRule must contain at least one of ' + ', '
JSON.stringify(selectors); )}). 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`); logger.info({ packageRule }, `packageRule warning`);
warnings.push({ errors.push({
depName: 'Configuration Warning', depName: 'Configuration Error',
message, message,
}); });
} }
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`config/validation validateConfig(config) errors for all types 1`] = ` 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 [ Array [
Object { Object {
"depName": "Configuration Error", "depName": "Configuration Error",
...@@ -47,6 +38,10 @@ Array [ ...@@ -47,6 +38,10 @@ Array [
"depName": "Configuration Error", "depName": "Configuration Error",
"message": "Invalid configuration option: \`foo\`", "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 { Object {
"depName": "Configuration Error", "depName": "Configuration Error",
"message": "packageRules must contain JSON objects", "message": "packageRules must contain JSON objects",
......
...@@ -43,10 +43,9 @@ describe('config/validation', () => { ...@@ -43,10 +43,9 @@ describe('config/validation', () => {
const { warnings, errors } = await configValidation.validateConfig( const { warnings, errors } = await configValidation.validateConfig(
config config
); );
expect(warnings).toMatchSnapshot(); expect(warnings).toHaveLength(0);
expect(warnings).toHaveLength(1);
expect(errors).toMatchSnapshot(); expect(errors).toMatchSnapshot();
expect(errors).toHaveLength(10); expect(errors).toHaveLength(11);
}); });
}); });
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment