Skip to content

fix: add description for watchFiles options #4057

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 1 commit into from
Nov 26, 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
5 changes: 4 additions & 1 deletion lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
24 changes: 24 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
},
};

Expand Down