Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: better validation errors #39

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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? }"
`;