diff --git a/lib/config/validation.js b/lib/config/validation.js index cea56a8f1a951909c2bc2cac8876857e3220650c..81886c41be776f47bbac13f6cf8a161fe4b8369e 100644 --- a/lib/config/validation.js +++ b/lib/config/validation.js @@ -244,5 +244,14 @@ async function validateConfig(config, isPreset, parentPath) { } } } + function sortAll(a, b) { + if (a.depName === b.depName) { + return a.message > b.message; + } + // istanbul ignore next + return a.depName > b.depName; + } + errors.sort(sortAll); + warnings.sort(sortAll); return { errors, warnings }; } diff --git a/test/config/__snapshots__/validation.spec.js.snap b/test/config/__snapshots__/validation.spec.js.snap index f5b8df6ac42031e6789b0befb9781657ffe85612..ed8699402a1d0fa5e7271eb1e92a2c645c01f5fb 100644 --- a/test/config/__snapshots__/validation.spec.js.snap +++ b/test/config/__snapshots__/validation.spec.js.snap @@ -4,11 +4,11 @@ exports[`config/validation validateConfig(config) errors for all types 1`] = ` Array [ Object { "depName": "Configuration Error", - "message": "Invalid semver range for allowedVersions: \`foo\`", + "message": "Configuration option \`lockFileMaintenance\` should be a json object", }, Object { "depName": "Configuration Error", - "message": "Configuration option \`enabled\` should be boolean. Found: 1 (number)", + "message": "Invalid semver range for allowedVersions: \`foo\`", }, Object { "depName": "Configuration Error", @@ -16,7 +16,7 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "timezone: Invalid timezone: Asia", + "message": "Invalid regExp for packageRules[3].excludePackagePatterns: \`abc ([a-z]+) ([a-z]+))\`", }, Object { "depName": "Configuration Error", @@ -28,11 +28,11 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "Configuration option \`lockFileMaintenance\` should be a json object", + "message": "Configuration option \`enabled\` should be boolean. Found: 1 (number)", }, Object { "depName": "Configuration Error", - "message": "extends: Invalid timezone: Europe/Brussel", + "message": "Configuration option \`packageRules[3].packagePatterns\` should be a list (Array)", }, Object { "depName": "Configuration Error", @@ -40,11 +40,11 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "Configuration option \`packageRules[3].packagePatterns\` should be a list (Array)", + "message": "extends: Invalid timezone: Europe/Brussel", }, Object { "depName": "Configuration Error", - "message": "Invalid regExp for packageRules[3].excludePackagePatterns: \`abc ([a-z]+) ([a-z]+))\`", + "message": "packageRules must contain JSON objects", }, Object { "depName": "Configuration Error", @@ -52,27 +52,27 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "packageRules must contain JSON objects", + "message": "timezone: Invalid timezone: Asia", }, ] `; exports[`config/validation validateConfig(config) ignore packageRule nesting validation for presets 1`] = `Array []`; -exports[`config/validation validateConfig(config) returns deprecation warnings 1`] = ` +exports[`config/validation validateConfig(config) invalid matchCurrentVersion triggers an error 1`] = ` Array [ Object { - "depName": "Deprecation Warning", - "message": "Direct editing of prTitle is now deprecated. Please edit commitMessage subcomponents instead as they will be passed through to prTitle.", + "depName": "Configuration Error", + "message": "packageRules: >= 2.-1.4 isn't a valid semver", }, ] `; -exports[`config/validation validateConfig(config) invalid matchCurrentVersion triggers an error 1`] = ` +exports[`config/validation validateConfig(config) returns deprecation warnings 1`] = ` Array [ Object { - "depName": "Configuration Error", - "message": "packageRules: >= 2.-1.4 isn't a valid semver", + "depName": "Deprecation Warning", + "message": "Direct editing of prTitle is now deprecated. Please edit commitMessage subcomponents instead as they will be passed through to prTitle.", }, ] `; @@ -85,11 +85,11 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "Unsafe regExp for packageRules[0].excludePackagePatterns: \`(x+x+)+y\`", + "message": "Invalid configuration option: \`lockFileMaintenance.bar\`", }, Object { "depName": "Configuration Error", - "message": "Invalid configuration option: \`lockFileMaintenance.bar\`", + "message": "Unsafe regExp for packageRules[0].excludePackagePatterns: \`(x+x+)+y\`", }, ] `; @@ -98,11 +98,11 @@ exports[`config/validation validateConfig(config) selectors outside packageRules Array [ Object { "depName": "Configuration Error", - "message": "packageNames: packageNames should be inside a \`packageRule\` only", + "message": "docker.minor.packageNames: packageNames should be inside a \`packageRule\` only", }, Object { "depName": "Configuration Error", - "message": "docker.minor.packageNames: packageNames should be inside a \`packageRule\` only", + "message": "packageNames: packageNames should be inside a \`packageRule\` only", }, ] `;