Skip to content

Commit 4e4733d

Browse files
authoredNov 6, 2020
fix: schema (#652)
1 parent be9ddcb commit 4e4733d

7 files changed

+100
-9
lines changed
 

‎src/loader-options.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "object",
3-
"additionalProperties": true,
3+
"additionalProperties": false,
44
"properties": {
55
"publicPath": {
66
"anyOf": [

‎src/plugin-options.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "object",
3-
"additionalProperties": true,
3+
"additionalProperties": false,
44
"properties": {
55
"filename": {
66
"anyOf": [

‎test/__snapshots__/validate-loader-options.test.js.snap

+48
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,51 @@ exports[`validate options should throw an error on the "publicPath" option with
2525
* options.publicPath should be a string.
2626
* options.publicPath should be an instance of function."
2727
`;
28+
29+
exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
30+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
31+
- options has an unknown property 'unknown'. These properties are valid:
32+
object { publicPath?, esModule?, modules? }"
33+
`;
34+
35+
exports[`validate options should throw an error on the "unknown" option with "[]" value 1`] = `
36+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
37+
- options has an unknown property 'unknown'. These properties are valid:
38+
object { publicPath?, esModule?, modules? }"
39+
`;
40+
41+
exports[`validate options should throw an error on the "unknown" option with "{"foo":"bar"}" value 1`] = `
42+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
43+
- options has an unknown property 'unknown'. These properties are valid:
44+
object { publicPath?, esModule?, modules? }"
45+
`;
46+
47+
exports[`validate options should throw an error on the "unknown" option with "{}" value 1`] = `
48+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
49+
- options has an unknown property 'unknown'. These properties are valid:
50+
object { publicPath?, esModule?, modules? }"
51+
`;
52+
53+
exports[`validate options should throw an error on the "unknown" option with "1" value 1`] = `
54+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
55+
- options has an unknown property 'unknown'. These properties are valid:
56+
object { publicPath?, esModule?, modules? }"
57+
`;
58+
59+
exports[`validate options should throw an error on the "unknown" option with "false" value 1`] = `
60+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
61+
- options has an unknown property 'unknown'. These properties are valid:
62+
object { publicPath?, esModule?, modules? }"
63+
`;
64+
65+
exports[`validate options should throw an error on the "unknown" option with "test" value 1`] = `
66+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
67+
- options has an unknown property 'unknown'. These properties are valid:
68+
object { publicPath?, esModule?, modules? }"
69+
`;
70+
71+
exports[`validate options should throw an error on the "unknown" option with "true" value 1`] = `
72+
"Invalid options object. Mini CSS Extract Plugin Loader has been initialized using an options object that does not match the API schema.
73+
- options has an unknown property 'unknown'. These properties are valid:
74+
object { publicPath?, esModule?, modules? }"
75+
`;

‎test/__snapshots__/validate-plugin-options.test.js.snap

+48
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,51 @@ exports[`validate options should throw an error on the "linkType" option with "i
9595
* options.linkType should be \\"text/css\\".
9696
* options.linkType should be a boolean."
9797
`;
98+
99+
exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
100+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
101+
- options has an unknown property 'unknown'. These properties are valid:
102+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
103+
`;
104+
105+
exports[`validate options should throw an error on the "unknown" option with "[]" value 1`] = `
106+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
107+
- options has an unknown property 'unknown'. These properties are valid:
108+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
109+
`;
110+
111+
exports[`validate options should throw an error on the "unknown" option with "{"foo":"bar"}" value 1`] = `
112+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
113+
- options has an unknown property 'unknown'. These properties are valid:
114+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
115+
`;
116+
117+
exports[`validate options should throw an error on the "unknown" option with "{}" value 1`] = `
118+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
119+
- options has an unknown property 'unknown'. These properties are valid:
120+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
121+
`;
122+
123+
exports[`validate options should throw an error on the "unknown" option with "1" value 1`] = `
124+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
125+
- options has an unknown property 'unknown'. These properties are valid:
126+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
127+
`;
128+
129+
exports[`validate options should throw an error on the "unknown" option with "false" value 1`] = `
130+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
131+
- options has an unknown property 'unknown'. These properties are valid:
132+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
133+
`;
134+
135+
exports[`validate options should throw an error on the "unknown" option with "test" value 1`] = `
136+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
137+
- options has an unknown property 'unknown'. These properties are valid:
138+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
139+
`;
140+
141+
exports[`validate options should throw an error on the "unknown" option with "true" value 1`] = `
142+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
143+
- options has an unknown property 'unknown'. These properties are valid:
144+
object { filename?, chunkFilename?, ignoreOrder?, insert?, attributes?, linkType? }"
145+
`;

‎test/cases/js-hash/webpack.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ module.exports = [1, 2].map((n) => {
1010
use: [
1111
{
1212
loader: Self.loader,
13-
options: {
14-
hmr: false,
15-
},
1613
},
1714
{
1815
loader: 'css-loader',

‎test/validate-loader-options.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ describe('validate options', () => {
1616
},
1717
unknown: {
1818
success: [],
19-
// TODO failed in next release
20-
// failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
19+
failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
2120
},
2221
};
2322

‎test/validate-plugin-options.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ describe('validate options', () => {
3838
},
3939
unknown: {
4040
success: [],
41-
// TODO failed in next release
42-
// failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
41+
failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }],
4342
},
4443
};
4544

0 commit comments

Comments
 (0)
Please sign in to comment.