Skip to content

Commit

Permalink
docs: Add example to guard-for-in docs. (#16983)
Browse files Browse the repository at this point in the history
Adds an example to the correct code for the guard-for-in rule
that uses Object.hasOwn

Fixes #16981
  • Loading branch information
alope107 committed Mar 14, 2023
1 parent fd47998 commit 6157d81
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/src/rules/guard-for-in.md
Expand Up @@ -44,6 +44,12 @@ Examples of **correct** code for this rule:
```js
/*eslint guard-for-in: "error"*/

for (key in foo) {
if (Object.hasOwn(foo, key)) {
doSomething(key);
}
}

for (key in foo) {
if (Object.prototype.hasOwnProperty.call(foo, key)) {
doSomething(key);
Expand Down

0 comments on commit 6157d81

Please sign in to comment.