Skip to content

refactor: fix schema #3315

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

Merged
merged 2 commits into from
May 19, 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
86 changes: 43 additions & 43 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
},
"publicPath": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1
},
{
"type": "string",
"minLength": 1
}
],
"description": "The bundled files will be available in the browser under this path."
Expand Down Expand Up @@ -74,37 +74,37 @@
"properties": {
"target": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1
},
{
"type": "boolean"
},
{
"type": "string",
"minLength": 1
}
],
"description": "Open specified route in browser."
},
"app": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"minItems": 1
},
{
"type": "string",
"minLength": 1
}
],
"description": "Open specified browser."
Expand All @@ -120,16 +120,16 @@
"properties": {
"paths": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
},
{
"type": "string",
"minLength": 1
}
]
},
Expand Down Expand Up @@ -457,15 +457,6 @@
},
"open": {
"anyOf": [
{
"$ref": "#/definitions/OpenBoolean"
},
{
"$ref": "#/definitions/OpenString"
},
{
"$ref": "#/definitions/OpenObject"
},
{
"type": "array",
"items": {
Expand All @@ -479,6 +470,15 @@
]
},
"minItems": 1
},
{
"$ref": "#/definitions/OpenBoolean"
},
{
"$ref": "#/definitions/OpenString"
},
{
"$ref": "#/definitions/OpenObject"
}
],
"description": "Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen"
Expand Down Expand Up @@ -529,15 +529,6 @@
},
"static": {
"anyOf": [
{
"type": "boolean"
},
{
"$ref": "#/definitions/StaticString"
},
{
"$ref": "#/definitions/StaticObject"
},
{
"type": "array",
"items": {
Expand All @@ -551,18 +542,21 @@
]
},
"minItems": 1
},
{
"type": "boolean"
},
{
"$ref": "#/definitions/StaticString"
},
{
"$ref": "#/definitions/StaticObject"
}
],
"description": "It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic"
},
"watchFiles": {
"anyOf": [
{
"$ref": "#/definitions/WatchFilesString"
},
{
"$ref": "#/definitions/WatchFilesObject"
},
{
"type": "array",
"items": {
Expand All @@ -575,6 +569,12 @@
}
]
}
},
{
"$ref": "#/definitions/WatchFilesString"
},
{
"$ref": "#/definitions/WatchFilesObject"
}
],
"description": "List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles"
Expand Down
62 changes: 31 additions & 31 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ exports[`options validate should throw an error on the "open" option with '[]' v
exports[`options validate should throw an error on the "open" option with '{"app":true}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.open should be one of these:
boolean | non-empty string | object { target?, app? } | [non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item)
[non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { target?, app? }
-> Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen
Details:
* configuration.open.app should be one of these:
non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
[non-empty string, ...] (should not have fewer than 1 item) | non-empty string
-> Open specified browser.
Details:
* configuration.open.app should be a non-empty string.
* configuration.open.app should be an array:
[non-empty string, ...] (should not have fewer than 1 item)"
[non-empty string, ...] (should not have fewer than 1 item)
* configuration.open.app should be a non-empty string."
`;

exports[`options validate should throw an error on the "open" option with '{"foo":"bar"}' value 1`] = `
Expand All @@ -356,17 +356,17 @@ exports[`options validate should throw an error on the "open" option with '{"foo
exports[`options validate should throw an error on the "open" option with '{"target":90}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.open should be one of these:
boolean | non-empty string | object { target?, app? } | [non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item)
[non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { target?, app? }
-> Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen
Details:
* configuration.open.target should be one of these:
boolean | non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
[non-empty string, ...] (should not have fewer than 1 item) | boolean | non-empty string
-> Open specified route in browser.
Details:
* configuration.open.target should be a boolean.
* configuration.open.target should be a non-empty string.
* configuration.open.target should be an array:
[non-empty string, ...] (should not have fewer than 1 item)"
[non-empty string, ...] (should not have fewer than 1 item)
* configuration.open.target should be a boolean.
* configuration.open.target should be a non-empty string."
`;

exports[`options validate should throw an error on the "port" option with 'false' value 1`] = `
Expand Down Expand Up @@ -440,22 +440,22 @@ exports[`options validate should throw an error on the "static" option with '{"d
exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static.publicPath should be one of these:
non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
[non-empty string, ...] (should not have fewer than 1 item) | non-empty string
-> The bundled files will be available in the browser under this path.
Details:
* configuration.static.publicPath should be a non-empty string.
* configuration.static.publicPath should be an array:
[non-empty string, ...] (should not have fewer than 1 item)"
[non-empty string, ...] (should not have fewer than 1 item)
* configuration.static.publicPath should be a non-empty string."
`;

exports[`options validate should throw an error on the "static" option with '{"serveIndex":"true"}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static.serveIndex should be one of these:
Expand All @@ -470,7 +470,7 @@ exports[`options validate should throw an error on the "static" option with '{"s
exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static.watch should be one of these:
Expand All @@ -486,55 +486,55 @@ exports[`options validate should throw an error on the "static" option with '{"w
exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static should be an array:
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
* configuration.static should be a boolean.
* configuration.static should be a non-empty string.
* configuration.static should be an object:
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
* configuration.static should be an array:
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
`;

exports[`options validate should throw an error on the "static" option with 'null' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static should be an array:
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
* configuration.static should be a boolean.
* configuration.static should be a non-empty string.
* configuration.static should be an object:
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
* configuration.static should be an array:
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
`;

exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.watchFiles should be one of these:
non-empty string | object { paths?, options? } | [non-empty string | object { paths?, options? }, ...]
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
-> List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
Details:
* configuration.watchFiles should be an array:
[non-empty string | object { paths?, options? }, ...]
* configuration.watchFiles should be a non-empty string.
* configuration.watchFiles should be an object:
object { paths?, options? }
* configuration.watchFiles should be an array:
[non-empty string | object { paths?, options? }, ...]"
object { paths?, options? }"
`;

exports[`options validate should throw an error on the "watchFiles" option with 'false' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.watchFiles should be one of these:
non-empty string | object { paths?, options? } | [non-empty string | object { paths?, options? }, ...]
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
-> List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
Details:
* configuration.watchFiles should be an array:
[non-empty string | object { paths?, options? }, ...]
* configuration.watchFiles should be a non-empty string.
* configuration.watchFiles should be an object:
object { paths?, options? }
* configuration.watchFiles should be an array:
[non-empty string | object { paths?, options? }, ...]"
object { paths?, options? }"
`;

exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `
Expand Down
Loading