diff --git a/lib/config/validation.js b/lib/config/validation.js index 4a8fa81658de5b22ae1ac17a97b761ed7134dcba..3955de01cfe6bed701514cd8a6961f398d04f83b 100644 --- a/lib/config/validation.js +++ b/lib/config/validation.js @@ -1,5 +1,4 @@ const options = require('./definitions').getOptions(); -const { isValidSemver } = require('../versioning/semver'); const { resolveConfigPresets } = require('./presets'); const { hasValidSchedule, @@ -90,13 +89,6 @@ async function validateConfig(config, isPreset, parentPath) { message: `${currentPath}: ${errorMessage}`, }); } - } else if (key === 'allowedVersions' && val !== null) { - if (!isValidSemver(val)) { - errors.push({ - depName: 'Configuration Error', - message: `Invalid semver range for ${currentPath}: \`${val}\``, - }); - } } else if (val != null) { const type = optionTypes[key]; if (type === 'boolean') { @@ -170,17 +162,6 @@ async function validateConfig(config, isPreset, parentPath) { message, }); } - if ( - resolvedRule.matchCurrentVersion && - !isValidSemver(resolvedRule.matchCurrentVersion) - ) { - errors.push({ - depName: 'Configuration Error', - message: `${currentPath}: ${ - resolvedRule.matchCurrentVersion - } isn't a valid semver`, - }); - } } else { errors.push({ depName: 'Configuration Error', diff --git a/test/config/__snapshots__/validation.spec.js.snap b/test/config/__snapshots__/validation.spec.js.snap index dfdb6d1ecbe5544c13d8af7b636597fc36979b90..861b627fc06aa5a51ef68dc94265c9e2b8d8ad5f 100644 --- a/test/config/__snapshots__/validation.spec.js.snap +++ b/test/config/__snapshots__/validation.spec.js.snap @@ -4,23 +4,23 @@ exports[`config/validation validateConfig(config) errors for all types 1`] = ` Array [ Object { "depName": "Configuration Error", - "message": "Configuration option \`lockFileMaintenance\` should be a json object", + "message": "extends: Invalid timezone: Europe/Brussel", }, Object { "depName": "Configuration Error", - "message": "Invalid semver range for allowedVersions: \`foo\`", + "message": "Configuration option \`enabled\` should be boolean. Found: 1 (number)", }, Object { "depName": "Configuration Error", - "message": "Invalid schedule: \`Schedule \\"every 15 mins every weekday\\" should not specify minutes\`", + "message": "Configuration option \`labels\` should be a list (Array)", }, Object { "depName": "Configuration Error", - "message": "Invalid regExp for packageRules[3].excludePackagePatterns: \`abc ([a-z]+) ([a-z]+))\`", + "message": "Configuration option \`lockFileMaintenance\` should be a json object", }, Object { "depName": "Configuration Error", - "message": "Configuration option \`labels\` should be a list (Array)", + "message": "Configuration option \`packageRules[3].packagePatterns\` should be a list (Array)", }, Object { "depName": "Configuration Error", @@ -28,19 +28,15 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "Configuration option \`enabled\` should be boolean. Found: 1 (number)", - }, - Object { - "depName": "Configuration Error", - "message": "Configuration option \`packageRules[3].packagePatterns\` should be a list (Array)", + "message": "Invalid configuration option: \`packageRules[1].foo\`", }, Object { "depName": "Configuration Error", - "message": "Invalid configuration option: \`packageRules[1].foo\`", + "message": "Invalid regExp for packageRules[3].excludePackagePatterns: \`abc ([a-z]+) ([a-z]+))\`", }, Object { "depName": "Configuration Error", - "message": "extends: Invalid timezone: Europe/Brussel", + "message": "Invalid schedule: \`Schedule \\"every 15 mins every weekday\\" should not specify minutes\`", }, Object { "depName": "Configuration Error", @@ -72,15 +68,6 @@ Array [ exports[`config/validation validateConfig(config) ignore packageRule nesting validation for presets 1`] = `Array []`; -exports[`config/validation validateConfig(config) invalid matchCurrentVersion triggers an error 1`] = ` -Array [ - Object { - "depName": "Configuration Error", - "message": "packageRules: >= 2.-1.4 isn't a valid semver", - }, -] -`; - exports[`config/validation validateConfig(config) returns deprecation warnings 1`] = ` Array [ Object { diff --git a/test/config/validation.spec.js b/test/config/validation.spec.js index a7c5ead5f2666c8e0657e62ce318b1cfcc1faefc..c40dffeb3a3e1725d5aeaa7852122832e388a90d 100644 --- a/test/config/validation.spec.js +++ b/test/config/validation.spec.js @@ -64,7 +64,7 @@ describe('config/validation', () => { ); expect(warnings).toHaveLength(0); expect(errors).toMatchSnapshot(); - expect(errors).toHaveLength(13); + expect(errors).toHaveLength(12); }); it('selectors outside packageRules array trigger errors', async () => { const config = { @@ -107,22 +107,6 @@ describe('config/validation', () => { expect(errors).toMatchSnapshot(); expect(errors).toHaveLength(0); }); - it('invalid matchCurrentVersion triggers an error', async () => { - const config = { - packageRules: [ - { - packageNames: ['angular'], - matchCurrentVersion: '>= 2.-1.4', - }, - ], - }; - const { warnings, errors } = await configValidation.validateConfig( - config - ); - expect(warnings).toHaveLength(0); - expect(errors).toMatchSnapshot(); - expect(errors).toHaveLength(1); - }); it('errors for unsafe fileMatches', async () => { const config = { npm: {