From 6157d813e19b80481a46f8cbdf9eae18a55e5619 Mon Sep 17 00:00:00 2001 From: alope107 Date: Tue, 14 Mar 2023 02:19:50 -0700 Subject: [PATCH] docs: Add example to guard-for-in docs. (#16983) Adds an example to the correct code for the guard-for-in rule that uses Object.hasOwn Fixes #16981 --- docs/src/rules/guard-for-in.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/rules/guard-for-in.md b/docs/src/rules/guard-for-in.md index 9481d2ad07f..f358e503039 100644 --- a/docs/src/rules/guard-for-in.md +++ b/docs/src/rules/guard-for-in.md @@ -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);