Skip to content

Commit

Permalink
Merge pull request #9728 from webpack/validation/potential-config-err…
Browse files Browse the repository at this point in the history
…or-cache-groups

disallow shorthand cache groups syntax with cache group named test
  • Loading branch information
sokra committed Sep 24, 2019
2 parents 951bf0d + 03b32d3 commit 494b223
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 145 deletions.
4 changes: 4 additions & 0 deletions lib/WebpackOptionsValidationError.js
Expand Up @@ -362,6 +362,10 @@ class WebpackOptionsValidationError extends WebpackError {
err.parentSchema
)}`;
}
} else if (err.keyword === "not") {
return `${dataPath} should not be ${getSchemaPartText(
err.schema
)}\n${getSchemaPartText(err.parentSchema)}`;
} else if (err.keyword === "absolutePath") {
const baseMessage = `${dataPath}: ${
err.message
Expand Down
24 changes: 24 additions & 0 deletions schemas/WebpackOptions.json
Expand Up @@ -684,6 +684,30 @@
}
}
]
},
"not": {
"description": "Using the cacheGroup shorthand syntax with a cache group named 'test' is a potential config error\nDid you intent to define a cache group with a test instead?\ncacheGroups: {\n <name>: {\n test: ...\n }\n}",
"type": "object",
"additionalProperties": true,
"properties": {
"test": {
"description": "The test property is a cache group name, but using the test option of the cache group could be intended instead",
"anyOf": [
{
"instanceof": "Function",
"tsType": "Function"
},
{
"type": "string"
},
{
"instanceof": "RegExp",
"tsType": "RegExp"
}
]
}
},
"required": ["test"]
}
},
"chunks": {
Expand Down
3 changes: 2 additions & 1 deletion test/Schemas.lint.js
Expand Up @@ -50,7 +50,8 @@ describe("Schemas", () => {
"minItems",
"minProperties",
"instanceof",
"tsType"
"tsType",
"not"
];

const validateProperty = property => {
Expand Down

0 comments on commit 494b223

Please sign in to comment.