guard-for-in
Configuration
rslint.config.ts
Rule Details
Require for-in loops to include an if statement. Iterating a for-in loop over an object exposes inherited prototype properties in addition to the object's own keys, so the body should typically be guarded (e.g. with Object.hasOwn, Object.prototype.hasOwnProperty.call, or a short-circuit continue) to filter unwanted properties.
Examples of incorrect code for this rule:
Examples of correct code for this rule: