From f7128ebf6cb9f1d7e338867377d9cb83961d6f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Auberon=20L=C3=B3pez?= Date: Mon, 13 Mar 2023 21:25:58 -0700 Subject: [PATCH] docs: Add example to guard-for-in docs. 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);