mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: validate common property usage
`common` contains multiple 'check'(boolean) properties that will be false if mistyped and may lead to errors. This makes sure that the used property exists in the `common`. PR-URL: https://github.com/nodejs/node/pull/31933 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
2ec9b58a41
commit
5c86475e20
1 file changed
+10
-1
+10
-1
@@ -672,7 +672,7 @@ function invalidArgTypeHelper(input) {
|
||||
return ` Received type ${typeof input} (${inspected})`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const common = {
|
||||
allowGlobals,
|
||||
buildType,
|
||||
canCreateSymLink,
|
||||
@@ -815,3 +815,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const validProperties = new Set(Object.keys(common));
|
||||
module.exports = new Proxy(common, {
|
||||
get(obj, prop) {
|
||||
if (!validProperties.has(prop))
|
||||
throw new Error(`Using invalid common property: '${prop}'`);
|
||||
return obj[prop];
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user