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

fix: schema #652

Merged
merged 1 commit into from
Nov 6, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/loader-options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "object",
"additionalProperties": true,
"additionalProperties": false,
"properties": {
"publicPath": {
"anyOf": [
Expand Down
2 changes: 1 addition & 1 deletion src/plugin-options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "object",
"additionalProperties": true,
"additionalProperties": false,
"properties": {
"filename": {
"anyOf": [
Expand Down
48 changes: 48 additions & 0 deletions test/__snapshots__/validate-loader-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,51 @@ exports[`validate options should throw an error on the "publicPath" option with
* options.publicPath should be a string.
* options.publicPath should be an instance of function."
`;

exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "[]" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "{"foo":"bar"}" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "{}" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "1" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "false" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "test" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;

exports[`validate options should throw an error on the "unknown" option with "true" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin Loader 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 { publicPath?, esModule?, modules? }"
`;
48 changes: 48 additions & 0 deletions test/__snapshots__/validate-plugin-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,51 @@ exports[`validate options should throw an error on the "linkType" option with "i
* options.linkType should be \\"text/css\\".
* options.linkType should be a boolean."
`;

exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "[]" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "{"foo":"bar"}" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "{}" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "1" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "false" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "test" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;

exports[`validate options should throw an error on the "unknown" option with "true" value 1`] = `
"Invalid options object. Mini CSS Extract 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 { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
`;
3 changes: 0 additions & 3 deletions test/cases/js-hash/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ module.exports = [1, 2].map((n) => {
use: [
{
loader: Self.loader,
options: {
hmr: false,
},
},
{
loader: 'css-loader',
Expand Down
3 changes: 1 addition & 2 deletions test/validate-loader-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe('validate options', () => {
},
unknown: {
success: [],
// TODO failed in next release
// failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
},
};

Expand Down
3 changes: 1 addition & 2 deletions test/validate-plugin-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ describe('validate options', () => {
},
unknown: {
success: [],
// TODO failed in next release
// failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
},
};

Expand Down