diff --git a/lib/options.json b/lib/options.json index c79e3e2b94..36080418b8 100644 --- a/lib/options.json +++ b/lib/options.json @@ -984,10 +984,13 @@ "type": "string", "minLength": 1 } - ] + ], + "description": "Path(s) of globs/directories/files to watch for file changes." }, "options": { "type": "object", + "description": "Configure advanced options for watching. See the chokidar documentation for the possible options.", + "link": "https://github.com/paulmillr/chokidar#api", "additionalProperties": true } }, diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 104caceb00..208e889523 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }" `; +exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.watchFiles.options should be an object: + object { … } + -> Configure advanced options for watching. See the chokidar documentation for the possible options. + -> Read more at https://github.com/paulmillr/chokidar#api" +`; + +exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.watchFiles should be one of these: + [non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? } + -> Allows to configure list of globs/directories/files to watch for file changes. + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles + Details: + * options.watchFiles.paths should be one of these: + [non-empty string, ...] | non-empty string + -> Path(s) of globs/directories/files to watch for file changes. + Details: + * options.watchFiles.paths should be an array: + [non-empty string, ...] + * options.watchFiles.paths should be a non-empty string." +`; + exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.watchFiles should be one of these: diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 104caceb00..208e889523 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }" `; +exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.watchFiles.options should be an object: + object { … } + -> Configure advanced options for watching. See the chokidar documentation for the possible options. + -> Read more at https://github.com/paulmillr/chokidar#api" +`; + +exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.watchFiles should be one of these: + [non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? } + -> Allows to configure list of globs/directories/files to watch for file changes. + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles + Details: + * options.watchFiles.paths should be one of these: + [non-empty string, ...] | non-empty string + -> Path(s) of globs/directories/files to watch for file changes. + Details: + * options.watchFiles.paths should be an array: + [non-empty string, ...] + * options.watchFiles.paths should be a non-empty string." +`; + exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.watchFiles should be one of these: diff --git a/test/validate-options.test.js b/test/validate-options.test.js index fbd4fd805e..219e030a8b 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -548,7 +548,16 @@ const tests = { { paths: ["dir"], options: { usePolling: true } }, [{ paths: ["one-dir"] }, "two-dir"], ], - failure: [false, 123], + failure: [ + false, + 123, + { + paths: false, + }, + { + options: false, + }, + ], }, };