| 76 | * @returns {void} |
| 77 | */ |
| 78 | const validateSchema = (schema, options, validationConfiguration) => { |
| 79 | validate( |
| 80 | schema, |
| 81 | options, |
| 82 | validationConfiguration || { |
| 83 | name: "Webpack", |
| 84 | postFormatter: (formattedError, error) => { |
| 85 | const children = error.children; |
| 86 | if ( |
| 87 | children && |
| 88 | children.some( |
| 89 | (child) => |
| 90 | child.keyword === "absolutePath" && |
| 91 | child.instancePath === "/output/filename" |
| 92 | ) |
| 93 | ) { |
| 94 | return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`; |
| 95 | } |
| 96 | |
| 97 | if ( |
| 98 | children && |
| 99 | children.some( |
| 100 | (child) => |
| 101 | child.keyword === "pattern" && child.instancePath === "/devtool" |
| 102 | ) |
| 103 | ) { |
| 104 | return ( |
| 105 | `${formattedError}\n` + |
| 106 | "BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" + |
| 107 | "Please strictly follow the order of the keywords in the pattern." |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | if (error.keyword === "additionalProperties") { |
| 112 | const params = error.params; |
| 113 | if ( |
| 114 | Object.prototype.hasOwnProperty.call( |
| 115 | DID_YOU_MEAN, |
| 116 | params.additionalProperty |
| 117 | ) |
| 118 | ) { |
| 119 | return `${formattedError}\nDid you mean ${ |
| 120 | DID_YOU_MEAN[ |
| 121 | /** @type {keyof DID_YOU_MEAN} */ (params.additionalProperty) |
| 122 | ] |
| 123 | }?`; |
| 124 | } |
| 125 | |
| 126 | if ( |
| 127 | Object.prototype.hasOwnProperty.call( |
| 128 | REMOVED, |
| 129 | params.additionalProperty |
| 130 | ) |
| 131 | ) { |
| 132 | return `${formattedError}\n${ |
| 133 | REMOVED[/** @type {keyof REMOVED} */ (params.additionalProperty)] |
| 134 | }?`; |
| 135 | } |