Skip to content

Commit e0d4501

Browse files
author
Joe Bottigliero
committed
[fix] webpackOptionsSchema
- Updates webpackOptionsSchema "stats" object to include "additionalProperties: false" - Adds missing stats options - Adds test for ensuring new stats options fail the schema check (if not included)
1 parent 33818bc commit e0d4501

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

schemas/webpackOptionsSchema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@
975975
"anyOf": [
976976
{
977977
"type": "object",
978+
"additionalProperties": false,
978979
"properties": {
979980
"context": {
980981
"type": "string",
@@ -997,6 +998,18 @@
997998
"type": "boolean",
998999
"description": "add assets information"
9991000
},
1001+
"env": {
1002+
"type": "boolean",
1003+
"description": "add --env information"
1004+
},
1005+
"colors": {
1006+
"type": "boolean",
1007+
"description": "`webpack --colors` equivalent"
1008+
},
1009+
"maxModules": {
1010+
"type": "number",
1011+
"description": "Set the maximum number of modules to be shown"
1012+
},
10001013
"chunks": {
10011014
"type": "boolean",
10021015
"description": "add chunk information"

test/Validation.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ describe("Validation", () => {
199199
message: [
200200
" - configuration.context: The provided value \"baz\" is not an absolute path!",
201201
]
202+
}, {
203+
name: "missing stats option",
204+
config: {
205+
entry: "foo.js",
206+
stats: {
207+
foobar: true
208+
}
209+
},
210+
test(e) {
211+
e.message.should.startWith("Invalid configuration object.");
212+
e.message.split("\n").slice(1)[0].should.be.eql(
213+
" - configuration.stats should be one of these:"
214+
);
215+
}
202216
}];
203217
testCases.forEach((testCase) => {
204218
it("should fail validation for " + testCase.name, () => {
@@ -207,6 +221,12 @@ describe("Validation", () => {
207221
} catch(e) {
208222
if(!(e instanceof WebpackOptionsValidationError))
209223
throw e;
224+
225+
if(testCase.test) {
226+
testCase.test(e);
227+
return;
228+
}
229+
210230
e.message.should.startWith("Invalid configuration object.");
211231
e.message.split("\n").slice(1).should.be.eql(testCase.message);
212232
return;

0 commit comments

Comments
 (0)