Skip to content

Commit

Permalink
fix: schema (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Nov 6, 2020
1 parent be9ddcb commit 4e4733d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 9 deletions.
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

0 comments on commit 4e4733d

Please sign in to comment.