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
No related tags found
No related merge requests found
......@@ -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,
});
}
......
// 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);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment