refactor: Add lint rule for unsafe property access with lodash get/set (no-changelog) (#8587)

This commit is contained in:
Elias Meire
2024-02-08 15:32:04 +01:00
committed by GitHub
parent 8e392cfc1d
commit de6d466e5e
22 changed files with 90 additions and 71 deletions

View File

@@ -176,11 +176,11 @@ function optionSelected(optionName: string) {
// The "fixedCollection" entries are different as they save values
// in an object and then underneath there is an array. So initialize
// them differently.
const retrievedObjectValue = get(props.nodeValues, `${props.path}.${optionName}`, {});
const retrievedObjectValue = get(props.nodeValues, [props.path, optionName], {});
newValue = retrievedObjectValue;
} else {
// Everything else saves them directly as an array.
const retrievedArrayValue = get(props.nodeValues, `${props.path}.${optionName}`, []) as Array<
const retrievedArrayValue = get(props.nodeValues, [props.path, optionName], []) as Array<
typeof option.default
>;
if (Array.isArray(retrievedArrayValue)) {