I am using esLint for my angular project it throw an error for below code
private calculateFieldValue(value: any): any {
let isEmptyObject = false;
if (value && Array.isArray(value) && value.length === 1 && value[0]) {
for (const subAttr in value[0]) {
if (value[0].hasOwnProperty(subAttr)) {
if (value[0][subAttr]) {
break;
}
}
isEmptyObject = true;
}
}
return isEmptyObject ? null : value;
}
It threw the error:
error The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype guard-for-in