Skip to content

Commit

Permalink
fix: output documentation link on errors (#3680)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Aug 19, 2021
1 parent d10bcc3 commit e16221b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
22 changes: 16 additions & 6 deletions lib/options.json
Expand Up @@ -71,12 +71,14 @@
},
"ClientLogging": {
"enum": ["none", "error", "warn", "info", "log", "verbose"],
"decription": "Allows to set log level in the browser."
"decription": "Allows to set log level in the browser.",
"link": "https://webpack.js.org/configuration/dev-server/#logging"
},
"ClientOverlay": {
"anyOf": [
{
"description": "Enables a full-screen overlay in the browser when there are compiler errors or warnings.",
"link": "https://webpack.js.org/configuration/dev-server/#overlay",
"type": "boolean"
},
{
Expand All @@ -97,6 +99,7 @@
},
"ClientProgress": {
"description": "Prints compilation progress in percentage in the browser.",
"link": "https://webpack.js.org/configuration/dev-server/#progress",
"type": "boolean"
},
"ClientWebSocketTransport": {
Expand All @@ -108,7 +111,8 @@
"$ref": "#/definitions/ClientWebSocketTransportString"
}
],
"description": "Allows to set custom web socket transport to communicate with dev server."
"description": "Allows to set custom web socket transport to communicate with dev server.",
"link": "https://webpack.js.org/configuration/dev-server/#websockettransport"
},
"ClientWebSocketTransportEnum": {
"enum": ["sockjs", "ws"]
Expand All @@ -119,6 +123,7 @@
},
"ClientWebSocketURL": {
"description": "Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).",
"link": "https://webpack.js.org/configuration/dev-server/#websocketurl",
"anyOf": [
{
"type": "string",
Expand Down Expand Up @@ -514,10 +519,12 @@
"directory": {
"type": "string",
"minLength": 1,
"description": "Directory for static contents."
"description": "Directory for static contents.",
"link": "https://webpack.js.org/configuration/dev-server/#directory"
},
"staticOptions": {
"type": "object",
"link": "https://webpack.js.org/configuration/dev-server/#staticoptions",
"additionalProperties": true
},
"publicPath": {
Expand All @@ -533,7 +540,8 @@
"type": "string"
}
],
"description": "The static files will be available in the browser under this public path."
"description": "The static files will be available in the browser under this public path.",
"link": "https://webpack.js.org/configuration/dev-server/#publicpath"
},
"serveIndex": {
"anyOf": [
Expand All @@ -545,7 +553,8 @@
"additionalProperties": true
}
],
"description": "Tells dev server to use serveIndex middleware when enabled."
"description": "Tells dev server to use serveIndex middleware when enabled.",
"link": "https://webpack.js.org/configuration/dev-server/#serveindex"
},
"watch": {
"anyOf": [
Expand All @@ -558,7 +567,8 @@
"link": "https://github.com/paulmillr/chokidar#api"
}
],
"description": "Watches for files in static content directory."
"description": "Watches for files in static content directory.",
"link": "https://webpack.js.org/configuration/dev-server/#watch"
}
}
},
Expand Down
17 changes: 13 additions & 4 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Expand Up @@ -69,13 +69,15 @@ exports[`options validate should throw an error on the "bonjour" option with ''
exports[`options validate should throw an error on the "client" option with '{"logging":"silent"}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.logging should be one of these:
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\""
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\"
-> Read more at https://webpack.js.org/configuration/dev-server/#logging"
`;

exports[`options validate should throw an error on the "client" option with '{"logging":"whoops!"}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.logging should be one of these:
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\""
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\"
-> Read more at https://webpack.js.org/configuration/dev-server/#logging"
`;

exports[`options validate should throw an error on the "client" option with '{"overlay":""}' value 1`] = `
Expand All @@ -90,6 +92,7 @@ exports[`options validate should throw an error on the "client" option with '{"o
Details:
* options.client.overlay should be a boolean.
-> Enables a full-screen overlay in the browser when there are compiler errors or warnings.
-> Read more at https://webpack.js.org/configuration/dev-server/#overlay
* options.client.overlay should be an object:
object { errors?, warnings? }"
`;
Expand All @@ -115,7 +118,8 @@ exports[`options validate should throw an error on the "client" option with '{"o
exports[`options validate should throw an error on the "client" option with '{"progress":""}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.progress should be a boolean.
-> Prints compilation progress in percentage in the browser."
-> Prints compilation progress in percentage in the browser.
-> Read more at https://webpack.js.org/configuration/dev-server/#progress"
`;

exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
Expand All @@ -134,6 +138,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
* options.client.webSocketTransport should be one of these:
\\"sockjs\\" | \\"ws\\" | non-empty string
-> Allows to set custom web socket transport to communicate with dev server.
-> Read more at https://webpack.js.org/configuration/dev-server/#websockettransport
Details:
* options.client.webSocketTransport should be one of these:
\\"sockjs\\" | \\"ws\\"
Expand Down Expand Up @@ -554,7 +559,8 @@ exports[`options validate should throw an error on the "static" option with '' v
exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.static.directory should be a non-empty string.
-> Directory for static contents."
-> Directory for static contents.
-> Read more at https://webpack.js.org/configuration/dev-server/#directory"
`;

exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
Expand All @@ -567,6 +573,7 @@ exports[`options validate should throw an error on the "static" option with '{"p
* options.static.publicPath should be one of these:
[string, ...] (should not have fewer than 1 item) | string
-> The static files will be available in the browser under this public path.
-> Read more at https://webpack.js.org/configuration/dev-server/#publicpath
Details:
* options.static.publicPath should be an array:
[string, ...] (should not have fewer than 1 item)
Expand All @@ -583,6 +590,7 @@ exports[`options validate should throw an error on the "static" option with '{"s
* options.static.serveIndex should be one of these:
boolean | object { … }
-> Tells dev server to use serveIndex middleware when enabled.
-> Read more at https://webpack.js.org/configuration/dev-server/#serveindex
Details:
* options.static.serveIndex should be a boolean.
* options.static.serveIndex should be an object:
Expand All @@ -599,6 +607,7 @@ exports[`options validate should throw an error on the "static" option with '{"w
* options.static.watch should be one of these:
boolean | object { … }
-> Watches for files in static content directory.
-> Read more at https://webpack.js.org/configuration/dev-server/#watch
Details:
* options.static.watch should be a boolean.
* options.static.watch should be an object:
Expand Down
17 changes: 13 additions & 4 deletions test/__snapshots__/validate-options.test.js.snap.webpack5
Expand Up @@ -69,13 +69,15 @@ exports[`options validate should throw an error on the "bonjour" option with ''
exports[`options validate should throw an error on the "client" option with '{"logging":"silent"}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.logging should be one of these:
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\""
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\"
-> Read more at https://webpack.js.org/configuration/dev-server/#logging"
`;

exports[`options validate should throw an error on the "client" option with '{"logging":"whoops!"}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.logging should be one of these:
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\""
\\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"verbose\\"
-> Read more at https://webpack.js.org/configuration/dev-server/#logging"
`;

exports[`options validate should throw an error on the "client" option with '{"overlay":""}' value 1`] = `
Expand All @@ -90,6 +92,7 @@ exports[`options validate should throw an error on the "client" option with '{"o
Details:
* options.client.overlay should be a boolean.
-> Enables a full-screen overlay in the browser when there are compiler errors or warnings.
-> Read more at https://webpack.js.org/configuration/dev-server/#overlay
* options.client.overlay should be an object:
object { errors?, warnings? }"
`;
Expand All @@ -115,7 +118,8 @@ exports[`options validate should throw an error on the "client" option with '{"o
exports[`options validate should throw an error on the "client" option with '{"progress":""}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.client.progress should be a boolean.
-> Prints compilation progress in percentage in the browser."
-> Prints compilation progress in percentage in the browser.
-> Read more at https://webpack.js.org/configuration/dev-server/#progress"
`;

exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
Expand All @@ -134,6 +138,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
* options.client.webSocketTransport should be one of these:
\\"sockjs\\" | \\"ws\\" | non-empty string
-> Allows to set custom web socket transport to communicate with dev server.
-> Read more at https://webpack.js.org/configuration/dev-server/#websockettransport
Details:
* options.client.webSocketTransport should be one of these:
\\"sockjs\\" | \\"ws\\"
Expand Down Expand Up @@ -554,7 +559,8 @@ exports[`options validate should throw an error on the "static" option with '' v
exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.static.directory should be a non-empty string.
-> Directory for static contents."
-> Directory for static contents.
-> Read more at https://webpack.js.org/configuration/dev-server/#directory"
`;

exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
Expand All @@ -567,6 +573,7 @@ exports[`options validate should throw an error on the "static" option with '{"p
* options.static.publicPath should be one of these:
[string, ...] (should not have fewer than 1 item) | string
-> The static files will be available in the browser under this public path.
-> Read more at https://webpack.js.org/configuration/dev-server/#publicpath
Details:
* options.static.publicPath should be an array:
[string, ...] (should not have fewer than 1 item)
Expand All @@ -583,6 +590,7 @@ exports[`options validate should throw an error on the "static" option with '{"s
* options.static.serveIndex should be one of these:
boolean | object { … }
-> Tells dev server to use serveIndex middleware when enabled.
-> Read more at https://webpack.js.org/configuration/dev-server/#serveindex
Details:
* options.static.serveIndex should be a boolean.
* options.static.serveIndex should be an object:
Expand All @@ -599,6 +607,7 @@ exports[`options validate should throw an error on the "static" option with '{"w
* options.static.watch should be one of these:
boolean | object { … }
-> Watches for files in static content directory.
-> Read more at https://webpack.js.org/configuration/dev-server/#watch
Details:
* options.static.watch should be a boolean.
* options.static.watch should be an object:
Expand Down

0 comments on commit e16221b

Please sign in to comment.