Skip to content

Commit

Permalink
feat: better validation errors (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Oct 4, 2021
1 parent 235429e commit 018d432
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
36 changes: 21 additions & 15 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"properties": {
"test": {
"description": "Include all modules that pass test assertion.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#test",
"oneOf": [
{
"$ref": "#/definitions/Rules"
Expand All @@ -50,6 +51,7 @@
},
"include": {
"description": "Include all modules matching any of these conditions.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#include",
"oneOf": [
{
"$ref": "#/definitions/Rules"
Expand All @@ -58,29 +60,16 @@
},
"exclude": {
"description": "Exclude all modules matching any of these conditions.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#exclude",
"oneOf": [
{
"$ref": "#/definitions/Rules"
}
]
},
"minimizerOptions": {
"description": "Options for `htmlMinimizerOptions`.",
"anyOf": [
{
"$ref": "#/definitions/MinimizerOptions"
},
{
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/MinimizerOptions"
}
}
]
},
"parallel": {
"description": "Use multi-process parallel running to improve the build speed.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#parallel",
"anyOf": [
{
"type": "boolean"
Expand All @@ -92,6 +81,7 @@
},
"minify": {
"description": "Allows you to override default minify function.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#minify",
"anyOf": [
{
"instanceof": "Function"
Expand All @@ -104,6 +94,22 @@
}
}
]
},
"minimizerOptions": {
"description": "Options for `htmlMinimizerOptions`.",
"link": "https://github.com/webpack-contrib/html-minimizer-webpack-plugin#minimizeroptions",
"anyOf": [
{
"$ref": "#/definitions/MinimizerOptions"
},
{
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/MinimizerOptions"
}
}
]
}
},
"additionalProperties": false
Expand Down
12 changes: 11 additions & 1 deletion test/__snapshots__/validate-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`validation 1`] = `
- options.test should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#test
Details:
* options.test should be an array:
[RegExp | non-empty string, ...]
Expand All @@ -21,6 +22,7 @@ exports[`validation 2`] = `
- options.test should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#test
Details:
* options.test[0] should be one of these:
RegExp | non-empty string
Expand All @@ -35,6 +37,7 @@ exports[`validation 3`] = `
- options.include should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#include
Details:
* options.include should be an array:
[RegExp | non-empty string, ...]
Expand All @@ -51,6 +54,7 @@ exports[`validation 4`] = `
- options.include should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#include
Details:
* options.include[0] should be one of these:
RegExp | non-empty string
Expand All @@ -65,6 +69,7 @@ exports[`validation 5`] = `
- options.exclude should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#exclude
Details:
* options.exclude should be an array:
[RegExp | non-empty string, ...]
Expand All @@ -81,6 +86,7 @@ exports[`validation 6`] = `
- options.exclude should be one of these:
[RegExp | non-empty string, ...] | RegExp | non-empty string
-> Filtering rules.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#exclude
Details:
* options.exclude[0] should be one of these:
RegExp | non-empty string
Expand All @@ -95,6 +101,7 @@ exports[`validation 7`] = `
- options.minimizerOptions should be one of these:
object {} | [object {}, ...] (should not have fewer than 1 item)
-> Options for \`htmlMinimizerOptions\`.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#minimizeroptions
Details:
* options.minimizerOptions should be an object:
object {}
Expand All @@ -107,6 +114,7 @@ exports[`validation 8`] = `
- options.parallel should be one of these:
boolean | integer
-> Use multi-process parallel running to improve the build speed.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#parallel
Details:
* options.parallel should be a boolean.
* options.parallel should be an integer."
Expand All @@ -117,6 +125,7 @@ exports[`validation 9`] = `
- options.parallel should be one of these:
boolean | integer
-> Use multi-process parallel running to improve the build speed.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#parallel
Details:
* options.parallel should be a boolean.
* options.parallel should be an integer."
Expand All @@ -127,6 +136,7 @@ exports[`validation 10`] = `
- options.minify should be one of these:
function | [function, ...] (should not have fewer than 1 item)
-> Allows you to override default minify function.
-> Read more at https://github.com/webpack-contrib/html-minimizer-webpack-plugin#minify
Details:
* options.minify should be an instance of function.
* options.minify should be an array:
Expand All @@ -136,5 +146,5 @@ exports[`validation 10`] = `
exports[`validation 11`] = `
"Invalid options object. Html Minimizer Plugin has been initialized using an options object that does not match the API schema.
- options has an unknown property 'unknown'. These properties are valid:
object { test?, include?, exclude?, minimizerOptions?, parallel?, minify? }"
object { test?, include?, exclude?, parallel?, minify?, minimizerOptions? }"
`;

0 comments on commit 018d432

Please sign in to comment.